From 1ccf17ce6f55579d1e7e8018e30f561d5a4a79e5 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Mon, 25 May 2020 18:54:32 +0200 Subject: [PATCH] rename Signer controller to Keyring --- src/client.ts | 16 ++++++++-------- src/constants/rpc.ts | 4 ++-- src/controllers/index.ts | 2 +- src/controllers/{signer.ts => keyring.ts} | 4 ++-- src/helpers/validators.ts | 6 +++--- src/typings/controllers.ts | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) rename src/controllers/{signer.ts => keyring.ts} (98%) diff --git a/src/client.ts b/src/client.ts index b392242..2befdf0 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,6 +1,6 @@ import { IWakuProvider, - IWakuSigner, + IWakuKeyring, IWakuStore, IWakuClient, JsonRpcRequest, @@ -8,15 +8,15 @@ import { import { HttpConnection, WakuProvider, - WakuSigner, + WakuKeyring, WakuStore, } from "./controllers"; -import { isSignerMethod, isNetworkMethod } from "./helpers/validators"; +import { isKeyringMethod, isNetworkMethod } from "./helpers/validators"; import { WAKU_PREFIX } from "./constants"; class Waku implements IWakuClient { public provider: IWakuProvider; public store: IWakuStore; - public signer: IWakuSigner; + public keyring: IWakuKeyring; constructor(provider: string | IWakuProvider, store?: IWakuStore) { this.provider = @@ -24,17 +24,17 @@ class Waku implements IWakuClient { ? new WakuProvider(new HttpConnection(provider)) : provider; this.store = store || new WakuStore(); - this.signer = new WakuSigner(this.store); + this.keyring = new WakuKeyring(this.store); } public async init(): Promise { - await this.signer.init(); + await this.keyring.init(); return this.provider.init(); } public async request(payload: JsonRpcRequest): Promise { - if (isSignerMethod(payload.method)) { - return this.signer.request(payload); + if (isKeyringMethod(payload.method)) { + return this.keyring.request(payload); } else if (isNetworkMethod(payload.method)) { return this.provider.request(payload); } diff --git a/src/constants/rpc.ts b/src/constants/rpc.ts index d94de79..618cf14 100644 --- a/src/constants/rpc.ts +++ b/src/constants/rpc.ts @@ -10,7 +10,7 @@ export const NETWORK_METHODS = { waku_cancelLightClient: "waku_cancelLightClient", }; -export const SIGNER_METHODS = { +export const KEYRING_METHODS = { waku_newKeyPair: "waku_newKeyPair", waku_addPrivateKey: "waku_addPrivateKey", waku_deleteKeyPair: "waku_deleteKeyPair", @@ -37,6 +37,6 @@ export const MESSAGING_METHODS = { export const RPC_METHODS = { NETWORK: NETWORK_METHODS, - SIGNER: SIGNER_METHODS, + KEYRING: KEYRING_METHODS, MESSAGING: MESSAGING_METHODS, }; diff --git a/src/controllers/index.ts b/src/controllers/index.ts index bb13b4e..079ca1d 100644 --- a/src/controllers/index.ts +++ b/src/controllers/index.ts @@ -1,4 +1,4 @@ export * from "./http"; export * from "./provider"; -export * from "./signer"; +export * from "./keyring"; export * from "./store"; diff --git a/src/controllers/signer.ts b/src/controllers/keyring.ts similarity index 98% rename from src/controllers/signer.ts rename to src/controllers/keyring.ts index d4755a7..ad8f861 100644 --- a/src/controllers/signer.ts +++ b/src/controllers/keyring.ts @@ -7,7 +7,7 @@ import { } from "eccrypto-js"; import { - IWakuSigner, + IWakuKeyring, IWakuStore, KeyMap, KeyPair, @@ -19,7 +19,7 @@ import { STORE_KEYS_ID, WAKU_PREFIX } from "../constants"; import { uuid, getFirstMatch } from "../helpers"; import { isKeyPair, isSymKey } from "../helpers/validators"; -export class WakuSigner implements IWakuSigner { +export class WakuKeyring implements IWakuKeyring { private keyMap: KeyMap = {}; constructor(private store: IWakuStore) {} diff --git a/src/helpers/validators.ts b/src/helpers/validators.ts index eef2bd3..9e8976e 100644 --- a/src/helpers/validators.ts +++ b/src/helpers/validators.ts @@ -1,7 +1,7 @@ import { KeyPair, SymKey } from "../typings"; import { NETWORK_METHODS, - SIGNER_METHODS, + KEYRING_METHODS, MESSAGING_METHODS, } from "../constants"; @@ -18,9 +18,9 @@ export function isNetworkMethod(value?: string): boolean { return Object.keys(NETWORK_METHODS).includes(value); } -export function isSignerMethod(value?: string): boolean { +export function isKeyringMethod(value?: string): boolean { if (!value) return false; - return Object.keys(SIGNER_METHODS).includes(value); + return Object.keys(KEYRING_METHODS).includes(value); } export function isMessagingMethod(value?: string): boolean { diff --git a/src/typings/controllers.ts b/src/typings/controllers.ts index 7d607fa..a33b889 100644 --- a/src/typings/controllers.ts +++ b/src/typings/controllers.ts @@ -11,7 +11,7 @@ export interface IWakuProvider extends BasicProvider, IWakuController { enable(): Promise; } -export interface IWakuSigner extends IWakuController { +export interface IWakuKeyring extends IWakuController { newKeyPair(): Promise; addPrivateKey(prvKey: string): Promise; deleteKeyPair(id: string): Promise; @@ -35,5 +35,5 @@ export interface IWakuStore { export interface IWakuClient extends IWakuController { provider: IWakuProvider; store: IWakuStore; - signer: IWakuSigner; + keyring: IWakuKeyring; }