fix: amend and cancel order tests, global connect tests
This commit is contained in:
@@ -32,9 +32,6 @@ export const testOrderAmendment = (
|
||||
...expected,
|
||||
};
|
||||
|
||||
expectedOrder.expiresAt = expectedOrder.expiresAt || undefined;
|
||||
expectedOrder.price = expectedOrder.price || undefined;
|
||||
|
||||
const transaction: OrderAmendmentBody = {
|
||||
orderAmendment: expectedOrder,
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ export interface VegaWalletContextShape {
|
||||
connect: (connector: VegaConnector) => Promise<PubKey[] | null>;
|
||||
|
||||
/** Disconnects from the connector and clears public key state */
|
||||
disconnect: () => Promise<boolean>;
|
||||
disconnect: () => Promise<void>;
|
||||
|
||||
/** Sets the current selected public key */
|
||||
selectPubKey: (pubKey: string) => void;
|
||||
|
||||
@@ -59,23 +59,19 @@ export const VegaWalletProvider = ({ children }: VegaWalletProviderProps) => {
|
||||
}, []);
|
||||
|
||||
const disconnect = useCallback(async () => {
|
||||
// always clear state after attempted disconnection.. this
|
||||
// is because long lived token sessions (used in tests)
|
||||
// cannot be cleared. Clearing state will force user to reconnect
|
||||
// again as expected
|
||||
setPubKeys(null);
|
||||
setPubKey(null);
|
||||
LocalStorage.removeItem(WALLET_KEY);
|
||||
try {
|
||||
await connector.current?.disconnect();
|
||||
setPubKeys(null);
|
||||
setPubKey(null);
|
||||
connector.current = null;
|
||||
LocalStorage.removeItem(WALLET_KEY);
|
||||
return true;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
if (err instanceof WalletError && err.code === 100) {
|
||||
setPubKeys(null);
|
||||
setPubKey(null);
|
||||
connector.current = null;
|
||||
LocalStorage.removeItem(WALLET_KEY);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
connector.current = null;
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user