message: Add: purser-metamask `accountChangeHook` index method
diff: @@ -9,11 +9,15 @@ import {
  methodCaller,
  getInpageProvider,
  detect as detectHelper,
  + setStateEventObserver,
  } from './helpers';
  import { staticMethods as messages } from './messages';
  -import type { MetamaskInpageProviderType } from './flowtypes';
  +import type {
  + MetamaskInpageProviderType,
  + MetamaskStateEventsObserverType,
  +} from './flowtypes';
  /**
  * Open the Metamask Wallet instance
  @@ -103,13 +107,28 @@ export const open = async (): Promise<MetamaskWallet> => {
  */
  export const detect = async (): Promise<boolean> => detectHelper();
  +/**
  + * Hook into Metamask's state events observers array to be able to act on account
  + * changes from the UI
  + *
  + * It's a wrapper around the `setStateEventObserver()` helper method
  + *
  + * @method accountChangeHook
  + *
  + * @return {Promise<void>} Does not return noting
  + */
  +export const accountChangeHook =
  + async (callback: MetamaskStateEventsObserverType): Promise<void> =>
  + setStateEventObserver(callback);
  +
  /*
  - * @NOTE There's an argument here to expose the new version
  + * @NOTE There's an argument to be made here to expose the new version
  */
  const metamaskWallet: Object = {
  open,
  detect,
  + accountChangeHook,
  };
  export default metamaskWallet;
  