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

Fastauth metamask #773

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Open

Fastauth metamask #773

wants to merge 9 commits into from

Conversation

mattlockyer
Copy link
Contributor

@mattlockyer mattlockyer commented Apr 10, 2023

To start:

  • yarn && yarn build:fastauth-metamask && yarn serve:react
  • login and select MetaMask
  • follow prompts

Basic implementation of:

  • search mapping contract for existence of NEAR account for Ethereum Address
  • sign message with MetaMask to generate keyPair for new Account
  • new KeyPair stored in memory
  • signIn with wallet-selector
  • signOut with wallet-selector
  • verifyOwner
  • signAndSendTransaction(s)

TODO

  1. deploy mapping contract and verify if NEAR account exists for given Ethereum address
  2. create account (with MetaTransaction API) if no mapping found and add the Ethereum account and NEAR account to the mapping contract
  3. fix signIn flow so modal hides without error

@HarisSQA
Copy link
Collaborator

HarisSQA commented Apr 20, 2023

Hi @mattlockyer,

I'm having this issue to build it as it's shown in the repo. Also tried to fix these issues, but I'm assuming that this isn't finished. Some functions don't work, there is missing import and type, and some variables are not renamed from neth. Feel free to comment if I'm missing something.

image

@mattlockyer
Copy link
Contributor Author

Sorry for the build errors, yarn serve:react was working previously and I guess the dev server was less strict.

Copy link
Collaborator

@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.

The build passes locally but there are a few linting issues which prevent the gh-actions to pass, try running:

yarn nx run fastauth-metamask:lint

When I tried to sign in with MetaMask on the final step the account id is not showing properly on the alert popup, can you fix this:

account-id-alert

UPDATE: The [object Object] was showing because I had a near account in MetaMask via NETH after removing and installing meta mask again this popup is not showing but it still says "kujtimprenku.testnet" has not been founded but I have NEAR on this account.

packages/fastauth-metamask/package.json Outdated Show resolved Hide resolved
packages/fastauth-metamask/.gitignore Outdated Show resolved Hide resolved
packages/fastauth-metamask/README.md Outdated Show resolved Hide resolved
packages/fastauth-metamask/package.json Outdated Show resolved Hide resolved
packages/fastauth-metamask/src/lib/lib.tsx Outdated Show resolved Hide resolved
// chainId: 1, // aurora
chainId: 1313161554, // aurora
};
const MODAL_ELEMENT_ID = "near-wallet-selector-modal";
Copy link
Collaborator

Choose a reason for hiding this comment

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

This ID conflicts with the main modal https://github.com/near/wallet-selector/blob/main/packages/modal-ui/src/lib/modal.tsx#L12 how is this meant to be used?

Looks like this is the reason why the flow throws an error when signIn finishes and the modal hides.

packages/fastauth-metamask/yarn.lock Outdated Show resolved Hide resolved
@kujtimprenkuSQA
Copy link
Collaborator

kujtimprenkuSQA commented Apr 24, 2023

@mattlockyer I added this PR to help you fix the linting issues: NearDeFi#1, if this looks good you can go ahead and merge it and then address other outstanding comments in this PR.

To spot these linting issues you might need to configure your IDE and then most of them would "automatically" be fixed on save.

https://github.com/near/wallet-selector#editor-setup


let res;
try {
res = await (account as any).signAndSendTransactions({
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does the signAndSendTransactions exist in the Account class?
https://github.com/near/near-api-js/blob/master/packages/accounts/src/account.ts

@mattlockyer
Copy link
Contributor Author

Thanks for the help. Ideally someone from Pagoda who understands more about how they plan to use the keys generated by MetaMask takes the lead on this PR. I'm still in the dark as to how accounts will be created and where keys will be stored once those accounts are created.

Appreciate the PR @kujtimprenkuSQA

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

3 participants