-
-
Notifications
You must be signed in to change notification settings - Fork 242
feat(accounts-controller): add new typed options for InternalAccount
s
#6147
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
Conversation
9d952f6
to
254e0a5
Compare
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
// If for some reason, we cannot find this address, then the caller made a mistake | ||
// and it did not use the proper keyring object. For now, we do not fail and just | ||
// consider this account as "simple account". |
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.
undefined
would be equivalent to a simple account? That doesn't seem correct.
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.
The other option would be to throw here. But that could be really risky and could brick wallets if not handled I guess 🤔
Also, this should NEVER happen, truly 😅 but I need to handle the error case.
Do you have anything else in mind for this case?
} else { | ||
keyringTypes.set(keyringTypeName, 1); | ||
keyringAccountIndexes.set(keyringTypeName, 1); | ||
} |
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.
Don't we start at 0 index?
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.
Well, for "account naming" we do start at 1 (and I just re-used the previous logic, I just renamed the variables to make it more clear.
That being said, with the current logic, the keyringAccountIndexes
will always be 1 and I think the if
is not necessary actually, because:
const keyringAccountIndex = 0;
keyringAccountIndexes.set(keyringTypeName, keyringAccountIndex + 1);
// Would set `keyringAccountIndexes` to 1.
const keyringAccountIndex = 0;
if (keyringAccountIndex) {
keyringTypes.set(keyringTypeName, keyringAccountIndex + 1);
} else {
// This branch will get executed.
keyringTypes.set(keyringTypeName, 1);
// Would set `keyringAccountIndexes` to 1.
}
So they do seem similar.
Lastly, we mostly use those indexes to compute the account name, but I do believe we never end up using this one, cause we ALWAYS set a name when creating an account 🤔 So this fallback is probably never executed and probably buggy too 🙃
I'll try to fix it still.
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.
Maybe we can add a deprecation notice to the name property in the internal account. The account name will come from the account group.
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.
Maybe we can add a deprecation notice to the name property in the internal account. The account name will come from the account group.
Sounds like a good idea, but IMO we should do that once we truly introduce account group naming!
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
Note: Simple private key accounts and hardware wallets do not have their accounts options automatically populated. It is not needed for state 2, and will be addressed in a subsequent PR. |
Explanation
Properly populate entropy options for EVM accounts and also add new typed options for every
InternalAccount
s.Test PR:
References
N/A
Changelog
N/A
Checklist