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

Removing signer from the Action constructor #372

Open
marcelomorgado opened this issue May 2, 2019 · 6 comments
Open

Removing signer from the Action constructor #372

marcelomorgado opened this issue May 2, 2019 · 6 comments
Labels
enhancement New feature or request tech debt Technical debt not involving bugs or features
Milestone

Comments

@marcelomorgado
Copy link
Contributor

marcelomorgado commented May 2, 2019

A signer shouldn't be mandatory for an action creation. A setter function should be created (Action.setSigner()) instead.

Notes:

  • The current Contract code will throw an error if a write function is called without a signer/wallet set. That check should move to the Action.send() function.
  • Signer here is the account object created by the tasit-account package.
@marcelomorgado marcelomorgado added enhancement New feature or request tech debt Technical debt not involving bugs or features labels May 2, 2019
@marcelomorgado marcelomorgado added this to the 0.2.0 release milestone May 2, 2019
@pcowgill
Copy link
Member

pcowgill commented May 2, 2019

@marcelomorgado Here's what I was trying to convey in the thread that led to this issue. I "misspoke" so it didn't come across clearly.

I think users would probably want to set the signer for the Contract rather than the Action, and then every Action for that Contract would use that signer.

@marcelomorgado
Copy link
Contributor Author

@marcelomorgado Here's what I was trying to convey in the thread that led to this issue. I "misspoke" so it didn't come across clearly.

I think users would probably want to set the signer for the Contract rather than the Action, and then every Action for that Contract would use that signer.

Ok, I agree. I'm thinking to keep the contract behavior the same as it's today. When a write function will be called the Action object will be instantiated and the signer will be set (the contract's signer).
I've thought to move the signer from the Action constructor to support a use like that:

const rawTx = "...";
const action = new Action(rawTx, provider);
// add signer later
action.setSigner(tasitAccount);
action.send(); // same as signAndSend

Makes sense?

@pcowgill
Copy link
Member

pcowgill commented May 2, 2019

Oh okay, so it's already using the contract's signer by default? I see now.

Then yeah, being able to override that with a custom signer is a useful feature - just shoudn't be a mandatory part of the constructor.

If it were an optional part of the constructor with a default rather than using set, that would be fine with me too. No preference.

@pcowgill
Copy link
Member

pcowgill commented May 2, 2019

const rawTx = "...";
const action = new Action(rawTx, provider);
// add signer later
action.setSigner(tasitAccount);
action.send(); // same as signAndSend

In this ^ example, when is it signed?

@marcelomorgado
Copy link
Contributor Author

marcelomorgado commented May 2, 2019

const rawTx = "...";
const action = new Action(rawTx, provider);
// add signer later
action.setSigner(tasitAccount);
action.send(); // same as signAndSend

In this ^ example, when is it signed?

We have the private signAndSend method, and for now send is an alias for that.

@pcowgill
Copy link
Member

pcowgill commented May 2, 2019

We have the private signAndSend method, and for now send is an alias for that.

Ah right. Got it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tech debt Technical debt not involving bugs or features
Projects
None yet
Development

No branches or pull requests

2 participants