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

Action.send(); #357

Merged
merged 13 commits into from
Apr 27, 2019
Merged

Action.send(); #357

merged 13 commits into from
Apr 27, 2019

Conversation

marcelomorgado
Copy link
Contributor

Issue link

#162

Auto-close the issue?

Closes #162

Types of changes

New feature (non-breaking change that adds functionality)

Breaking change (fix or feature that would cause existing functionality not to work as expected)

Notes

  • The send() function is async and the use of await on the call is necessary for now (Since we are still using waitForOneConfirmation()), it should be changed on the Test suite should capture how we expect the library to be used #219

  • The way that GnosisSafe was coded introduced an extra complexity to the Action object: A function that should be sync but creates an action from a sequence of async calls (See: GnosisSafe.executeTransaction()). The solution that I've found is assuming that the rawTx param (from Action constructor) could be a promise or not.
    Maybe a better name could be used instead of rawTx (maybe rawAction?).

@pcowgill
Copy link
Member

The send() function is async and the use of await on the call is necessary for now (Since we are still using waitForOneConfirmation()), it should be changed on the #219

Makes sense

The way that GnosisSafe was coded introduced an extra complexity to the Action object: A function that should be sync but creates an action from a sequence of async calls (See: GnosisSafe.executeTransaction()). The solution that I've found is assuming that the rawTx param (from Action constructor) could be a promise or not.

Makes sense! Thanks for this info, that's helpful.

Maybe a better name could be used instead of rawTx (maybe rawAction?).

Sounds good

pcowgill
pcowgill previously approved these changes Apr 26, 2019
packages/tasit-action/src/contract/Action.js Show resolved Hide resolved
}

_toRaw = async () => {
return await this.#rawTx;
Copy link
Member

Choose a reason for hiding this comment

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

Can we handle whether to await it or not upstream of this function somehow? Like only call _toRaw once we know the promise has resolved? Or only use this in tasit-contract-based-account?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. I need to think about it, not sure.
  2. For now, we are using that function only on tasit-contract-based-account GnosisSafe class.

Copy link
Member

Choose a reason for hiding this comment

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

  1. Okay. Keep me posted. My intuition tells me that move would make sense, but I haven't thought it through fully.
  2. Yep, I thought so. That's part of my rough reasoning for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've made a change on this PR #360
On these changes, we are assuming that the Action will expect a sync rawTx on the constructor but the signAndSend function stills using await to resolve that. It isn't 100% solution, though.
Another path is to force rawTx to be sync (removing the await inside of the signAndSend but that'll make GnosisSafe.executeTransaction to be async (on the way that is written for now).

Copy link
Member

Choose a reason for hiding this comment

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

I don't have time to think this through fully right now - feel free to go with whatever you thinks makes the most sense for now, and I'll circle back to this soon

Copy link
Member

Choose a reason for hiding this comment

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

Or wait, maybe what I just said is wrong

Copy link
Member

Choose a reason for hiding this comment

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

I guess what I'm asking is this: At a high level, what is it about GnosisSafe.executeTransaction that prevents it from having a rawTx ready to go right away?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess what I'm asking is this: At a high level, what is it about GnosisSafe.executeTransaction that prevents it from having a rawTx ready to go right away?

The [#prepareTransaction](https://github.com/tasitlabs/TasitSDK/blob/4111170669afb4447cb95315f45fd4ecd1fa02ec/packages/tasit-contract-based-account/src/GnosisSafe.js#L157).
That function has some async calls needed to create a safe transaction (e.g.: GnosisSafeContract.nonce (L199) and GnosisSafeContract.getTransactionHash (L201)).
These async calls are nested and needed to create the transaction that we want to be executed by the GnosisSafeContract.
My intention is to have the GnosisSafe encapsulating all that is possible, transparent to the user.

Copy link
Member

Choose a reason for hiding this comment

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

transparent to the user or opaque to the user?

Copy link
Contributor Author

@marcelomorgado marcelomorgado May 2, 2019

Choose a reason for hiding this comment

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

🤦‍♂️ I don't know why I've used the "transparent" word. Opaque was what I've meant. Thanks

packages/tasit-action/src/contract/Action.js Outdated Show resolved Hide resolved
packages/tasit-action/src/contract/Contract.js Outdated Show resolved Hide resolved
packages/tasit-action/src/erc721/ERC721Full.test.js Outdated Show resolved Hide resolved
@pcowgill
Copy link
Member

@marcelomorgado What does TBD: mean in the name of this PR?

@marcelomorgado
Copy link
Contributor Author

@marcelomorgado What does TBD: mean in the name of this PR?

To Be Discussed

@marcelomorgado marcelomorgado changed the title TBD: Action.send(); Action.send(); Apr 26, 2019
@pcowgill
Copy link
Member

@marcelomorgado What does TBD: mean in the name of this PR?

To Be Discussed

Ah ok cool. It's often used to mean To Be Determined, so I was confused

@pcowgill
Copy link
Member

@marcelomorgado I don't think any of the open comment threads gate merging this. Nicely done with this PR, by the way! Any objection to merging it now?

@marcelomorgado
Copy link
Contributor Author

@marcelomorgado I don't think any of the open comment threads gate merging this. Nicely done with this PR, by the way! Any objection to merging it now?

Let's merge!

@pcowgill pcowgill merged commit 7d83e73 into develop Apr 27, 2019
@pcowgill pcowgill deleted the feature/action.send branch April 27, 2019 00:57
@marcelomorgado marcelomorgado mentioned this pull request Apr 30, 2019
#tx;
#txConfirmations;
#timeout;
#lastConfirmationTime;

constructor(txPromise, provider) {
constructor(rawTx, provider, signer) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Creating a thread for that:

Maybe a better name could be used instead of rawTx (maybe rawAction?).

Sounds good

To track easily.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allows Action to send tx after object creation
2 participants