Add decodeAny

This commit is contained in:
Simon Warta 2020-08-06 11:22:21 +02:00
parent d393adf31a
commit 484149a427
4 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,13 @@
import { google } from "./generated/codecimpl";
/**
* Decodes a serialized [google.protobuf.Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto)
* and returns the components.
*/
export function decodeAny(serialized: Uint8Array): { readonly typeUrl: string; readonly value: Uint8Array } {
const envelope = google.protobuf.Any.decode(serialized);
return {
typeUrl: envelope.type_url,
value: envelope.value,
};
}

View File

@ -0,0 +1 @@
export { decodeAny } from "./any";

10
packages/proto-signing/types/any.d.ts vendored Normal file
View File

@ -0,0 +1,10 @@
/**
* Decodes a serialized [google.protobuf.Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto)
* and returns the components.
*/
export declare function decodeAny(
serialized: Uint8Array,
): {
readonly typeUrl: string;
readonly value: Uint8Array;
};

View File

@ -0,0 +1 @@
export { decodeAny } from "./any";