2023-08-31 02:40:04 +00:00
|
|
|
import { FLAGS } from '@vegaprotocol/environment';
|
2023-01-19 11:16:21 +00:00
|
|
|
import {
|
|
|
|
JsonRpcConnector,
|
|
|
|
ViewConnector,
|
2023-07-12 10:34:42 +00:00
|
|
|
InjectedConnector,
|
2023-08-29 01:51:58 +00:00
|
|
|
SnapConnector,
|
|
|
|
DEFAULT_SNAP_ID,
|
2023-01-19 11:16:21 +00:00
|
|
|
} from '@vegaprotocol/wallet';
|
2022-02-22 23:06:35 +00:00
|
|
|
|
2022-10-03 18:12:34 +00:00
|
|
|
export const jsonRpc = new JsonRpcConnector();
|
2023-07-12 10:34:42 +00:00
|
|
|
export const injected = new InjectedConnector();
|
2022-02-23 05:39:12 +00:00
|
|
|
|
2023-01-19 11:16:21 +00:00
|
|
|
let view: ViewConnector;
|
|
|
|
if (typeof window !== 'undefined') {
|
|
|
|
const urlParams = new URLSearchParams(window.location.hash.split('?')[1]);
|
|
|
|
view = new ViewConnector(urlParams.get('address'));
|
|
|
|
} else {
|
|
|
|
view = new ViewConnector();
|
|
|
|
}
|
|
|
|
|
2023-08-31 02:40:04 +00:00
|
|
|
export const snap = FLAGS.METAMASK_SNAPS
|
|
|
|
? new SnapConnector(DEFAULT_SNAP_ID)
|
|
|
|
: undefined;
|
2023-08-29 01:51:58 +00:00
|
|
|
|
2022-02-22 23:06:35 +00:00
|
|
|
export const Connectors = {
|
2023-07-12 10:34:42 +00:00
|
|
|
injected,
|
2022-10-03 18:12:34 +00:00
|
|
|
jsonRpc,
|
2023-01-19 11:16:21 +00:00
|
|
|
view,
|
2023-08-29 01:51:58 +00:00
|
|
|
snap,
|
2022-02-22 23:06:35 +00:00
|
|
|
};
|