Update - 4

  1. I finalised on the architecure while setting up the everything required for the wallet, you can read more about it here: https://hackmd.io/4CoD1N-sR0O16HhUL40YFQ
  2. I created a version of Keyring controller that will control all the keyrings of wallets. Every keyring by wallet must implement the following interface:
export interface Keyring {
  type: string;
  serialize: () => Promise<object>;
  deserialize: (data: object) => Promise<void>;
  addAccounts: (numberOfAccounts?: number) => Promise<string[]>;
  getAccounts: () => Promise<string[]>;
  signTransaction: (
    address: string,
    userOperation: Partial<UserOperationStruct>,
    options?: object
  ) => Promise<UserOperationStruct>;
  signMessage: (
    address: string,
    data: any,
    options?: object
  ) => Promise<Buffer>;
  signPersonalMessage: (
    address: string,
    data: any,
    options?: object
  ) => Promise<Buffer>;
  getEncryptionPublicKey: (
    address: string,
    options?: object
  ) => Promise<Buffer>;
  decryptMessage: (
    address: string,
    data: any,
    options?: object
  ) => Promise<Buffer>;
  signTypedData: (
    address: string,
    data: any,
    options?: object
  ) => Promise<Buffer>;
  getAppKeyAddress: (_address: string, origin: string) => Promise<string>;
  exportAccount: (address: string, options?: object) => Promise<string>;
  generateRandomMnemonic?: () => void;
  init?: () => Promise<void>;
  removeAccount?: (address: string) => void;
  forgetDevice?: () => any;
}
  1. So far, I am able to initialise the keyring with a password, securely store the keyring's state in localstorage & recover the keyring from the localstorage if password or temperory recovery-key was provided.
  2. I also defined the service architecture for my chrome exgtension. Everything in the background & sandbox runs within services which listens to chrome runtime messages to communicate between each other.