-
Notifications
You must be signed in to change notification settings - Fork 244
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
Multi contract keystore #1163
Multi contract keystore #1163
Conversation
|
hey @amirsaran3 |
@andy-haynes This PR looks good, we'll just add a "getContracts" method and tests and move all changes to a separate PR. What do you think? |
Overall I’m not convinced this is a good fit for the repo. I saw the linked First and foremost, it doubles down on the usage of plaintext key storage. This is not a practice we should endorse by providing new functionality for it. There are more secure approaches to key storage supported by major browsers, so we would need a pretty compelling reason to continue to support this approach. Secondly, I don’t think it’s a good idea from an architectural perspective. It adds a new keystore abstract class just to modify the arity on some of the methods and support this specific implementation, which is largely duplicated from the current localstorage keystore. If this implementation exists solely to associate sets of accounts with a contract, it could be implemented in Wallet Selector as a one-off by mapping contracts to localstorage keystores instead of extending the keystore behavior, e.g. class LocalStorageMultiContractKeyStore {
contracts: { [contractId: string]: BrowserLocalStorageKeyStore } = [];
...
setContractKeys(network: string, accountId: string, permissions: AccessKeyPermission[]) {
for (let permission of permissions) {
if (!this.contracts[permission.receiverId]) {
this.contracts[permission.receiverId] = new BrowserLocalStorageKeyStore(localStorage, permission.receiverId);
}
this.contracts[permission.receiverId].setKey(network, accountId);
}
}
...
} |
Hey @andy-haynes, thank you for the feedback! This change will not be used directly in the wallet-selector, instead it should be applied by the wallets supported by the wallet-selector. |
Thanks for the clarification and context @gtsonevv! After thinking about this some more, I see two big impediments in the current implementation to supporting
If we had a keystore capable of storing an arbitrary number of keys per account and had awareness of access key types, it would be trivial to implement Do you think something like that could be a viable option for the original use case? Given the upcoming work, it's probably worth looking more critically at our keystore interfaces. |
Hey @andy-haynes, your suggestion sounds reasonable but it would require a general refactoring of the existing classes and would delay the release of this feature a lot I think. It will also introduce breaking changes that all wallets must adapt to. This can be added as an important thing to do in the future. |
@gtsonevv fair enough.
If this is the entirety of the changes (e.g. we're not changing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merging into feature branch to retain history
17c9531
into
near:feat/multi-contract-keystore-original
Pre-flight checklist
pnpm changeset
to create achangeset
JSON document appropriate for this change.Motivation
Test Plan
Related issues/PRs