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

[Research] Multiple contract support #403

Closed
austinabell opened this issue Aug 16, 2022 · 5 comments
Closed

[Research] Multiple contract support #403

austinabell opened this issue Aug 16, 2022 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@austinabell
Copy link

austinabell commented Aug 16, 2022

Is your feature request related to a problem? Please describe.

Currently, the wallet selector modal APIs do not allow for managing function call access keys. APIs might have to change in the wallet selector core APIs as well to be able to check if there is an access key for the given contract, or just to ensure they are signed into an injected wallet.

The reason this is useful/necessary is if someone wanted to interact with multiple contracts within the same frontend, they would need to sign in and generate a function call access key for each time they interact with a new contract (using a hosted wallet).

This is a problem because not only is it a bad UX, but also it charges unnecessary gas by throwing away usable function call access keys. The pattern of interact with contract A -> interact with contract B -> interact with contract A requires that you generate two function call access keys for interacting with contract A when you should only need one.

The assumption based on how the code is set up is that there is a 1:1 mapping of wallet -> contract, which is very invalid.

Describe the solution you'd like

  • Keep contractId mandatory and expose a method to switch the contract, like updateContractId as a callback (along with hide and show)
    • Alternatively: Modal show method takes a contractId parameter (optional) and make the contractId parameter of ModalOptions optional as well. Assumption is error would be thrown if neither is used. This might be able to be restricted based on TS type system (in theory it should be able to be) so that either is required.
  • Assumption that wallets maintain contract id -> access key mappings, if not, adjust the selector core APIs to convey the switch in account or expose the generated access keys from the selector. (unclear the semantics around requestSignIn , is the implication that it will force another sign in, or if it's already signed in for the account it will short-circuit?)

Describe alternatives you've considered

Acceptance criteria Allow interacting with multiple contracts with a single wallet selector

Additional context Motivation is for building a frontend that interacts with contracts dynamically at runtime.

@austinabell austinabell added the enhancement New feature or request label Aug 16, 2022
@austinabell austinabell changed the title Enable passing in contractId in modal show Multiple contract support Aug 16, 2022
@amirsaran3
Copy link
Collaborator

@austinabell This currently is not possible to add because wallets like MyNearWallet only allow you to one add access key to one contract when signing in. This will need to first be addressed on the wallet side and/or to update the near-api-js library.

Right now we call the sign in function like this: wallet.requestSignIn({ contractId, methodNames }).
Maybe we can have something like this: wallet.requestSignIn([{ contractId, methodNames }, { contractId, methodNames }]); which will allow us to add multiple access keys with one approve/sign in.

Example of adding full access key to guest-book.testnet when signing in:
image

In explorer you can see that we only create a full access key for guest-book.testnet.
image

This looks like a big change, I am not completely sure about how to approach this. Maybe @MaximusHaximus can comment more on this.

@exalate-issue-sync exalate-issue-sync bot changed the title Multiple contract support [Research] Multiple contract support Oct 4, 2022
@exalate-issue-sync exalate-issue-sync bot reopened this Oct 11, 2022
@amirsaran3
Copy link
Collaborator

Currently with MyNearWallet there is no way to generate multiple function call access keys for different contracts with one sign in. This is the limitation of some wallets that is preventing us to continue with this task.

The new Injected Wallet NEP suggests to use only one or more contract id when signing in. This will allow us to use multiple contracts.

After we align the wallet standards to be like Injected Wallets then we can integrate this feature.

@exalate-issue-sync
Copy link

exalate-issue-sync bot commented Nov 14, 2022

Ammar Humackic commented:

Daryl Collins will make sure Injected Wallet NEP and Bridge Wallet NEP have this added.

@bmeeder22
Copy link

+1

@AmmarHumackicSQA
Copy link
Collaborator

Closing this as it will be covered by the work in: #811

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

No branches or pull requests

5 participants