-
Notifications
You must be signed in to change notification settings - Fork 17
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
bech32m #979
bech32m #979
Conversation
25b77b0
to
ef1aca3
Compare
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.
Nice tests!
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.
tests for removed function deleted
packages/getters/src/metadata.ts
Outdated
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.
use replaced with getValidatorIdentityKey
plus bech32IdentityKey
d60b753
to
1b8a965
Compare
1e2133a
to
e378ed5
Compare
}; | ||
}>; | ||
|
||
export default { |
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.
We should avoid using default exports in general
@@ -0,0 +1,30 @@ | |||
import SPEC from './format'; | |||
|
|||
export default SPEC; |
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 here, let's name our exports
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 package seems to have multiple ways its accessing the same information
A)
import { Prefixes } from './format/prefix';
const prefix = Prefixes.passet;
B)
import SPEC from './format';
export const PENUMBRA_BECH32M_ASSETID_PREFIX = SPEC.passet.prefix;
Instead of defining all of these parameters in separate objects, it feels simpler to just put them all in this file. Aka, this:
export const bech32Spec = {
passet: {
prefix: 'passet',
stringLength: 65,
byteLength: 32,
innerName: "inner",
},
}
versus
import { Inner } from './inner';
import { StringLength } from './strings';
import { ByteLength } from './bytes';
import { Prefixes } from './prefix';
export const bech32Spec = {
passet: {
prefix: Prefixes.passet,
stringLength: StringLength.passet,
byteLength: ByteLength.passet,
innerName: Inner.passet,
This will allow us also to delete packages/bech32m/src/index.ts
entirely
export const assetIdFromBech32m = (passet1: string): { [innerName]: Uint8Array } => ({ | ||
[innerName]: fromBech32m(passet1 as `${typeof prefix}1${string}`, prefix), | ||
}); |
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 whole purpose of this package is to allow us easy ways to convert to/from bech32 to/from Penumbra protobuf types. Returning approximations of the inside of these types feels unnecessary, especially given all consumers will then be required to construct the type manually right after. The more natural API is to simply return what they need. I think we should do this:
- export const assetIdFromBech32m = (passet1: string): { [innerName]: Uint8Array }
+ export const assetIdFromBech32m = (passet1: string): AssetId
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 whole purpose of the package is to verify bech32m or convert from bech32m to binary data in a verifiable way.
the types are a convenience. i would prefer to remove the structure than to add the types.
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.
Talked offline. Can revisit these topics later.
e378ed5
to
a1ca03e
Compare
fixing #778 and providing typesafe, named functions
also updating most of the tests to use more realistic data, now that lengths and checksums are validated everywhere.
this package is configured to build with tsc for publish, despite discussion of not building - it's a relatively simple package, the main export is all constant primitives, and it may be used in simpler contexts than the larger and more complex packages that depend on message types.
the diff is huge, because these functions are used absolutely everywhere.