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

Near Snap - MetaMask Snap to support NEAR network #460

Merged
merged 34 commits into from
Feb 28, 2023

Conversation

BeroBurny
Copy link
Contributor

Description

NEAR Snap extends the capability of MetaMask to interact with the NEAR network.

  • Snaps is a system that allows anyone to expand the capabilities of MetaMask safely.
  • Snaps is pre-release software, To try Snaps, install MetaMask Flask.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

@kujtimprenkuSQA
Copy link
Contributor

Hey, @BeroBurny thank you for submitting this PR.

Can you make sure that Near Snap follows these criteria:
https://github.com/near/wallet-selector/blob/main/CONTRIBUTING.md#listing-criteria-for-third-party-wallet-on-wallet-selector

Could you please explain how to use this wallet: how do we create an account or import an existing one (i.e kujtimprenku.testnet)?

@irubido
Copy link
Contributor

irubido commented Sep 22, 2022

Hey, @BeroBurny thank you for submitting this PR.

Can you make sure that Near Snap follows these criteria: https://github.com/near/wallet-selector/blob/main/CONTRIBUTING.md#listing-criteria-for-third-party-wallet-on-wallet-selector

Could you please explain how to use this wallet: how do we create an account or import an existing one (i.e kujtimprenku.testnet)?

Hi @kujtimprenkuSQA,
Near Snap follows the criteria linked above.
It uses Metamask Flask extension https://metamask.io/flask/ that support snaps, it derives Near address from metamask seed.
Importing and exporting is the same as with Metamask, through extension.
I'll update readme to be more specific about Metamask interaction.

@kujtimprenkuSQA
Copy link
Contributor

Hey, @BeroBurny.

I will share my experience with Near Snap and I also have some questions.

For a user it is very unclear what is happening under the hood when using this wallet, I downloaded and installed the extension then created a new "Ethereum" account it was not clear how this account will be used just when I tried to sign in via Wallet Selector then I noticed a message 429380d6c79d10d1b7cd5b457153d8f433e9dec37e29bf52467cc1a30bdd74c0 does not exist this account was somehow created based on the "Ethereum" account created through the extension but because it had 0 NEAR on it the sign in did not work what's strange is that I never saw that account id anywhere in the Extension indicating that this is the account id based on the Ethereum account.

Questions/ comments:

  • There's no way to know if the above account id is testnet or mainnet (near) account.
  • The network in the extension shows as Ethereum Mainnet even though I was able to signIn and signOut with a near account (possibly testnet). - How do we add a NEAR testnet or mainnet network?
  • When I try to sign and send a transaction the UI is not showing any useful information (like the amount, action type, text message, gas price etc).
  • When you connect/signIn to a website through MetaMask on the left side there's a button that says Connected but in this case even though I sing in successfully it still says Not Connected
  • I created a second Ethereum account and switching to that account does nothing when I sign in via Wallet Selector it still selects the above account id which was created for my first account.
  • I transferred 5 NEAR from kujtimprenku.testnet to 429380d6c79d10d1b7cd5b457153d8f433e9dec37e29bf52467cc1a30bdd74c0 but they don't show anywhere in the Near Snap shows as 0 ETH $0.00 USD
  • How does signOut work? - I click the signout button and switch the account in the extension then try to sign in it still selects the first account I created there.
  • Assets and Activity tabs in the extension don't show any information.

Did anything change in the source code of Near Snap?

Today I tried to test how this would work if I exported the account first and then removed the extension after that I re-installed it and imported the account but this wallet does not work anymore I see this error when I click Connect on the wallet's UI:
Errors-Flask

@AmmarHumackicSQA
Copy link
Contributor

Hey @BeroBurny @irubido I just wanted to check the status regarding the work on this. Do you guys have any updates or any questions? Hvala 😉

@danforbes
Copy link

Hi, @AmmarHumackicSQA - I am the ChainSafe project manager for our work on the NEAR snap. this Pull Request was made as part of a contract that was signed by ChainSafe and the NEAR Foundation. I agree with many of the concerns raised by @kujtimprenkuSQA, but in many/most cases they speak to limitations of the snap system itself. Snaps are still in beta so it's possible that as the snap ecosystem matures the concerns that have been brought up will be addressed, but at this time it's not within the scope of work (or in many cases even the scope of possibility) for ChainSafe developers to address the issues that have been brought up. Please let me know if you'd like to set up some time to chat about this and we'll figure out a way to make that work.

# Conflicts:
#	README.md
#	examples/react/contexts/WalletSelectorContext.tsx
#	workspace.json
# Conflicts:
#	README.md
#	examples/react/contexts/WalletSelectorContext.tsx
@kujtimprenkuSQA
Copy link
Contributor

Hey, @danforbes I have noticed two potential issues and I am unable to use this Wallet (snap)

  • When Metamask is installed then this error shows up, and the wallet selector fails to initialize (disabling Metamaks makes the error go away):

