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

feat: add genesis hash to injected accounts #236

Merged

Conversation

tien
Copy link
Contributor

@tien tien commented Jun 25, 2024

DApp will use this to determine which network can the account be used with. This is especially important in this case, as accounts are always restricted to one network.

@CLAassistant
Copy link

CLAassistant commented Jun 25, 2024

CLA assistant check
All committers have signed the CLA.

@tien tien force-pushed the feat/add-genesis-hash-to-injected-accounts branch from 53df365 to 240b709 Compare July 1, 2024 10:11
@BeroBurny
Copy link
Contributor

Hey. Thanks for taking the time to contribute.

There is an issue I see the genesisHash will be part of the account only in case if is provided by config and only that hash.
Is that intentional? If not what is intention?

@tien
Copy link
Contributor Author

tien commented Jul 1, 2024

Hey. Thanks for taking the time to contribute.

There is an issue I see the genesisHash will be part of the account only in case if is provided by config and only that hash. Is that intentional? If not what is intention?

Hey @BeroBurny, for example, if the account has the "Kusama genesis hash" attached to it, DApp will know that the account can only sign Kusama transaction. Which is true for this snap because enablePolkadotSnap accept a config of 1 network only.

@BeroBurny
Copy link
Contributor

Hey. Thanks for taking the time to contribute.
There is an issue I see the genesisHash will be part of the account only in case if is provided by config and only that hash. Is that intentional? If not what is intention?

Hey @BeroBurny, for example, if the account has the "Kusama genesis hash" attached to it, DApp will know that the account can only sign Kusama transaction. Which is true for this snap because enablePolkadotSnap accept a config of 1 network only.

That will work if the user provide config, but in case there is no config provided value will be undefined as is not sent from snap to client (adapter)

Copy link
Contributor

@Lykhoyda Lykhoyda left a comment

Choose a reason for hiding this comment

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

Agree with @BeroBurny please take care of his comment

@tien tien force-pushed the feat/add-genesis-hash-to-injected-accounts branch from 240b709 to 85fff72 Compare July 1, 2024 11:06
@tien
Copy link
Contributor Author

tien commented Jul 1, 2024

Thanks for the review, I have made genesisHash mandatory for custom network 🙏.

@tien tien requested a review from Lykhoyda July 1, 2024 11:07
@tien tien force-pushed the feat/add-genesis-hash-to-injected-accounts branch from 85fff72 to 31d62e7 Compare July 1, 2024 11:11
DApp will use this to determine which network can the account be used with.
This is especially important in this case, as accounts are always restricted to one network.
@tien tien force-pushed the feat/add-genesis-hash-to-injected-accounts branch from 31d62e7 to 259590d Compare July 1, 2024 11:19
@BeroBurny
Copy link
Contributor

Thanks for the review, I have made genesisHash mandatory for custom network 🙏.

My bad seems I miscommunicated the issue.

Let us begin with the basics, snap is like a microservice. The browser is calling an extension and we get data back.

User => Browser <=> Snap

So the adapter lives in the browser and snaps inside MetaMask.
With the current setup browser never gets configured from snap, as there is no method to retrieve it. So adding data to config in a snap is not going to do anything on the adapter part and the browser in this case only gets the user address but no information about the genesis.

So current solution to that falls on top of my head.
a) Implement retrieving config method
b) Include genesis hash in response to getAddress
c) Open the issue and hope someone solves the problem

@tien
Copy link
Contributor Author

tien commented Jul 1, 2024

Alright, thanks for the clarification, would you say option a make the most sense here? @BeroBurny

BeroBurny
BeroBurny previously approved these changes Jul 2, 2024
Copy link
Contributor

@BeroBurny BeroBurny left a comment

Choose a reason for hiding this comment

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

Great Job, Thanks for taking the time :)

@Lykhoyda @irubido Please check it if I missed something

irubido
irubido previously approved these changes Jul 2, 2024
Copy link
Contributor

@irubido irubido left a comment

Choose a reason for hiding this comment

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

Looks good to me, genesisHash as requirement for custom config 👍

packages/types/index.d.ts Outdated Show resolved Hide resolved
@tien tien dismissed stale reviews from irubido and BeroBurny via 050398f July 2, 2024 20:22
@tien tien force-pushed the feat/add-genesis-hash-to-injected-accounts branch from 68cf769 to 050398f Compare July 2, 2024 20:22
@BeroBurny BeroBurny merged commit bc73e6c into ChainSafe:master Jul 3, 2024
3 of 4 checks passed
@github-actions github-actions bot mentioned this pull request Jul 1, 2024
BeroBurny pushed a commit that referenced this pull request Jul 24, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>metamask-polkadot-adapter: 0.8.0</summary>

##
[0.8.0](metamask-polkadot-adapter-v0.7.0...metamask-polkadot-adapter-v0.8.0)
(2024-07-03)


### Features

* add genesis hash to injected accounts
([#236](#236))
([bc73e6c](bc73e6c))


### Bug Fixes

* incorrect account type
([#237](#237))
([ae02ce9](ae02ce9))
</details>

<details><summary>metamask-polkadot-types: 0.9.0</summary>

##
[0.9.0](metamask-polkadot-types-v0.8.0...metamask-polkadot-types-v0.9.0)
(2024-07-03)


### Features

* add genesis hash to injected accounts
([#236](#236))
([bc73e6c](bc73e6c))
</details>

<details><summary>polkadot-snap: 0.11.0</summary>

##
[0.11.0](polkadot-snap-v0.10.0...polkadot-snap-v0.11.0)
(2024-07-03)


### Features

* add genesis hash to injected accounts
([#236](#236))
([bc73e6c](bc73e6c))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

5 participants