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

Transaction signer, callable SmartContracts, Update user connector. #21

Merged
merged 24 commits into from
May 17, 2018

Conversation

digitaldonkey
Copy link
Owner

No description provided.

@digitaldonkey
Copy link
Owner Author

@amateescu Do I use the services wisely now? I'm sometimes a little unsure. Ii would be very happy to get your feedback on that.

Copy link
Collaborator

@amateescu amateescu left a comment

Choose a reason for hiding this comment

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

Reviewed the parts of the module that I'm familiar with :)

* @return array
* Table render array.
*/
public function getDeployedAsTable() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

An entity object shouldn't provide methods that output render arrays, that's the job of a list builder or a specialized controller.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Moved to ethereum_user_connector/src/Form/AdminForm.php

Copy link
Owner Author

Choose a reason for hiding this comment

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

Moved to form

/**
* @inheritdoc
*/
public function status();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This method is already defined by ConfigEntityInterface so we don't need to declare it again.

Copy link
Owner Author

Choose a reason for hiding this comment

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

removed.

*
* @var boolean
*/
protected $status;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is already defined by ConfigEntityBase, no need to redefine it here.

Copy link
Owner Author

Choose a reason for hiding this comment

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

removed

@@ -21,15 +23,20 @@ class EthereumController extends ControllerBase {
*
* @var \Ethereum\Ethereum
*/
protected $client;
public $client;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need this change?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Made protected and renamed to web3 for consistency.

*/
public function __construct(Ethereum $ethereum_client) {
$this->client = $ethereum_client;
public function __construct(Ethereum $web3 = NULL) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change should not be needed since we're are injecting the ethereum client from the container.

I assume that some other code is not initializing this class properly..

Copy link
Owner Author

Choose a reason for hiding this comment

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

Hopefully fixed. This topic is still confusing for me.

$client = \Drupal::service('ethereum.client_factory')->get($this->getUrl());
/** @var \Ethereum\Ethereum $web3 */
$web3 = new Ethereum($this->url);
// @todo How to load the \Drupal::service('ethereum.client') with a updated url?
Copy link
Collaborator

Choose a reason for hiding this comment

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

The previous code was already handling that..

Copy link
Owner Author

Choose a reason for hiding this comment

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

ok. Reverted to your code.

* @return array
* Table render array.
*/
public function getServerInfoAsTable() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

As mentioned above, we shouldn't put these kinds of methods on the config entity, but in their specific controller instead.

Copy link
Owner Author

Choose a reason for hiding this comment

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

moved to form

if ($status == SAVED_UPDATED) {
$this->messenger()->addStatus($this->t('The server %label has been updated.', ['%label' => $server->label()]));
drupal_set_message($this->t('The server %label has been updated.', ['%label' => $server->label()]));
Copy link
Collaborator

Choose a reason for hiding this comment

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

drupal_set_message() is deprecated, the previous code is using the proper API.

Copy link
Owner Author

Choose a reason for hiding this comment

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

cleaned up all usages of drupal_set_message()

}
elseif ($status == SAVED_NEW) {
$this->messenger()->addStatus($this->t('The server %label has been added.', ['%label' => $server->label()]));
drupal_set_message($this->t('The server %label has been added.', ['%label' => $server->label()]));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here.

Copy link
Owner Author

Choose a reason for hiding this comment

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

cleaned up all usages of drupal_set_message()

@@ -35,6 +35,10 @@ public static function defaultSettings() {
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$element = parent::formElement($items, $delta, $element, $form, $form_state);

if ($element['value']['#default_value']) {
$element['value']['#attributes']['data-original-value'] = $element['value']['#default_value'];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need the original value here?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I use it to check if a address entry is the same than before, in order to give the address_status the right value. You are right: technically it should be somewhere in ethereum_user_connector module. There are 3 fields on the user required to manage the contract registry subscription (address, hash, address_status).

$eth = new EthereumUserConnectorController();
$validation = $eth->verifyUserByHash(Xss::filter($hash));

$controller = new EthereumUserConnectorController();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here and in all the other places which instantiate EthereumUserConnectorController, we need to do it through the class resolver instead, like this: \Drupal::service('class_resolver')->getInstanceFromDefinition(EthereumUserConnectorController::class)

This will properly inject the dependencies from the container, and I'm pretty sure it's the reason for the changes to the constructor of \Drupal\ethereum\Controller\EthereumController (i.e. those changes can be reverted)

@@ -0,0 +1,92 @@
# Metamask Mascara wrapper
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 this be a stand-alone JS library (in a separate github repo) that the module would require?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes. It actually is a external library.

What I still miss is how to load external libs with composer. Seems we need to add asset-packagist to the root composer json like Thunder distribution does. Was hoping we will get that in core soon, before externalizing the dependencies.

@digitaldonkey digitaldonkey merged commit 680f622 into 8.x-1.x May 17, 2018
@digitaldonkey digitaldonkey deleted the feature-GlobalTransactionSigner branch May 18, 2018 23:49
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.

None yet

2 participants