Skip to content
This repository was archived by the owner on Oct 7, 2024. It is now read-only.
Prev Previous commit
Next Next commit
Cast typing to override method return type
  • Loading branch information
gantunesr committed May 4, 2023
commit bca1de4b6dcea3aead1462da7f924aeb1e7a3fa1
18 changes: 9 additions & 9 deletions src/KeyringController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class KeyringController extends EventEmitter {
throw new Error(KeyringControllerError.UnsupportedExportAccount);
}

return await keyring.exportAccount(normalizeToHex(address));
return await keyring.exportAccount(normalizeToHex(address) as Hex);
}

/**
Expand Down Expand Up @@ -388,7 +388,7 @@ class KeyringController extends EventEmitter {
rawAddress: string,
opts: Record<string, unknown> = {},
): Promise<TxData> {
const address = normalizeToHex(rawAddress);
const address = normalizeToHex(rawAddress) as Hex;
const keyring = await this.getKeyringForAccount(address);
if (!keyring.signTransaction) {
throw new Error(KeyringControllerError.UnsupportedSignTransaction);
Expand All @@ -415,7 +415,7 @@ class KeyringController extends EventEmitter {
},
opts: Record<string, unknown> = {},
): Promise<string> {
const address = normalizeToHex(msgParams.from);
const address = normalizeToHex(msgParams.from) as Hex;
const keyring = await this.getKeyringForAccount(address);
if (!keyring.signMessage) {
throw new Error(KeyringControllerError.UnsupportedSignMessage);
Expand Down Expand Up @@ -443,13 +443,13 @@ class KeyringController extends EventEmitter {
},
opts: Record<string, unknown> = {},
): Promise<string> {
const address = normalizeToHex(msgParams.from);
const address = normalizeToHex(msgParams.from) as Hex;
const keyring = await this.getKeyringForAccount(address);
if (!keyring.signPersonalMessage) {
throw new Error(KeyringControllerError.UnsupportedSignPersonalMessage);
}

const normalizedData = normalizeToHex(msgParams.data);
const normalizedData = normalizeToHex(msgParams.data) as Hex;

return await keyring.signPersonalMessage(address, normalizedData, opts);
}
Expand All @@ -467,7 +467,7 @@ class KeyringController extends EventEmitter {
address: string,
opts: Record<string, unknown> = {},
): Promise<Bytes> {
const normalizedAddress = normalizeToHex(address);
const normalizedAddress = normalizeToHex(address) as Hex;
const keyring = await this.getKeyringForAccount(address);
if (!keyring.getEncryptionPublicKey) {
throw new Error(KeyringControllerError.UnsupportedGetEncryptionPublicKey);
Expand All @@ -490,7 +490,7 @@ class KeyringController extends EventEmitter {
from: string;
data: Eip1024EncryptedData;
}): Promise<Bytes> {
const address = normalizeToHex(msgParams.from);
const address = normalizeToHex(msgParams.from) as Hex;
const keyring = await this.getKeyringForAccount(address);
if (!keyring.decryptMessage) {
throw new Error(KeyringControllerError.UnsupportedDecryptMessage);
Expand Down Expand Up @@ -536,7 +536,7 @@ class KeyringController extends EventEmitter {
* @returns The app key address.
*/
async getAppKeyAddress(rawAddress: string, origin: string): Promise<string> {
const address = normalizeToHex(rawAddress);
const address = normalizeToHex(rawAddress) as Hex;
const keyring = await this.getKeyringForAccount(address);
if (!keyring.getAppKeyAddress) {
throw new Error(KeyringControllerError.UnsupportedGetAppKeyAddress);
Expand All @@ -556,7 +556,7 @@ class KeyringController extends EventEmitter {
rawAddress: string,
origin: string,
): Promise<string> {
const address = normalizeToHex(rawAddress);
const address = normalizeToHex(rawAddress) as Hex;
const keyring = await this.getKeyringForAccount(address);
if (!keyring.exportAccount) {
throw new Error(KeyringControllerError.UnsupportedExportAppKeyForAddress);
Expand Down