vega-frontend-monorepo/libs/wallet/src/context.ts
Sam Keen 171babc2c9
Feat/1010: show rejected reason (and error details) on propose form results (#1086)
* feat/1010: Show proposal rejected reason in transaction dialog

* feat/1010: Show wallet rejection details in transaction dialog

* Feat/1010: Updated wallet types

* Feat/1010: Ensuring rejected proposals get the correct transaction dialog title

* Feat/1010: Fixing linting warning

* Feat/1010: Skipping node switcher tests for now
2022-08-26 16:05:16 +01:00

43 lines
1.2 KiB
TypeScript

import type { VegaKey } from './wallet-types';
import { createContext } from 'react';
import type { VegaConnector } from './connectors';
import type {
TransactionSubmission,
TransactionResponse,
} from './wallet-types';
export interface VegaKeyExtended extends VegaKey {
name: string;
}
export interface VegaWalletContextShape {
/** The current select public key */
keypair: VegaKeyExtended | null;
/** Public keys stored in users wallet */
keypairs: VegaKeyExtended[] | null;
/** Calls connect on the supplied connector, storing the returned keys */
connect: (connector: VegaConnector) => Promise<VegaKey[] | null>;
/** Disconnects from the connector and clears public key state */
disconnect: () => Promise<boolean>;
/** Sets the current selected public key */
selectPublicKey: (publicKey: string) => void;
/** Reference to the connector */
connector: VegaConnector | null;
/** Send a transaction to the network, only order submissions for now */
sendTx: (
tx: TransactionSubmission
) => Promise<
TransactionResponse | { error: string; details?: string[] }
> | null;
}
export const VegaWalletContext = createContext<
VegaWalletContextShape | undefined
>(undefined);