-
Notifications
You must be signed in to change notification settings - Fork 573
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
feat(ironfish,rust-nodejs): Add EncryptedAccount class #5226
feat(ironfish,rust-nodejs): Add EncryptedAccount class #5226
Conversation
serialize(value: AccountValue): Buffer { | ||
export type AccountValue = EncryptedAccountValue | DecryptedAccountValue | ||
|
||
export class AccountValueEncoding implements IDatabaseEncoding<DecryptedAccountValue> { |
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.
This is a temporary change to update the generic and will be changed back to AccountValue
(the new union type) in a subsequent PR. We are using DecryptedAccountValue
to keep code changes small per PR, and the change will come once the wallet and walletdb are updated to read / store encrypted accounts.
async *loadAccounts(tx?: IDatabaseTransaction): AsyncGenerator<AccountValue, void, unknown> { | ||
async *loadAccounts( | ||
tx?: IDatabaseTransaction, | ||
): AsyncGenerator<DecryptedAccountValue, void, unknown> { |
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.
Same comment above regarding the generic. Will update once encrypted account encoding is added.
const encoder = new AccountValueEncoding() | ||
const data = encoder.serialize(account.serialize()) | ||
|
||
const encryptedData = encrypt(data, passphrase) |
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.
Will be refactored when the decrypted account has an encrypt
method for better encapsulation.
Summary
encrypt
/decrypt
to accept and return JS buffersAccountValue
toDecryptedAccountValue
encrypted
property to be used as a type guard in subsequent PRsEncryptedAccountValue
to represent encrypted accounts in the databaseTesting Plan
Unit test
Documentation
Does this change require any updates to the Iron Fish Docs (ex. the RPC API
Reference)? If yes, link a
related documentation pull request for the website.
Breaking Change
Is this a breaking change? If yes, add notes below on why this is breaking and label it with
breaking-change-rpc
orbreaking-change-sdk
.