Skip to content

Commit

Permalink
Revert "feat(connect): add bluetoothProps to Device"
Browse files Browse the repository at this point in the history
This reverts commit 17847cb.
  • Loading branch information
Nodonisko committed Jan 27, 2025
1 parent 3bbf0de commit 2aff779
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 864 deletions.
9 changes: 1 addition & 8 deletions packages/connect/src/device/Device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ export class Device extends TypedEmitter<DeviceEvents> {
public readonly transportPath;
private readonly transportSessionOwner;
private readonly transportDescriptorType;
private readonly bluetoothProps;
private session;
private lastAcquiredHere;

Expand Down Expand Up @@ -215,7 +214,6 @@ export class Device extends TypedEmitter<DeviceEvents> {
this.transportPath = descriptor.path;
this.transportSessionOwner = descriptor.sessionOwner;
this.transportDescriptorType = descriptor.type;
this.bluetoothProps = descriptor.uuid ? { uuid: descriptor.uuid } : undefined;

this.session = descriptor.session;
this.lastAcquiredHere = false;
Expand Down Expand Up @@ -531,7 +529,6 @@ export class Device extends TypedEmitter<DeviceEvents> {
// update features
try {
if (fn) {
console.log('initialize', !!options.useCardanoDerivation);
await this.initialize(!!options.useCardanoDerivation);
} else {
const getFeaturesTimeout =
Expand Down Expand Up @@ -729,9 +726,7 @@ export class Device extends TypedEmitter<DeviceEvents> {
}
}

console.log('initialiaze getFeatures');
const { message } = await this.getCommands().typedCall('Initialize', 'Features', payload);
console.log('initialiaze getFeatures done', message);
this._updateFeatures(message);
this.setState({ deriveCardano: payload?.derive_cardano });
}
Expand Down Expand Up @@ -864,7 +859,7 @@ export class Device extends TypedEmitter<DeviceEvents> {
return;
}

const releases = getReleases(this.features.internal_model) ?? [];
const releases = getReleases(this.features.internal_model);

const release = releases.find(
r =>
Expand Down Expand Up @@ -1194,7 +1189,6 @@ export class Device extends TypedEmitter<DeviceEvents> {
label: 'Unacquired device',
name: this.name,
transportSessionOwner: this.transportSessionOwner,
bluetoothProps: this.bluetoothProps,
};
}
const defaultLabel = 'My Trezor';
Expand All @@ -1220,7 +1214,6 @@ export class Device extends TypedEmitter<DeviceEvents> {
unavailableCapabilities: this.unavailableCapabilities,
availableTranslations: this.availableTranslations,
authenticityChecks: this.authenticityChecks,
bluetoothProps: this.bluetoothProps,
};
}
}
34 changes: 20 additions & 14 deletions packages/connect/src/events/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,24 @@ export const createResponseMessage = (
success: boolean,
payload: any,
device?: Device,
): MethodResponseMessage => ({
event: RESPONSE_EVENT,
type: RESPONSE_EVENT,
id,
success,
): MethodResponseMessage => {
if (!success) {
console.error(payload);
}

payload: success ? payload : serializeError(payload),
device: device
? {
path: device?.getUniquePath(),
state: device?.getState(),
instance: device?.getInstance(),
}
: undefined,
});
return {
event: RESPONSE_EVENT,
type: RESPONSE_EVENT,
id,
success,

payload: success ? payload : serializeError(payload),
device: device
? {
path: device?.getUniquePath(),
state: device?.getState(),
instance: device?.getInstance(),
}
: undefined,
};
};
7 changes: 0 additions & 7 deletions packages/connect/src/types/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ type BaseDevice = {
name: string;
};

export type BluetoothDeviceProps = {
uuid: string;
};

export type KnownDevice = BaseDevice & {
type: 'acquired';
id: string | null;
Expand All @@ -109,7 +105,6 @@ export type KnownDevice = BaseDevice & {
};
transportSessionOwner?: undefined;
transportDescriptorType?: typeof undefined;
bluetoothProps?: BluetoothDeviceProps;
};

export type UnknownDevice = BaseDevice & {
Expand All @@ -131,7 +126,6 @@ export type UnknownDevice = BaseDevice & {
availableTranslations?: typeof undefined;
transportSessionOwner?: string;
transportDescriptorType?: typeof undefined;
bluetoothProps?: BluetoothDeviceProps;
};

export type UnreadableDevice = BaseDevice & {
Expand All @@ -153,7 +147,6 @@ export type UnreadableDevice = BaseDevice & {
availableTranslations?: typeof undefined;
transportSessionOwner?: undefined;
transportDescriptorType: Descriptor['type'];
bluetoothProps?: BluetoothDeviceProps;
};

export type Device = KnownDevice | UnknownDevice | UnreadableDevice;
Expand Down
1 change: 0 additions & 1 deletion packages/transport/src/api/abstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export enum DEVICE_TYPE {
TypeT2 = 3,
TypeT2Boot = 4,
TypeEmulator = 5,
TypeBluetooth = 6,
}

type AccessLock = {
Expand Down
2 changes: 0 additions & 2 deletions packages/transport/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ export type Descriptor = Omit<DescriptorApiLevel, 'path'> & {
debugSession?: null | Session;
/** only reported by old bridge */
debug?: boolean;
/** only reported by transport-bluetooth */
uuid?: string;
};

export interface Logger {
Expand Down
22 changes: 11 additions & 11 deletions suite-native/state/src/extraDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ import { mergeDeepObject } from '@trezor/utils';

const deviceType = Device.isDevice ? 'device' : 'emulator';

// const transportsPerDeviceType = {
// device: Platform.select({
// ios: ['BridgeTransport'],
// android: [NativeUsbTransport],
// }),
// emulator: ['BridgeTransport'],
// } as const;
const transportsPerDeviceType = {
device: Platform.select({
ios: ['BridgeTransport'],
android: [NativeUsbTransport],
}),
emulator: ['BridgeTransport'],
} as const;

// let transports = transportsPerDeviceType[deviceType];
let transports = transportsPerDeviceType[deviceType];

// if (isBluetoothEnabled) {
const transports = [NativeTransportBLE];
// }
if (isBluetoothEnabled) {
transports = [NativeTransportBLE];
}

export const extraDependencies: ExtraDependencies = mergeDeepObject(extraDependenciesMock, {
selectors: {
Expand Down
Loading

0 comments on commit 2aff779

Please sign in to comment.