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

✨ feat: Add keplr wallet support and shared utils package #1147

Closed
wants to merge 60 commits into from

Conversation

Seroxdesign
Copy link

@Seroxdesign Seroxdesign commented Jun 12, 2024

Motivation and context

We want to support keplr wallet and the cosmos ecosystem, as well as Phantom to support the Solana ecosystem. Additionally we want to set a standard for multi-wallet cache support

Does it fix any issue?

  • Allows us to use multiple wallets with cache
  • Adds Keplr/cosmos support

Other useful info

  • I removed test/unit from wallets since we removed the duplicate prepareExtension wallet solely in sypress-cache and all the units are already tested in cache
  • Modified CLI to take a flag to decide on a wallet to use for cache
  • Added over all the necessary functions/pages/and tests to use as a base for keplr
  • Added 2 setup functions in keplr (Note: the cache library needs 2 setup files to work properly, consistently and produce the correct hash in cache and wallet)

Quality checklist

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough e2e tests.

⚠️👆 Delete any section you see irrelevant before submitting the pull request 👆⚠️

@Seroxdesign Seroxdesign added the enhancement New feature or request label Jun 12, 2024
@Seroxdesign Seroxdesign self-assigned this Jun 12, 2024
Copy link

vercel bot commented Jun 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
synpress ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 5, 2024 0:39am

@Seroxdesign
Copy link
Author

Things to change:

  • Change the randomly generated ClassNames to somethings more stable
  • Maybe select all elements of a certain type and filter through them
  • Priority should be for text, or xpath, IDs, or test-ids

"extends": "./tsconfig.build.json",
"compilerOptions": {
"rootDir": ".",
"exactOptionalPropertyTypes": false, // Allows for `undefined` in `playwright.config.ts`
"types": ["cypress"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

we will need that :)

let extensionNames = extensionsToSetup()

if (!extensionNames.length) {
extensionNames = ['Keplr']
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't we use MetaMask as default?

@@ -1,6 +1,6 @@
import path from 'node:path'
import fs from 'fs-extra'
import { CACHE_DIR_NAME } from './constants'
import { CACHE_DIR_NAME } from '../../cache/src/constants'
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we do "./ensureCacheDirExists"?

export * from './downloadFile'
export * from './unzipArchive'
export * from '../../cache/src/unzipArchive'
Copy link
Collaborator

Choose a reason for hiding this comment

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

why isn't it in the same "cache" directory?

@@ -1,6 +1,7 @@
import { getUniqueWalletSetupFunctions } from './utils/getUniqueWalletSetupFunctions'
import { triggerCacheCreation } from './utils/triggerCacheCreation'

//@TODO: Make it so createCache can handle only one wallet setup function
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you elaborate?

Copy link
Author

@Seroxdesign Seroxdesign Jul 3, 2024

Choose a reason for hiding this comment

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

For some reason when we only have 1 setup file, the hash generated in prepareExtension creates what would have been the the hash from the second item in the wallet setup functions array.

If there's 2 or more setup functions this behaviour does not happen (this is true for MM as well even before adding Keplr)

This will be tackled in a separate issue

await notificationPage.waitForLoadState('domcontentloaded')
await notificationPage.waitForSelector(notificationPageElements.approveButton)
await notificationPage.click(notificationPageElements.approveButton)
return true
Copy link
Collaborator

Choose a reason for hiding this comment

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

why?

@@ -0,0 +1,10 @@
export const homePageElements = {
tokenNameLabel: (tokenName: string) => `:text-is("${tokenName}")`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
tokenNameLabel: (tokenName: string) => `:text-is("${tokenName}")`,
getTokenNameLabel: (tokenName: string) => `:text-is("${tokenName}")`,

newTokensFound: 'new token(s) found',
addChainsButton: 'Add Chains',
newTokensFoundSelector: 'text=new token(s) found',
walletSelectors: (chainName: string) => `img[alt="${chainName}"]`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

selectors? isn't it only one?

},

page: async ({ page }, use) => {
await page.goto('https://wallet.keplr.app/')
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not to use default page?

@Seroxdesign
Copy link
Author

NOTE:

We need to update synpress npm packages and versioning in package.json before we merge this

@Seroxdesign Seroxdesign marked this pull request as draft July 4, 2024 10:51
@Seroxdesign Seroxdesign changed the title ✨ feat: Add keplr wallet support and shared utils package ✨ feat: Add Keplr and Phantom support Jul 4, 2024
@Seroxdesign Seroxdesign changed the title ✨ feat: Add Keplr and Phantom support ✨ feat: Add keplr and phantom support Jul 4, 2024
@Seroxdesign Seroxdesign changed the title ✨ feat: Add keplr and phantom support ✨ feat: Add keplr wallet support Jul 4, 2024
@Seroxdesign Seroxdesign changed the title ✨ feat: Add keplr wallet support ✨ feat: Add keplr wallet support and shared utils package Jul 4, 2024
@Seroxdesign Seroxdesign changed the base branch from new-dawn to new-dawn-dev July 9, 2024 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants