-
Notifications
You must be signed in to change notification settings - Fork 9
feat: snap birthday block form on install #67
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
Conversation
import { Form, Box, Heading, Input, Button, Text } from "@metamask/snaps-sdk/jsx"; | ||
|
||
type BirthdayBlockForm = {customBirthdayBlock: number | null} |
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.
Please reformat files with prettier
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.
Lint is currently broken across the snap and web-wallet, will address fixing linter to @chainsafe/eslint-config in separate issue
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.
@irubido prettier should also be configured with your IDE, to reference the .prettierrc file. I wouldn't rely on @chainsafe/eslint-config as it's pretty outdated. But we can indeed force to to follow prettier styles with eslint
</Text> | ||
<Input min={0} step={1} type='number' name="customBirthdayBlock" placeholder='optional syncing block height' /> | ||
</Box> | ||
<Button type='submit' name="next">Next</Button> |
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.
Should be "submit" button text
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.
Submit kind of implies that something should be submitted, and it is optional. Maybe, Continue to wallet
would be better?
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.
"Continue to wallet" sounds good
<Form name="birthday-block-form"> | ||
<Box> | ||
<Heading>Optional syncing block height</Heading> | ||
<Text> |
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.
It would also be nice to give a user a hint about the current block height as a reference point.
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.
Guess I would need "endowment:network-access" and some API providing current block of the chain. Or did I miss some method in wasm returning latest block without initialized wallet?
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.
you can pass it from front-end when calling setBirthdayBlock()
packages/web-wallet/src/App.tsx
Outdated
@@ -19,7 +20,7 @@ function App() { | |||
}, [location.pathname]); | |||
|
|||
useInterval(() => { | |||
triggerRescan(); | |||
if(installedSnap) triggerRescan(); |
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.
You can put this logic directly inside triggerRescan method as we have an access to the state
@@ -83,10 +83,11 @@ export function useWebZjsActions(): WebzjsActions { | |||
|
|||
const addNewAccountFromUfvk = useCallback( | |||
async (ufvk: string, birthdayHeight: number) => { | |||
if(state.webWallet === null) {dispatch({ type: 'set-error', payload: new Error('Wallet not initialized') }); return;} |
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.
reformat with prettier please
}, [installedSnap, navigate]); | ||
if (installedSnap) { | ||
const homeReload = async () => { | ||
const accountData = await getAccountData(); |
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.
Shouldn't we get Account data only on the Receive page?
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.
I replaced unifiedAddress instead installedSnap as a flag that allows /dashboard/account-summary
.
Maybe checking wallet summary is better for this case
Closes #63
Adds snaps Interactive UI Form input as option to set birthday block from which web wallet starts sync.
Dapp redirects to account-summary once wallet was created.
I also tried with new
OnInstallHandler
and storing form data to state, but it does not happen first thing onInstall and does not stop the all other rpcs called.