Adjust object index typings (#765)

* Adjust object index typings

* CHANGELOG

* Bump common
This commit is contained in:
Jaco
2023-06-11 10:16:28 +03:00
committed by GitHub
parent 252a8a8554
commit 50b4e2bd07
14 changed files with 214 additions and 216 deletions
+6 -5
View File
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type { KeyringInstance, KeyringPair } from '@polkadot/keyring/types';
import type { HexString } from '@polkadot/util/types';
import type { Prefix } from '@polkadot/util-crypto/address/types';
import type { AddressSubject } from './observable/types.js';
import type { KeyringOptions, KeyringStore } from './types.js';
@@ -28,9 +29,9 @@ export class Base {
protected _store: KeyringStore;
protected _genesisHash?: string | undefined;
protected _genesisHash?: HexString | undefined;
protected _genesisHashAdd: string[] = [];
protected _genesisHashAdd: HexString[] = [];
constructor () {
this.#accounts = accounts;
@@ -64,11 +65,11 @@ export class Base {
throw new Error('Keyring should be initialised via \'loadAll\' before use');
}
public get genesisHash (): string | undefined {
public get genesisHash (): HexString | undefined {
return this._genesisHash;
}
public get genesisHashes (): string[] {
public get genesisHashes (): HexString[] {
return this._genesisHash
? [this._genesisHash, ...this._genesisHashAdd]
: [...this._genesisHashAdd];
@@ -130,7 +131,7 @@ export class Base {
this.#keyring = keyring;
this._genesisHash = options.genesisHash && (
isString(options.genesisHash)
? options.genesisHash.toString()
? options.genesisHash.toString() as HexString
: options.genesisHash.toHex()
);
this._genesisHashAdd = options.genesisHashAdd || [];
+5 -20
View File
@@ -2,29 +2,14 @@
// SPDX-License-Identifier: Apache-2.0
import type { KeyringInstance as BaseKeyringInstance, KeyringOptions as KeyringOptionsBase, KeyringPair, KeyringPair$Json, KeyringPair$Meta } from '@polkadot/keyring/types';
import type { HexString } from '@polkadot/util/types';
import type { EncryptedJson } from '@polkadot/util-crypto/json/types';
import type { KeypairType } from '@polkadot/util-crypto/types';
import type { AddressSubject, SingleAddress } from './observable/types.js';
export interface ContractMeta {
abi: string;
genesisHash?: string | null;
}
export type ContractMeta = NonNullable<KeyringPair$Meta['contract']>;
export interface KeyringJson$Meta {
contract?: ContractMeta;
genesisHash?: string | null | undefined;
hardwareType?: 'ledger';
isHardware?: boolean;
isInjected?: boolean;
isRecent?: boolean;
isTesting?: boolean;
name?: string;
whenCreated?: number;
whenEdited?: number;
whenUsed?: number;
[index: string]: unknown;
}
export type KeyringJson$Meta = KeyringPair$Meta;
export interface KeyringJson {
address: string;
@@ -44,8 +29,8 @@ export interface KeyringStore {
export interface KeyringOptions extends KeyringOptionsBase {
filter?: (json: KeyringJson) => boolean;
genesisHash?: string | { toHex: () => string };
genesisHashAdd?: string[];
genesisHash?: HexString | { toHex: () => HexString };
genesisHashAdd?: HexString[];
isDevelopment?: boolean;
store?: KeyringStore;
}