-
Notifications
You must be signed in to change notification settings - Fork 15
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
use local codegen for protobuf message types #1624
Conversation
🦋 Changeset detectedLatest commit: bf60c3f The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
"@buf/tendermint_tendermint.bufbuild_es": "1.10.0-20231117195010-33ed361a9051.1", | ||
"@bufbuild/protobuf": "^1.10.0", | ||
"@connectrpc/connect": "^1.4.0", | ||
"@connectrpc/connect-web": "^1.4.0" | ||
}, | ||
"devDependencies": { | ||
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240703080008-312294d02bf9.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.
this one buf dep is still necessary because the registry incorrectly fails to declare a dependency
packages/protobuf/package.json
Outdated
"gen:cosmos-sdk": "buf generate buf.build/cosmos/cosmos-sdk:e7a85cef453e4b999ad9aff8714ae05f", | ||
"gen:ibc": "buf generate buf.build/cosmos/ibc:7ab44ae956a0488ea04e04511efa5f70", | ||
"gen:ics23": "buf generate buf.build/cosmos/ics23:55085f7c710a45f58fa09947208eb70b", | ||
"gen:penumbra": "buf generate buf.build/penumbra-zone/penumbra:312294d02bf945ffa4c1b1dd7cd91328", |
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.
versions used in core
https://github.com/penumbra-zone/penumbra/blob/main/proto/buf.lock
packages/protobuf/src/gen/.npmignore
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.
empty npmignore will allow this dir to be packaged
97af744
to
185a5db
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.
@@ -2,7 +2,7 @@ import { Translator } from './types.js'; | |||
import { | |||
SwapClaimView, | |||
SwapClaimView_Opaque, | |||
} from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/dex/v1/dex_pb.js'; | |||
} from '@penumbra-zone/protobuf/penumbra/core/component/dex/v1/dex_pb'; |
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.
question: any chance in the future we could simplify the imports? Maybe after applying v2 of the generator we could export types as barrels?
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 service definitions have a barrel export defined, but i think trying to collect other types into barrels is likely to be very complex and not very useful.
3289a2e
to
5a61797
Compare
79fbeaf
to
7115b4c
Compare
going to wait until recent core message type changes are merged for ibc compat before trying to merge this |
63839f4
to
adafb63
Compare
b17e61f
to
86eae85
Compare
fa81126
to
bf60c3f
Compare
const getTxHash = <T extends Required<PartialMessage<TransactionId>> | PartialMessage<Transaction>>( | ||
t: T, | ||
): T extends Required<PartialMessage<TransactionId>> ? string : Promise<string> => | ||
'inner' in t && t.inner instanceof Uint8Array | ||
? (uint8ArrayToHex(t.inner) as T extends Required<PartialMessage<TransactionId>> | ||
? string | ||
: never) | ||
: (getTxId(t as PartialMessage<Transaction>).then(({ inner }) => | ||
uint8ArrayToHex(inner), | ||
) as T extends Required<PartialMessage<TransactionId>> ? never : Promise<string>); | ||
|
||
const getTxId = (tx: Transaction | PartialMessage<Transaction>) => | ||
const txSha256 = (tx: Transaction | PartialMessage<Transaction>) => | ||
sha256Hash(tx instanceof Transaction ? tx.toBinary() : new Transaction(tx).toBinary()).then( | ||
inner => new TransactionId({ inner }), | ||
); |
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 caused problems at some point during this work, and the types were technically incorrect, so it's now simplified
fixes #1483 #1503
replaces #1582 #1583
it's simplest to use
buf generate
to create the definitions