2022-02-22 06:40:55 +00:00
|
|
|
import { VegaKey } from '@vegaprotocol/vegawallet-service-api-client';
|
|
|
|
import { createContext } from 'react';
|
2022-02-22 23:06:35 +00:00
|
|
|
import { VegaConnector } from './connectors';
|
2022-02-22 06:40:55 +00:00
|
|
|
|
2022-02-23 05:05:39 +00:00
|
|
|
export interface VegaKeyExtended extends VegaKey {
|
|
|
|
name: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface VegaWalletContextShape {
|
2022-02-24 00:03:59 +00:00
|
|
|
/** The current select public key */
|
|
|
|
keypair: VegaKeyExtended | null;
|
|
|
|
|
2022-02-23 05:05:39 +00:00
|
|
|
/** Public keys stored in users wallet */
|
2022-02-24 00:03:59 +00:00
|
|
|
keypairs: VegaKeyExtended[] | null;
|
2022-02-23 05:05:39 +00:00
|
|
|
|
|
|
|
/** Calls connect on the supplied connector, storing the returned keys */
|
2022-02-22 06:40:55 +00:00
|
|
|
connect: (connector: VegaConnector) => Promise<void>;
|
2022-02-23 05:05:39 +00:00
|
|
|
|
|
|
|
/** Disconnects from the connector and clears public key state */
|
2022-02-22 06:40:55 +00:00
|
|
|
disconnect: () => Promise<void>;
|
2022-02-23 05:05:39 +00:00
|
|
|
|
2022-02-24 00:03:59 +00:00
|
|
|
/** Sets the current selected public key */
|
|
|
|
selectPublicKey: (publicKey: string) => void;
|
|
|
|
|
2022-02-23 05:05:39 +00:00
|
|
|
/** Reference to the connector */
|
2022-02-22 06:40:55 +00:00
|
|
|
connector: VegaConnector | null;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const VegaWalletContext = createContext<
|
|
|
|
VegaWalletContextShape | undefined
|
|
|
|
>(undefined);
|