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

Change wallet #109

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Change wallet #109

wants to merge 13 commits into from

Conversation

wirednkod
Copy link
Member

@wirednkod wirednkod commented Sep 8, 2024

closes #107
fixes #76

Submission checklist:

Layout

  • Remove DotConnect
  • Add Polkadot UI Connect Functionality

@wirednkod wirednkod requested a review from Tbaut as a code owner September 8, 2024 12:51
@wirednkod wirednkod marked this pull request as draft September 8, 2024 12:51
Copy link

cloudflare-workers-and-pages bot commented Sep 8, 2024

Deploying delegit with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8a4c08b
Status: ✅  Deploy successful!
Preview URL: https://49b38c65.delegit.pages.dev
Branch Preview URL: https://nik-change-wallet.delegit.pages.dev

View logs

@Tbaut
Copy link
Contributor

Tbaut commented Sep 8, 2024

Thanks a lot, it's looking super promising, I'll check the code a little later, just as I tried the functionality and not the code, there's something weird that happens when you selected an account, then you still see the "Connect" button rather than the accounts. Is that expected?

selection.mp4

Also unfortunately, although it's not the highest importance, this is not compatible with mobile view (it'd need 2 different panels , with navigation like on the hydra example), and the selected/hover state in dark view are hard to read.
image

image

@wirednkod
Copy link
Member Author

wirednkod commented Sep 8, 2024

Thanks a lot, it's looking super promising, I'll check the code a little later, just as I tried the functionality and not the code, there's something weird that happens when you selected an account, then you still see the "Connect" button rather than the accounts. Is that expected?

Thank you for the feedback. There are still some edge cases (and some non edge ones) that im still fixing, making it more DX. The most important is that i have now multiple views available that can be dedicated per device.
I changed it to draft as I know why the connect is not working and some other alternations.
Im glad i figured out some major problems and i can solve them without the use of any state manager dependencies.

Also most of the design elements can be parameterized by the config so design wise that will be super easy to fix

@wirednkod wirednkod marked this pull request as ready for review September 14, 2024 18:09
Copy link
Contributor

@Tbaut Tbaut left a comment

Choose a reason for hiding this comment

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

Sorry in advance for the amount of comments, I'm fresh and have many questions.
As a dev, I really just want to get the accounts, selectAccount, selectedAccount. If there's any localstorage, I should take care of this, just like we did with Tien's modal.

Finally I couldn't actually play with it as I got the following error

 SyntaxError: The requested module 'http://localhost:5173/node_modules/.vite/deps/@polkadot-ui_react.js?v=a9b536dc' doesn't provide an export named: 'useAccountLocalStorage'

src/App.tsx Outdated Show resolved Hide resolved
src/components/MyDelegations.tsx Show resolved Hide resolved
src/components/ui/dialog.tsx Outdated Show resolved Hide resolved
}

const AccountContext = createContext<IAccountContext | undefined>(undefined)

const AccountContextProvider = ({ children }: AccountContextProps) => {
const accounts = useRedotAccounts()
const [localStorageAccount, setLocalStorageAccount] = useAccountLocalStorage()
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a weird DX that I've never seen before. I don't understand why we'd need it.

Copy link
Member Author

Choose a reason for hiding this comment

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

For the wallet the localstorage has a specific key. This hook is allowing you to get/set that key without the need to know the key

Copy link
Contributor

Choose a reason for hiding this comment

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

do I really need this though, as a dev? I'm still not sure.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure what you mean "as a dev"... how will you setup the localstorage?

Copy link
Contributor

Choose a reason for hiding this comment

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

Look at Tien's interface for the dot-connect, there's no mention of local storage ever. If we do anything with local storage, it's on our side. This useAccountLocalStorage comes form polkadot-ui and I don't get why. I think these things should be hidden if needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Noted!

src/contexts/AccountsContext.tsx Outdated Show resolved Hide resolved
src/header.tsx Show resolved Hide resolved
type="extensions"
config={connectConfig}
selected={selectedAccount}
setSelected={selectAccount}
Copy link
Contributor

Choose a reason for hiding this comment

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

the naming setSelected and selectAccount looks weird here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you.. Opened polkadot-ui/library#356 and will fix in next version of the library release.

src/header.tsx Outdated Show resolved Hide resolved
src/header.tsx Outdated Show resolved Hide resolved
src/header.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@Tbaut Tbaut left a comment

Choose a reason for hiding this comment

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

Sorry I messed up yesterday and hadn't installed de deps, I did play with it in the end. Functionality looks good, just the implementation feel non intuitive, with things I wouldn't expect us to have to deal with, see my previous comments.

src/header.tsx Outdated Show resolved Hide resolved
@wirednkod
Copy link
Member Author

@Tbaut I have no idea why the build and lint are failing here 🤷🏽

@Tbaut
Copy link
Contributor

Tbaut commented Sep 17, 2024

The NodeJS server is extremely slow and the CI doesn't manage to download it in time, I guess it'll be better when we retry later. I relaunched it, and tried myself, but it's simply super slow, takes 5+min and times out.

Copy link
Contributor

@Tbaut Tbaut left a comment

Choose a reason for hiding this comment

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

There are stuff I just don't see why they are here. Maybe it's just me, but without any background, it's just confusing and will make the maintenance harder:

  • I don't want any local storage handling from the lib. we care about the last selected account 100%, or the lib cares about it 100%. this mix that we have here isn't clear
  • same for the accounts. I see a setAccounts passed in the ConnectModal. I don't think this is right. I should just get them e.g with const {accounts} = useConnect() and not have to care about the state. we never use it, so it shouldn't be exposed.
  • similarly, I'm not sure why we need to pass selected and setSelected accounts. The modal doesn't do anything with them.

src/header.tsx Outdated Show resolved Hide resolved
src/header.tsx Show resolved Hide resolved
src/components/MyDelegations.tsx Show resolved Hide resolved
Co-authored-by: Thibaut Sardan <[email protected]>
@wirednkod
Copy link
Member Author

  • same for the accounts. I see a setAccounts passed in the ConnectModal. I don't think this is right. I should just get them e.g with const {accounts} = useConnect() and not have to care about the state. we never use it, so it shouldn't be exposed.

Modal has different forms ("type") and some of them handle the accounts. But you are right that in the current state (only extensions) it does not. Will adjust accordingly

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.

Replace DOTconnect with Polkadot UI connect Fix polkadot-ui unmet peer polkadot-api warning
2 participants