Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Lightweight project implementation #83

Merged
merged 5 commits into from
Sep 13, 2018
Merged

Conversation

spalladino
Copy link
Contributor

Provides an implementation named SimpleProject for a lib/Project that can manage proxies without setting up a Package or App contracts at all. Note that SimpleProject requires to be provided with two sender accounts, one for managing proxies and one for initializing them, since the TransparentProxy pattern makes it impossible for the admin of the proxy to invoke initialize (or any other function of the underlying instance).

Fixes #70

facuspagnuolo
facuspagnuolo previously approved these changes Sep 13, 2018
Copy link
Contributor

@facuspagnuolo facuspagnuolo left a comment

Choose a reason for hiding this comment

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

Looks really good, left some small comments :)


export default class AppProject extends Project {
export default class AppProject extends BasePackageProject {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can use just PackageProject

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I actually prefer to make it clear which are base classes, and which are leaves that can be actually instantiated.

if (!contractName) contractName = contractClass.contractName
if (!packageName) packageName = this.name
if (!_.isEmpty(initArgs) && !initMethod) initMethod = 'initialize'
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this check was already performed at an upper level, isn't it? If so, do you think it still make sense to have it duplicated?

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 may be done at an upper level on the CLI, but since we may want to start promoting usage of the lib directly, we need to have it here as well.

Copy link
Contributor Author

@spalladino spalladino Sep 13, 2018

Choose a reason for hiding this comment

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

Actually I scanned through the NetworkAppController, scripts/create, and commands/create, and didn't found it. It could be that I already removed it when making the change to Projects.

async _tryInitializeProxy(proxy, contractClass, initMethodName, initArgs) {
if (!initMethodName) return;
if (this.txParamsInitializer.from === this.txParamsAdmin.from) {
throw Error(`Cannot initialize the proxy from the same address as its admin address. Make sure you use a different 'from' account for the initialization transaction params.`)
Copy link
Contributor

Choose a reason for hiding this comment

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

I see why we need to do this but it will be completely weird for the users and I'm sure they won't understand it at once. If we move the initialization method call to the constructor, this shouldn't be a problem anymore, am I right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, that's why I was interested in pushing that change; we should work on it ASAP. Still, keep in mind that the user would still need a 2nd account to interact with the proxy after creating it, but at least the Project can work with a single account.

await proxy.changeAdmin(newAdmin)
log.info(`Proxy admin changed to ${newAdmin}`)
return proxy
}
Copy link
Contributor

Choose a reason for hiding this comment

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

In general, I'd love to expose an interface that abstracts you from the idea of having a proxy under the hood, even more if are planning to deal with non-upgradeable instances. Honestly, I don't have better options for naming now, we can think more about them later together

@@ -18,13 +17,14 @@ const assertions = helpers.assertions
const assertRevert = helpers.assertRevert

// model objects
import Proxy from './proxy/Proxy'
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we don't need to import this one right?

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 exported in L40 of this file

- Rename Project to PackageProject
- Add ProxyProject behaviour
- Minor changes in projects and baseapp
- Add create method
- Move buildCallData and callDescription out of BaseApp
- Add new sendDataTransaction method to Transactions object, to estimate gas of a manually crafted transaction
- Use sendDataTransaction when initializing a non-upgradable instance
- Add methods to proxy to support deploying and managing
Since it is an abstract class
@spalladino
Copy link
Contributor Author

@facuspagnuolo could you please re-review? I've only rebased on top of next

Copy link
Contributor

@facuspagnuolo facuspagnuolo left a comment

Choose a reason for hiding this comment

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

LGTM!

@mergify mergify bot merged commit b19992c into next Sep 13, 2018
@spalladino spalladino deleted the feature/lightweight-projects branch September 13, 2018 16:25
spalladino added a commit that referenced this pull request Sep 24, 2018
* Add tests for proxy management in app project

- Rename Project to PackageProject
- Add ProxyProject behaviour
- Minor changes in projects and baseapp

* Move Proxy from utils to models

- Add create method

* Refactor buildCallData methods into an ABIs utils

- Move buildCallData and callDescription out of BaseApp
- Add new sendDataTransaction method to Transactions object, to estimate gas of a manually crafted transaction
- Use sendDataTransaction when initializing a non-upgradable instance

* Initial implementation of simple project

- Add methods to proxy to support deploying and managing

* Rename PackageProject to BasePackageProject

Since it is an abstract class
spalladino added a commit that referenced this pull request Sep 24, 2018
* Add tests for proxy management in app project

- Rename Project to PackageProject
- Add ProxyProject behaviour
- Minor changes in projects and baseapp

* Move Proxy from utils to models

- Add create method

* Refactor buildCallData methods into an ABIs utils

- Move buildCallData and callDescription out of BaseApp
- Add new sendDataTransaction method to Transactions object, to estimate gas of a manually crafted transaction
- Use sendDataTransaction when initializing a non-upgradable instance

* Initial implementation of simple project

- Add methods to proxy to support deploying and managing

* Rename PackageProject to BasePackageProject

Since it is an abstract class
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status:ready-to-merge Order mergify to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants