sips icon indicating copy to clipboard operation
sips copied to clipboard

SIP: Modern Wallet APIs

Open janniks opened this issue 5 months ago β€’ 19 comments

  • Adds SIP for more modern standard for wallet API RPC (usable for browser-extensions as well as other settings)

Will remain a draft while Xverse, Leather, and other are asked to contribute

janniks avatar Jan 12 '24 16:01 janniks

Great work @janniks. Leather supports this SIP πŸ–€

kyranjamie avatar Jan 30 '24 14:01 kyranjamie

Thanks for the input @m-aboelenein @kyranjamie . I updated the stuff we chatted about on the call, and also added some OPEN QUESTIONS to the top.

Do you think you could do another review with final remarks until ~Tue. 20.02.2024 to wrap this up with bipartisan support? πŸ™

janniks avatar Feb 14 '24 19:02 janniks

Added methods getAddresses and getAccounts for better compatibility with current solution.

janniks avatar Feb 15 '24 22:02 janniks

@aryzing @kyranjamie I added an update to the encoding (as discussed on last weeks call). Let me know what you think! This can be used as the canonical repr and Stacks.js would also migrate towards it. (Serialized hex encoded string could also still be used (easy to tell apart).

Also updated:

  • renamed functionName to name, functionArgs to arguments
  • merged contractName + contractAddress to contract -- which is a ${string}.${string} (how it's copy pasted from the explorer)
  • renamed some other params (see 425f81ca2aacab06f92c84b8a88023a94a2a6b82 for details)

Ping me if you disagree with anything -- trying to make the naming more logical and short

janniks avatar Feb 29 '24 14:02 janniks

CC @pradel would also love to get your feedback on this updated approach to "Connect"/auth -- it's less convoluted, but also more explicit (might need multiple steps for some things, that were just magically done in auth previously , e.g. requesting a gaia token would be it's own step, (although wallets could also add it to something like getAddresses / getAccounts)

janniks avatar Feb 29 '24 14:02 janniks

@janniks I like this change, less magic on what's going on and the behavior seems to be pretty similar to how ETH is doing things, making it easier for ETH devs to use the API

pradel avatar Mar 01 '24 10:03 pradel

CC @friedger would also love to get some of your feedback+expertise, since you've worked on this area in the past πŸ™

janniks avatar Mar 05 '24 12:03 janniks

Also, Thanks for all the feedback everyone! πŸ‘

I feel like we're nearing a good document here. I think we can wrap it up soon 🫑

janniks avatar Mar 05 '24 12:03 janniks

Let me know which email-addresses/github-usernames to add to the author list. cc @kyranjamie @m-aboelenein @aryzing

janniks avatar Mar 05 '24 12:03 janniks

@janniks [email protected] & @kyranjamie

kyranjamie avatar Mar 05 '24 12:03 kyranjamie

Let me know which email-addresses/github-usernames to add to the author list

Aren't all the commits yours? :joy: I wasn't even thinking about making it to the author list, not sure I've contributed enough, up to you :shrug:

aryzing avatar Mar 05 '24 14:03 aryzing

I’ll consider anybody an author/editor that contributed in some say πŸ˜‰ so lmk. Honestly I don’t need the section, but probably even changeable later

janniks avatar Mar 05 '24 14:03 janniks

Sure, why not :) link to my github, @aryzing , thanks :pray:

aryzing avatar Mar 06 '24 19:03 aryzing

@janniks does this modern wallet API, include API's that would help the wallet/dapp know if there is a difference between the network and/or account between what is active on the extension and what is signed in with on the dapp? Say you are on account 1 in the dapp and your Leather is active on account 2. In Metamask you would get a warning (do you want to switch to account 2?) or something like that. I have a feeling that could help prevent some issues where users are confused about which account is signing.

A. Account switching, There may be other relevant issues, but this is a recent one that came to my mind https://github.com/leather-wallet/extension/issues/4859 As part of that, this one is probably harder/impossible? (detect when different secret key is used) https://github.com/leather-wallet/extension/issues/3006

Similar with different networks being used. Especially relevant when users are on testnet and forget to switch back to mainnet... the experience is currently confusing for users. This issue pops up every time there is a popular public testnet.

I think we'll see similar issues once subnets and other layered approaches become popular which require users to install/add networks much like Metamask does for L2 on Ethereum. B. Network: https://github.com/leather-wallet/extension/issues/4194 (changing network, adding network, dapp to prompt switch or addition)

314159265359879 avatar Mar 11 '24 15:03 314159265359879

@janniks @m-aboelenein & [email protected]

m-aboelenein avatar Mar 11 '24 19:03 m-aboelenein

Exciting update! I am thrilled to share that we now have a beta version of sats-connect that implements the SIP check the docs for details. https://docs.xverse.app/sats-connect-wallet-api-for-bitcoin-and-stacks-1 Very excited to hear your thoughts and feedback πŸ™Œ

m-aboelenein avatar Mar 11 '24 19:03 m-aboelenein

does this modern wallet API, include API's that would help the wallet/dapp know if there is a difference between the network and/or account between what is active on the extension and what is signed in with on the dapp?

Doesn't this imply that the account management strategy / state management strategy of wallets would leak into the spec? Seems that the concept of an "active" account is just a way for some wallets to organize or handle what data they keep in memory or present to the user. A "comprehensive" wallet could present all accounts & balances simultaneously to the user (even from both mainnet & testnet).

Would it make sense to include the address & network as part of the request? After all, if the result of the operations in this SIP are a function of the network and address, should those not be included in the requests too?

If included, the "comprehensive" wallet described above (that has no concept of an "active" account) would know exactly what to do too. For wallets segregating state based on the "active" account abstraction, they'd have a clear way of checking whether address / network match the currently "active" ones and act as seen fit.

aryzing avatar Mar 11 '24 21:03 aryzing

There was similar ideas to https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md#chainchanged-1 -- we haven't scoped them onto this SIP yet, but we can add it.

janniks avatar Mar 13 '24 14:03 janniks

There was similar ideas to https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md#chainchanged-1 -- we haven't scoped them onto this SIP yet, but we can add it.

address and network as part of the request, I would love to see that scoped in. @aryzing thanks for that explanation I do believe that is a valuable addition to this sip to help deal with the issues I mentioned with the wallet.

314159265359879 avatar Mar 27 '24 19:03 314159265359879