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

[Seedless-Onboarding] Add signer account to address book on login #2672

Merged
merged 2 commits into from
Oct 23, 2023

Conversation

schmanu
Copy link
Member

@schmanu schmanu commented Oct 20, 2023

What it solves

Adds the mpc signer address into the addressbook after login.

How to test it

  1. If the google signer address is in the addressbook, delete it.
  2. Re-Login with google
  3. Observe that the resolved address is added to the addressbook.

Checklist

  • I've tested the branch on mobile 📱
  • I've documented how it affects the analytics (if at all) 📊
  • I've written a unit/e2e test for it (if applicable) 🧑‍💻

@github-actions
Copy link

github-actions bot commented Oct 20, 2023

Branch preview

✅ Deploy successful!

https://seedless_addressbook--walletweb.review-wallet-web.5afe.dev

@schmanu schmanu requested a review from usame-algan October 20, 2023 11:16
@github-actions
Copy link

github-actions bot commented Oct 20, 2023

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@github-actions
Copy link

github-actions bot commented Oct 20, 2023

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
74.7% (+0.3% 🔼)
9307/12460
🔴 Branches
48.84% (+0.37% 🔼)
1871/3831
🔴 Functions
56.49% (+0.23% 🔼)
1366/2418
🟡 Lines
76.24% (+0.29% 🔼)
8412/11033
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟡
... / module.ts
70% (-2.09% 🔻)
50%
75% (-1.92% 🔻)
66.67% (-1.75% 🔻)
🟢
... / MPCLogin.tsx
93.33% (-0.14% 🔻)
90.91% 88.89%
93.02% (-0.16% 🔻)

Test suite run success

991 tests passing in 140 suites.

Report generated by 🧪jest coverage report action from 057b67d

Copy link
Member

@usame-algan usame-algan left a comment

Choose a reason for hiding this comment

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

Works nicely 👍

I was also exploring moving the logic into useWallet or a similar place where we listen to connected wallets but in that case we are missing the email address and would have to add that dependency. Also useWallet has a lot of instances which would mess with inserting an address book entry. We might want to convert it into a global context at some point.

@@ -30,6 +35,9 @@ export const useMPCWallet = (): MPCWalletHook => {
const [walletState, setWalletState] = useState(MPCWalletState.NOT_INITIALIZED)
const mpcCoreKit = useMPC()
const onboard = useOnboard()
const addressBook = useAddressBook()
const currentChainId = useCurrentChain()
Copy link
Member

Choose a reason for hiding this comment

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

We can use useChainId directly here as we only need the chain id


// If the signer is not in the address book => add it as the user's first name
if (wallets && currentChainId && wallets.length > 0) {
const signerAddress = ethers.utils.getAddress(wallets[0].accounts[0]?.address)
Copy link
Member

Choose a reason for hiding this comment

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

getAddress throws an error if we pass undefined. Not sure why the types don't reflect it but I think we need to split up the call. We could also reuse our checksumAddress wdyt?

const address = wallets[0].accounts[0]?.address
if (!address) return
const checksummedAddress = checksumAddress(address)

@schmanu schmanu merged commit f31099b into web3authcoresdk Oct 23, 2023
7 of 8 checks passed
@schmanu schmanu deleted the seedless-addressbook branch October 23, 2023 09:32
@github-actions github-actions bot locked and limited conversation to collaborators Oct 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants