From df5b42c5f599ed91dc24c336b24d4b0d437c7fb8 Mon Sep 17 00:00:00 2001 From: Harry Solovay Date: Tue, 31 Jan 2023 18:55:50 -0500 Subject: [PATCH] cleanup --- rpc/known/chain.ts | 3 +-- rpc/known/utils.ts | 2 +- util/branded.ts | 17 ++++------------- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/rpc/known/chain.ts b/rpc/known/chain.ts index 28ab8b193..7983cea65 100644 --- a/rpc/known/chain.ts +++ b/rpc/known/chain.ts @@ -1,4 +1,3 @@ -import { HexEncoded } from "../../util/branded.ts" import { Hash, Hex, ListOrValue, NumberOrHex, RpcResult, Subscription } from "./utils.ts" // https://github.com/paritytech/substrate/blob/0ba251c/primitives/runtime/src/generic/digest.rs @@ -14,7 +13,7 @@ export interface Header { /** The parent hash. */ parentHash: Hash /** The block number. */ - number: HexEncoded + number: Hex /** The state trie merkle root */ stateRoot: Hash /** The merkle root of the extrinsics. */ diff --git a/rpc/known/utils.ts b/rpc/known/utils.ts index 789737fc9..7106511a8 100644 --- a/rpc/known/utils.ts +++ b/rpc/known/utils.ts @@ -11,6 +11,6 @@ export type Hash = U.HexHash export type SubId = string export type AccountId = string export type Subscription = string & { _subscription: [T, U] } -export type NumberOrHex = U.HexEncoded | number +export type NumberOrHex = U.Hex | number export type ListOrValue = T | T[] export type RpcResult = T diff --git a/util/branded.ts b/util/branded.ts index 11123260c..07733d865 100644 --- a/util/branded.ts +++ b/util/branded.ts @@ -1,18 +1,9 @@ -import { HasherKind } from "../frame_metadata/Metadata.ts" -export type Branded = T & { [_ in Brand]: V } +export type Branded = T & { [_ in Brand]: true } declare const _hex: unique symbol -export type Hex = Branded - -declare const _encoded: unique symbol -export type Encoded = Branded +export type Hex = Branded declare const _hash: unique symbol -export type Hash = Branded< - Uint8Array, - typeof _hash, - [T, K] -> +export type Hash = Branded -export type HexEncoded = Hex> -export type HexHash = Hex> +export type HexHash = Hex & Hash