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

Add serialization to the account classes #571

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

heliuchuan
Copy link
Contributor

@heliuchuan heliuchuan commented Nov 10, 2024

Description

This adds serialization to all the account classes. Clients that use Keyless will want to support the ability to add backup keys or turn the account into a multikey. This allows clients to cache the account agnostic of the actual signing method impl underneath. i.e., caching a MultiKeyAccount and KeylessAccount can work the same and use Account.deserialize

Test Plan

Added unit tests

Checklist

  • Have you ran pnpm fmt?
  • Have you updated the CHANGELOG.md?

@heliuchuan heliuchuan requested a review from a team as a code owner November 10, 2024 06:16
Copy link
Contributor

@GhostWalker562 GhostWalker562 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two comment but everything else looks good

Comment on lines +9 to +11
export interface DeserializableAccount<T> extends Deserializable<T> {
fromHex(hex: HexInput): T;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to only be used in one test. Define it in the test file instead since this interface won't be that useful if it's not being inherited

const anyKeyVariantOffset = deserializer.getOffset();
deserializer.reset(offset);
switch (anyKeyVariant) {
case AnyPublicKeyVariant.Keyless:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better if we can look into refactoring the accounts so that Keyless and Federated are SingleKeyAccount's and SingleKeyAccount can deserialize for the other two.

Since you added SingleKeySigner, maybe we can add the deserialization logic there and call that instead. This would be useful in the case that SingleKey's can also be used in new accounts (if ever)

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.

2 participants