Add decodeAny
This commit is contained in:
parent
d393adf31a
commit
484149a427
13
packages/proto-signing/src/any.ts
Normal file
13
packages/proto-signing/src/any.ts
Normal 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,
|
||||
};
|
||||
}
|
||||
1
packages/proto-signing/src/index.ts
Normal file
1
packages/proto-signing/src/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export { decodeAny } from "./any";
|
||||
10
packages/proto-signing/types/any.d.ts
vendored
Normal file
10
packages/proto-signing/types/any.d.ts
vendored
Normal 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;
|
||||
};
|
||||
1
packages/proto-signing/types/index.d.ts
vendored
Normal file
1
packages/proto-signing/types/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export { decodeAny } from "./any";
|
||||
Loading…
Reference in New Issue
Block a user