-
-
Notifications
You must be signed in to change notification settings - Fork 350
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
Refactor: Move all components to separate files #379
Conversation
* chore: refactor signature types to different components * fix: injection order of components
And committing a naming crime, but we will allow it
This introduces a new parameters on `globalContext` called `_connected` with a getter and setter. When set to a new value, the setter dispatches a custom event `globalConnectionChange`. Each module with a button that needs to be enabled when MetaMask is connected thus has an event listener for that event. Now, those buttons are enabled via the listener. This gets us part way to relying on listeners for all state changes.
Also fix a few small errors from previous commits
* chore: Split transactions into separate components * chore: add index.js to export all modules * chore: add index.js to export all modules
Unfortunately most of the connection logic is still in index.js and is hard to untangle
export function signTypedDataV3Component(parentContainer) { | ||
parentContainer.insertAdjacentHTML( | ||
'beforeend', | ||
`<div class="col-xl-4 col-lg-6 col-md-12 col-sm-12 col-12 d-flex align-items-stretch"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Would it make sense to keep a separate HTML file for each component so that it has syntax highlighting, and import the markup here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. There are other ways to do it too, like importing a JSX parser so you can use JSX fragments instead of strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Or just use a plugin, or just bite the bullet and port to React :) )
Ran all e2e on chrome and firefox successfully with a patch version from local: MetaMask/metamask-extension#29433 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi there! Nice work 🔥
I'm in the middle of the testing, will update this comment with my findings.
So far, I found that whenever I am using the Wallet Connect functionalty several buttons remain disabled (deploy contracts, signatures..) see video with the comparision of current prod and this test dapp version below:
wallet-connect-btn-disabled.mp4
[Update] The rest seems to work fine on my end!
</p> | ||
</div> | ||
</div> | ||
</div>`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice new section! Suggestion: could we add a Verify
section too, so we are sure the wallet works correctly with those signature values?
No need to be in this PR, but would be nice to have this, at some point
Hmmm @pnarayanaswamy we will have to figure out where this might have gone wrong... maybe just missed some elements in the events? |
b8b2cbb
Please try again, just merged a fix by @pnarayanaswamy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, I see the issue fixed now!!
wc-dapp.mp4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this functionality seems to be incorrectly placed under transactions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this file could be consolidated with the network data we already have here
https://github.com/MetaMask/test-dapp/blob/main/src/onchain-sample-contracts.js#L2
Malicious Permit | ||
</button> | ||
<button | ||
class="btn btn-primary btn-lg btn-block mb-3" | ||
id="maliciousTradeOrder" | ||
disabled | ||
> | ||
Malicious Trade Order | ||
</button> | ||
<button | ||
class="btn btn-primary btn-lg btn-block mb-3" | ||
id="maliciousSeaport" | ||
disabled | ||
> | ||
Malicious Seaport | ||
</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this section is placed under ppom/transactions but those are actually signatures
- Malicious Permit
- Malicious Trade Order
- Malicious Seaport
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is how the test-dapp was originally organized. We could rename transactions.js to something else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the following content is related to transactions, but it's placed under signatures folder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the way the cards are grouped is based on the name of the section. It's not ideal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One solution could be to move this card to the transactions section, but I did not want to make any IA changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mm yeah so I think something could be improved there, as at the moment the current folder naming doesn't completely match the classification 🤔
mm if I imagine if I want to add a new section, let's say Solana tx's and signatures, where will they go?
I think the natural way might be to create a solana folder, and inside, to have a signature component and then a tx component.
So I think we might want to follow the same approach here. We could have a folder for Malformed Interactions and inside we can distinguish between signatures and tx. Same goes for Blockaid and so on.
-- Malformed Interactions
|
|--- Signatures
|--- Transactions
-- Malicious Interactions
|
|--- Signatures
|--- Transactions
-- Solana
|
|--- Signatures
|--- Transactions
What do you think?
The functionality seems to be preserved so I've approved the PR, but recently added a couple of nits regarding the re-org, non-blocking but might be worth taking a look now or in a future PR |
@seaona I think overall the IA nits should be for the developers who made these cards. I don't want to mess with how the cards are grouped and sorted, my intention was to keep the IA the same. |
This is the release candidate PR for `v9.0.0` ### Added - Add SignTypedData primaryType variants: Blur - Order, PermitBatch, PermitSingle, Seaport - BulkOrder ([#376](#376)) ### Changed - Move all components to separate files, use shared global state and events for updating cards based on connect / disconnect / deploy contract ([#379](#379))
* Release Candidate v9.0.0 This is the release candidate PR for `v9.0.0` ### Added - Add SignTypedData primaryType variants: Blur - Order, PermitBatch, PermitSingle, Seaport - BulkOrder ([#376](#376)) ### Changed - Move all components to separate files, use shared global state and events for updating cards based on connect / disconnect / deploy contract ([#379](#379)) * Put Unreleased lines back in CHANGELOG
hi there 👋 thanks for the reply!! I made a couple of the cards mentioned above so I'm happy to add the changes if they make sense to you! |
This refactors everything as independent modules with shared global context. We also attempted to
This refactor does not:
But it's progress