mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-02-20 00:33:07 +01:00
refactor(connect): remove override
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import TrezorConnect from '@trezor/connect';
|
||||
|
||||
import { getController, initTrezorConnect, setup } from '../../common.setup';
|
||||
|
||||
const controller = getController();
|
||||
|
||||
describe('TrezorConnect override param', () => {
|
||||
beforeAll(async () => {
|
||||
await setup(controller, {
|
||||
mnemonic: 'mnemonic_all',
|
||||
});
|
||||
await initTrezorConnect(controller, { autoConfirm: false });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
controller.dispose();
|
||||
TrezorConnect.dispose();
|
||||
});
|
||||
|
||||
[
|
||||
// 1, this is flaky and only @marekrjpolak has the power to solve it
|
||||
10, 100, 300, 500, 1000, 1500,
|
||||
].forEach(delay => {
|
||||
it(`override previous call after ${delay}ms`, async () => {
|
||||
TrezorConnect.removeAllListeners();
|
||||
|
||||
const overridden = TrezorConnect.getAddress({
|
||||
path: "m/44'/1'/0'/0/0",
|
||||
showOnTrezor: true,
|
||||
});
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, delay));
|
||||
|
||||
const address = await TrezorConnect.getAddress({
|
||||
path: "m/44'/1'/0'/0/0",
|
||||
override: true,
|
||||
showOnTrezor: false,
|
||||
});
|
||||
expect(address.success).toBe(true);
|
||||
|
||||
const response = await overridden;
|
||||
expect(response.success).toBe(false);
|
||||
expect(response.payload).toMatchObject({ code: 'Method_Override' });
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -10,6 +10,7 @@ export default class SetBusy extends AbstractMethod<'setBusy', PROTO.SetBusy> {
|
||||
this.useDeviceState = false;
|
||||
this.requiredPermissions = ['management'];
|
||||
this.skipFinalReload = false;
|
||||
this.overridePreviousCall = true; // currently used only in cj and should always override
|
||||
|
||||
const { payload } = this;
|
||||
|
||||
|
||||
@@ -174,8 +174,7 @@ export abstract class AbstractMethod<Name extends CallMethodPayload['method'], P
|
||||
: false;
|
||||
this.keepSession = typeof payload.keepSession === 'boolean' ? payload.keepSession : false;
|
||||
this.skipFinalReload = true;
|
||||
this.overridePreviousCall =
|
||||
typeof payload.override === 'boolean' ? payload.override : false;
|
||||
this.overridePreviousCall = false;
|
||||
this.overridden = false;
|
||||
this.useEmptyPassphrase =
|
||||
typeof payload.useEmptyPassphrase === 'boolean' ? payload.useEmptyPassphrase : false;
|
||||
|
||||
@@ -16,7 +16,6 @@ export interface CommonParams {
|
||||
useEmptyPassphrase?: boolean;
|
||||
useEventListener?: boolean; // this param is set automatically in factory
|
||||
keepSession?: boolean;
|
||||
override?: boolean;
|
||||
useCardanoDerivation?: boolean;
|
||||
/**
|
||||
* internal flag. if set to true, call will only return info about the method, not execute it.
|
||||
|
||||
@@ -100,7 +100,6 @@ export const init = () => async (dispatch: Dispatch, getState: GetState) => {
|
||||
try {
|
||||
const res = await TrezorConnect.cipherKeyValue({
|
||||
device: { path: device?.path },
|
||||
override: true,
|
||||
useEmptyPassphrase: true,
|
||||
path: METADATA_PASSWORDS.PATH,
|
||||
key: METADATA_PASSWORDS.DEFAULT_KEYPHRASE,
|
||||
|
||||
@@ -255,10 +255,7 @@ export const setBusyScreen =
|
||||
}
|
||||
|
||||
return TrezorConnect.setBusy({
|
||||
device: {
|
||||
path: device?.path,
|
||||
},
|
||||
override: true, // override current call (override SUITE.LOCK)
|
||||
device: { path: device?.path },
|
||||
keepSession: !!expiry, // do not release device session, keep it for signTransaction
|
||||
expiry_ms: expiry,
|
||||
});
|
||||
@@ -662,7 +659,6 @@ const signCoinjoinTx =
|
||||
preauthorized: true,
|
||||
serialize: false,
|
||||
unlockPath,
|
||||
override: true, // override current call (override SUITE.LOCK)
|
||||
chunkify: addressDisplayType === AddressDisplayOptions.CHUNKED,
|
||||
});
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ export const EntryForm = ({ onEncrypted, entry, cancel }: Props) => {
|
||||
const nonce = randomBytes(32).toString('hex');
|
||||
TrezorConnect.cipherKeyValue({
|
||||
device: { path: device.path },
|
||||
override: true,
|
||||
useEmptyPassphrase: true,
|
||||
path: PATH,
|
||||
key: getDisplayKey(title, username),
|
||||
|
||||
@@ -66,7 +66,6 @@ export const PasswordEntry = ({
|
||||
setInProgress(true);
|
||||
TrezorConnect.cipherKeyValue({
|
||||
device: { path: devicePath },
|
||||
override: true,
|
||||
useEmptyPassphrase: true,
|
||||
path: PATH,
|
||||
key: getDisplayKey(title, username),
|
||||
|
||||
@@ -16,7 +16,7 @@ const groups = {
|
||||
// temporarily created group for flaky test - to spend less time on reruns and to make test result in CI more readable without investigating long logs
|
||||
apiFlaky: {
|
||||
name: 'api-flaky',
|
||||
pattern: 'override init',
|
||||
pattern: 'init',
|
||||
},
|
||||
thp: {
|
||||
name: 'thp',
|
||||
|
||||
Reference in New Issue
Block a user