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/fresh web wallet #172

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

yogh333
Copy link

@yogh333 yogh333 commented Mar 17, 2023

Hello,

This is a tentative/proposal to integrate support of web wallets in get-starknet. This PR includes modifications in both core and ui packages, as well as in example Dapp. It also provides a sample web wallet (web_wallet_mock) with WebauthN support. To test Dapp <-> Web wallet connection,

  1. Launch web wallet (pnpm dev in web_wallet_mock folder)
  2. Create a fake account by entering an user name and click Register
  3. Test if account is properly set by entering the same user id and click Authenticate
  4. Launch Dapp (pnpm dev in example folder)
  5. Login to web wallet by entering the registered user name
  6. Interact with web wallet

However, I think that GetStarknetResult interface needs to be reviewed/refactored to properly abstract Web wallet as well as Extension wallet: getAvailableWallets, getDiscoveryWallets, getWebWallet introduce some kind of redundancy and confusion IMO. Thus, I am not fully satisfied the way I have integrate web wallet support even if it can make the job nowadays. I am willing to discuss/exchange, if you have any proposal.

Thanks,

@yogh333
Copy link
Author

yogh333 commented Mar 17, 2023

Hello,

Here is a proposal for a new GetStarknetResultv2 interface

interface GetStarknetResultv2 {

  // Return all wallets available in the window object
  getInjectedWallets: (options?: GetWalletOptions) => Promise<StarknetWindowObject[]>
  // Return all available web wallets
  getWebWallets: (options?: GetWalletOptions) => Promise<WebWalletProvider[]>
  // Return all available extension wallets
  getExtensionWallets: (options?: GetWalletOptions) => Promise<ExtWalletProvider[]>
  // Open a web wallet and get StarknetWindowObject
  openWebWallet: (wp: WebWalletProvider) => Promise<StarknetWindowObject>
  // Connect StarknetWindowObject
  connect: (wallet: StarknetWindowObject) => Promise<ConnectedStarknetWindowObject>
  disconnect: (options?: DisconnectOptions) => Promise<void> // Disconnects from a wallet
  // Those two functions shall handle extension wallets and web wallets differently as for a
  // web wallet, a connection shall be set in order to call isPreauthorized() function 
  getPreAuthorizedWallets: (options?: GetWalletOptions,) => Promise<StarknetWindowObject[]>
  getLastConnectedWallet: () => Promise<StarknetWindowObject | null | undefined> 

}

interface WalletProvider = {
  id: string,
  name: string,
  icon: string
}

interface ExtWalletProvider extends WalletProvider = {
  downloads:
    | { chrome?: `https://chrome.google.com/webstore/detail/${string}` }
    | { firefox?: `https://addons.mozilla.org/en-US/firefox/addon/${string}` }
    | { edge?: `https://microsoftedge.microsoft.com/addons/detail/${string}` }
}

interface WebWalletProvider extends WalletProvider = {
  urls: string[]
}

@avimak
Copy link
Collaborator

avimak commented Mar 29, 2023

tnx @yogh333 ! does this PR represent a WIP proposal ?

@yogh333
Copy link
Author

yogh333 commented Mar 29, 2023

Yes this is a WIP but I would like to get feedback from others get-starknet contributors as it introduces heavy modifications. In the meantime, this branch will be used in our current development @ledger for our upcoming Fresh project (WebAuthn based Web Wallet for Starknet).

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.

3 participants