Skip to content

Commit 774fff4

Browse files
committed
wip: useful logs
1 parent 0a11bf2 commit 774fff4

File tree

3 files changed

+40
-18
lines changed

3 files changed

+40
-18
lines changed

packages/suite/src/middlewares/wallet/discoveryMiddleware.ts

+6
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export const prepareDiscoveryMiddleware = createMiddlewareWithExtraDeps(
8080
!locks.includes(SUITE.LOCK_TYPE.DEVICE) &&
8181
(deviceActions.selectDevice.match(action) || action.type === SUITE.APP_CHANGED)
8282
) {
83+
console.log('true 1');
8384
authorizationIntent = true;
8485
}
8586

@@ -100,12 +101,17 @@ export const prepareDiscoveryMiddleware = createMiddlewareWithExtraDeps(
100101
device.connected
101102
);
102103
if (becomesAcquired) {
104+
console.log('true 2');
105+
103106
authorizationIntent = true;
104107
}
105108
}
106109

107110
// 3. begin auth process
108111
if (authorizationIntent) {
112+
console.log('middleware handling action', action.type);
113+
114+
console.log('authorizeDeviceThunk()');
109115
dispatch(authorizeDeviceThunk());
110116
}
111117

suite-common/connect-init/src/connectInitThunks.ts

+31-18
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export const connectInitThunk = createThunk(
5959

6060
const synchronize = getSynchronize();
6161

62+
let connectlock = '';
6263
Object.keys(TrezorConnect)
6364
.filter(
6465
key =>
@@ -85,25 +86,37 @@ export const connectInitThunk = createThunk(
8586

8687
// @ts-expect-error
8788
TrezorConnect[key] = async (params: any) => {
88-
const infoResult = await original({ ...params, __info: true });
89-
const useWrapped = infoResult.success && infoResult.payload.useDevice;
90-
91-
if (!useWrapped) {
92-
return original(params);
89+
try {
90+
if (connectlock) {
91+
console.warn(
92+
`Device.LOCK is already set! this suggest antipattern: ${key} locked by ${connectlock}`,
93+
);
94+
}
95+
connectlock = key;
96+
console.log('key', key);
97+
const infoResult = await original({ ...params, __info: true });
98+
console.log('infoResult', infoResult);
99+
const useWrapped = infoResult.success && infoResult.payload.useDevice;
100+
101+
if (!useWrapped) {
102+
return original(params);
103+
}
104+
105+
const enabledNetworks = getEnabledNetworks();
106+
const cardanoEnabled =
107+
infoResult.payload.useDeviceState &&
108+
!!enabledNetworks.find(a => a === 'ada' || a === 'tada');
109+
110+
dispatch(lockDevice(true));
111+
const result = await synchronize(() =>
112+
original({ ...params, useCardanoDerivation: cardanoEnabled }),
113+
);
114+
dispatch(lockDevice(false));
115+
console.log('result', result);
116+
return result;
117+
} finally {
118+
connectlock = '';
93119
}
94-
95-
const enabledNetworks = getEnabledNetworks();
96-
const cardanoEnabled =
97-
infoResult.payload.useDeviceState &&
98-
!!enabledNetworks.find(a => a === 'ada' || a === 'tada');
99-
100-
dispatch(lockDevice(true));
101-
const result = await synchronize(() =>
102-
original({ ...params, useCardanoDerivation: cardanoEnabled }),
103-
);
104-
dispatch(lockDevice(false));
105-
106-
return result;
107120
};
108121
});
109122

suite-common/wallet-core/src/device/deviceThunks.ts

+3
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ export const authorizeDeviceThunk = createThunk<
336336
useEmptyPassphrase: device.useEmptyPassphrase,
337337
};
338338

339+
console.log('getDeviceState 1');
339340
const response = await TrezorConnect.getDeviceState(deviceParams);
340341

341342
if (response.success) {
@@ -415,6 +416,8 @@ export const authConfirm = createThunk(
415416
const device = selectDeviceSelector(getState());
416417
if (!device) return false;
417418

419+
console.log('getDeviceState 2');
420+
418421
const response = await TrezorConnect.getDeviceState({
419422
device: {
420423
path: device.path,

0 commit comments

Comments
 (0)