-
Notifications
You must be signed in to change notification settings - Fork 0
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
Protobuf metadata #32
Conversation
# Conflicts: # package-lock.json # package.json # tsconfig.json
# Conflicts: # index.web.ts # src/api/transaction/multipartMock # src/transaction/mocks/multipart # src/transaction/multipartMock
if (!file?.arrayBuffer) { | ||
throw new Error(`Unsupported metadata type: ${typeof file}`); | ||
} |
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.
So this will happen on older engines, right? Should we have the error message tell users to upgrade their engines?
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.
No, it won't. It's looking for metadata.proto
part, so it won't get here.
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.
I think this LGTM. I haven't finished reading the tests, but the main core of the code looks right :) Thanks both!
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.
Very nice and clean :)
"build": "rm -rf ./dist && webpack build", | ||
"proto-gen": "npx protoc --ts_out src/proto/generated/ --proto_path src/proto src/proto/*.proto", | ||
"dev": "rm -rf ./dist && webpack watch", |
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.
Are build
and dev
unrelated cleanups?
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.
yes
src/api/transaction/mocks/protobuf
Outdated
@@ -0,0 +1,11 @@ | |||
|
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.
Nit pick: Can we use the proper file extension :)
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.
Sure we can, I just I have no idea about what that would be. What's the proper file extension for protobuf binaries?
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.
.proto i think
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.
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.
yeah. I guess we didn't get this right in the actual protocol.
Maybe .pb
, i.e. metadata.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.
Renamed to metadata.pb
src/proto/metadata.proto
Outdated
@@ -0,0 +1,160 @@ | |||
syntax = "proto3"; |
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 file is engine internal and not needed in the client :)
Please delete it!
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.
Done, thx!
// TODO uncomment and make TransactionAsyncResult.metadata required | ||
// if (!metadataProto) { | ||
// throw new Error('metadata proto part not found'); | ||
// } |
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.
Is this a TODO for this PR?
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.
No, it'll be removed later. Just don't want it to throw errors on old engines.
export async function readProtoMetadata(file: File | Blob) { | ||
if (!file?.arrayBuffer) { | ||
throw new Error(`Unsupported metadata type: ${typeof file}`); | ||
} |
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.
Do we still need the error handling? In which case would either the File
or Blob
type not contain the array buffer?
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.
Yes, I think so. We had an issue when node-fetch
was returning a string instead of File | Blob
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.
that's fixed in the engines now, but i guess there could always be an old engine lurking out there 👀
makes sense, thanks
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.
Thanks Denis! Pair-reviewed with @bachdavi
src/proto/generated/metadata.ts
Outdated
@@ -0,0 +1,1283 @@ | |||
// @generated by protobuf-ts 2.7.0 |
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.
(and please delete this file too, of course)
This PR adds support to metadata protobuf format parsing.