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

Utilize an Opaque type to key on currencies in the Ledger #3231

Merged
merged 1 commit into from
Oct 22, 2021

Conversation

topocount
Copy link
Member

By utilizing an opaque type, we can eliminate the details of
stringifying the Currency objects from the ledger. This allows for some
cleaner scope of concern.

The opaque type prevents the decoding of keys, which
should not be necessary, Generating a key should be a one-way operation,
in case we ever move to generating hashes instead of just stringified
objects, or some other operation to that changes the characteristics of
keys.

Additionally, json-stable-stringify is utilized over JSON.stringify
because it produces the same string across all platforms. Some
JSON.stringify implementations differ and therefore it is potentially
unstable.

test plan: unit tests have been updated

Merge plan: this is a prereq to #3156

By utilizing an opaque type, we can eliminate the details of
stringifying the Currency objects from the ledger. This allows for some
cleaner scope of concern.

The opaque type prevents the decoding of keys, which
should not be necessary, Generating a key should be a one-way operation,
in case we ever move to generating hashes instead of just stringified
objects, or some other operation to that changes the characteristics of
keys.

Additionally, json-stable-stringify is utilized over JSON.stringify
because it produces the same string across all platforms. Some
JSON.stringify implementations differ and therefore it is potentially
unstable.

test plan: unit tests have been updated
Copy link
Contributor

@hozzjss hozzjss left a comment

Choose a reason for hiding this comment

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

Awesome shit dude, LFG

@topocount topocount merged commit b95f7fb into main Oct 22, 2021
@topocount topocount deleted the currency-key branch October 22, 2021 20:01
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