AccountContext.js 478 B
Newer Older
Axel Chalon's avatar
Axel Chalon committed
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: BSD-3-Clause

Axel Chalon's avatar
Axel Chalon committed
import React from 'react';
import { Provider, subscribe } from 'react-contextual';
Axel Chalon's avatar
Axel Chalon committed

Axel Chalon's avatar
Axel Chalon committed
export const consumeAccount = subscribe('account');
Axel Chalon's avatar
Axel Chalon committed

export const provideAccount = getAccountAddress => Component => props => {
  return (
Axel Chalon's avatar
Axel Chalon committed
    <Provider id='account' accountAddress={getAccountAddress(props)}>
Axel Chalon's avatar
Axel Chalon committed
      <Component {...props} />
    </Provider>
  );
};