-
Notifications
You must be signed in to change notification settings - Fork 463
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
Conversation
Branch preview✅ Deploy successful! https://seedless_addressbook--walletweb.review-wallet-web.5afe.dev |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
Coverage report
Show files with reduced coverage 🔻
Test suite run success991 tests passing in 140 suites. Report generated by 🧪jest coverage report action from 057b67d |
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.
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() |
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.
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) |
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.
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)
What it solves
Adds the mpc signer address into the addressbook after login.
How to test it
Checklist