mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-11 14:09:15 +00:00
Adapt types to fix
This commit is contained in:
parent
db90bd4445
commit
c5e1b75c40
@ -409,18 +409,24 @@ type RpcSignature = {
|
||||
/** hex encoded */
|
||||
readonly validator_address: string;
|
||||
readonly timestamp: string;
|
||||
/** bae64 encoded */
|
||||
readonly signature: string;
|
||||
/**
|
||||
* Base64 encoded signature.
|
||||
* There are cases when this is not set, see https://github.com/cosmos/cosmjs/issues/704#issuecomment-797122415.
|
||||
*/
|
||||
readonly signature: string | null;
|
||||
};
|
||||
|
||||
function decodeCommitSignature(data: RpcSignature): CommitSignature {
|
||||
const nonZeroTime = data.timestamp && !data.timestamp.startsWith("0001-01-01");
|
||||
return {
|
||||
blockIdFlag: decodeBlockIdFlag(data.block_id_flag),
|
||||
// FIXME: Return an optional validatorAddress instead of an empty Uint8Array
|
||||
// in the next breaking release.
|
||||
validatorAddress: fromHex(data.validator_address),
|
||||
timestamp: nonZeroTime ? fromRfc3339WithNanoseconds(data.timestamp) : undefined,
|
||||
// FIXME: make this optional in type? (signature?: Uint8Array)
|
||||
signature: fromBase64(optional(data.signature, "")),
|
||||
// FIXME: Return an optional signature instead of an empty Uint8Array
|
||||
// in the next breaking release.
|
||||
signature: fromBase64(data.signature || ""),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ export enum BlockIdFlag {
|
||||
}
|
||||
|
||||
export interface CommitSignature {
|
||||
/** If this is BlockIdFlag.Absent, all other fields are expected to be unset */
|
||||
blockIdFlag: BlockIdFlag;
|
||||
validatorAddress: Uint8Array;
|
||||
timestamp?: ReadonlyDateWithNanoseconds;
|
||||
|
Loading…
x
Reference in New Issue
Block a user