@provenanceio/wallet-utils
Version:
Typescript Utilities for Provenance Blockchain Wallet
16 lines (15 loc) • 726 B
JavaScript
import * as google_protobuf_any_pb from 'google-protobuf/google/protobuf/any_pb';
import { bytesToBase64 } from '@tendermint/belt';
import { TYPE_NAMES_READABLE_MAP } from '../../types';
/**
* Returns a base64 encoded string of the provided message.
* @param type the type of the message. If message type is unsupported,
* update ReadableMessageNames in types.
* @param msg the message to convert to base64.
* @returns a base 64 string of the provided message
*/
export var createAnyMessageBase64 = function createAnyMessageBase64(type, msg) {
var msgAny = new google_protobuf_any_pb.Any();
msgAny.pack(msg.serializeBinary(), TYPE_NAMES_READABLE_MAP[type], '/');
return bytesToBase64(msgAny.serializeBinary());
};