near-snap-error

  • I am unable to sign in with this Wallet, this error shows up for me (this is the same error I mentioned on September 26 see the comment):

near-snap-sign-in-error

I just installed MetaMask Flask DEVELOPMENT and created a new Account, and tried to sign in with Wallet Selector, is there any extra step/work I need to do to successfully signIn in to the guest-book example with Near Snap?

@danforbes
Copy link

@kujtimprenkuSQA - this is a known bug that occurs when both MetaMask and MetaMask Flask are installed as extensions in the same browser. Based on the first screenshot you shared, that seems to be the cause of the problem you're experiencing.

@gutsyphilip
Copy link
Contributor

d on the first screenshot yo

@kujtimprenkuSQA - this is a known bug that occurs when both MetaMask and MetaMask Flask are installed as extensions in the same browser. Based on the first screenshot you shared, that seems to be the cause of the problem you're experiencing.

@danforbes Should we expect an update that'd fix these or is this out of the domain of Snaps?

@danforbes
Copy link

@gutsyphilip the answer to that question is out of my domain as I am not associated with the MetaMask team; I am associated with the team at ChainSafe that implemented the Near snap, with the support of the Near Foundation.

Copy link
Contributor

@kujtimprenkuSQA kujtimprenkuSQA left a comment

Choose a reason for hiding this comment

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

Hey, @irubido thank you for updating the PR.
Left a few comments and questions, also looks like there are some linting issues/errors to check them try running:
yarn nx run near-snap:lint

packages/near-snap/src/lib/near-snap.ts Outdated Show resolved Hide resolved
packages/near-snap/README.md Outdated Show resolved Hide resolved
packages/near-snap/package.json Outdated Show resolved Hide resolved
packages/near-snap/src/lib/near-snap.ts Show resolved Hide resolved
packages/near-snap/src/lib/near-snap.ts Outdated Show resolved Hide resolved
packages/near-snap/src/lib/near-snap.ts Outdated Show resolved Hide resolved
packages/near-snap/src/lib/types.ts Outdated Show resolved Hide resolved
@AmmarHumackicSQA
Copy link
Contributor

Hey @irubido, any news on the status regarding the work on addressing the comments left by @kujtimprenkuSQA ?

Copy link
Contributor

@kujtimprenkuSQA kujtimprenkuSQA left a comment

Choose a reason for hiding this comment

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

Currently, Near Snap is blocking the execution of the Wallet Selector when setupNearSnap() is added to the array of modules in the setupWalletSelector() for this reason, we can not manually test the functionality.

To reproduce: remove node_modules and dist install, build, and run everything again.

TODO:

  • Address the comments.
  • Merge with the latest changes of the dev branch.
  • Make sure build, tests, and linting are working.
  • Request a review again.

packages/nearfi/src/lib/nearfi.ts Outdated Show resolved Hide resolved
packages/near-snap/package.json Show resolved Hide resolved
packages/near-snap/src/lib/near-snap.ts Show resolved Hide resolved
packages/near-snap/src/lib/types.ts Outdated Show resolved Hide resolved
packages/near-snap/src/lib/utils.ts Outdated Show resolved Hide resolved
packages/near-snap/src/lib/near-snap.ts Outdated Show resolved Hide resolved
@danforbes
Copy link

@kujtimprenkuSQA - are there any pending tasks related to this PR for the ChainSafe team?

@kujtimprenkuSQA
Copy link
Contributor

kujtimprenkuSQA commented Feb 14, 2023

Hey, @danforbes the PR looks good to me, there are no pending tasks for the ChainSafe/ Near Snap team.

@irubido
Copy link
Contributor

irubido commented Feb 17, 2023

Updated breaking changes for metamask flask v1.25 released today

@kujtimprenkuSQA
Copy link
Contributor

Updated breaking changes for metamask flask v1.25 released today

@irubido after this last update we're seeing an error when we try to signIn:

Screenshot 2023-02-20 155021

Version
10.25.0-flask.0

@BeroBurny
Copy link
Contributor Author

Updated breaking changes for metamask flask v1.25 released today

@irubido after this last update we're seeing an error when we try to signIn:

Screenshot 2023-02-20 155021

Version 10.25.0-flask.0

Can you tell me a version of snap installed on Flask? (should be 1.0.6)

You can find it under Account -> Settings -> Snaps -> Near Snap - See Details (buttons)
  1. image
  2. image
  3. image
  4. image

@kujtimprenkuSQA
Copy link
Contributor

Is there a "right" way to upgrade these snaps?

The way I did it was by removing the previous version and trying to connect with the new one, now it's working.

@kujtimprenkuSQA kujtimprenkuSQA merged commit 1fced9e into near:dev Feb 28, 2023
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.

6 participants