@onekeyfe/hd-core 0.3.21 → 0.3.23-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,18 @@ export declare const processTxRequest: ({ typedCall, request, data, chainId, sup
7
7
  chainId?: number | undefined;
8
8
  supportTrezor?: boolean | undefined;
9
9
  }) => Promise<EVMSignedTx>;
10
+ export declare const evmSignTx: ({ typedCall, addressN, tx, supportTrezor, }: {
11
+ typedCall: TypedCall;
12
+ addressN: number[];
13
+ tx: EVMTransaction;
14
+ supportTrezor?: boolean | undefined;
15
+ }) => Promise<EVMSignedTx>;
16
+ export declare const evmSignTxEip1559: ({ typedCall, addressN, tx, supportTrezor, }: {
17
+ typedCall: TypedCall;
18
+ addressN: number[];
19
+ tx: EVMTransactionEIP1559;
20
+ supportTrezor?: boolean | undefined;
21
+ }) => Promise<EVMSignedTx>;
10
22
  export declare const signTransaction: ({ typedCall, isEIP1559, addressN, tx, }: {
11
23
  addressN: number[];
12
24
  tx: EVMTransaction | EVMTransactionEIP1559;
@@ -1 +1 @@
1
- {"version":3,"file":"signTransaction.d.ts","sourceRoot":"","sources":["../../../../src/api/evm/latest/signTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,uBAAuB,EAEvB,SAAS,EACV,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAIpF,eAAO,MAAM,gBAAgB;eAOhB,SAAS;aACX,uBAAuB;UAC1B,MAAM;cACF,MAAM,GAAG,SAAS;;MAE1B,QAAQ,WAAW,CA6CtB,CAAC;AAiHF,eAAO,MAAM,eAAe;cAMhB,MAAM,EAAE;QACd,cAAc,GAAG,qBAAqB;eAC/B,OAAO;eACP,SAAS;0BAI4C,CAAC"}
1
+ {"version":3,"file":"signTransaction.d.ts","sourceRoot":"","sources":["../../../../src/api/evm/latest/signTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,uBAAuB,EAEvB,SAAS,EACV,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAIpF,eAAO,MAAM,gBAAgB;eAOhB,SAAS;aACX,uBAAuB;UAC1B,MAAM;cACF,MAAM,GAAG,SAAS;;MAE1B,QAAQ,WAAW,CA6CtB,CAAC;AAEF,eAAO,MAAM,SAAS;eAMT,SAAS;cACV,MAAM,EAAE;QACd,cAAc;;0BAgDnB,CAAC;AAEF,eAAO,MAAM,gBAAgB;eAMhB,SAAS;cACV,MAAM,EAAE;QACd,qBAAqB;;0BA4C1B,CAAC;AACF,eAAO,MAAM,eAAe;cAMhB,MAAM,EAAE;QACd,cAAc,GAAG,qBAAqB;eAC/B,OAAO;eACP,SAAS;0BAI4C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"signTransaction.d.ts","sourceRoot":"","sources":["../../../../src/api/evm/legacyV1/signTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyC,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAoFvE,eAAO,MAAM,eAAe;cAMhB,MAAM,EAAE;QACd,cAAc,GAAG,qBAAqB;eAC/B,OAAO;eACP,SAAS;mDAIoC,CAAC"}
1
+ {"version":3,"file":"signTransaction.d.ts","sourceRoot":"","sources":["../../../../src/api/evm/legacyV1/signTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAGvE,eAAO,MAAM,eAAe;cAMhB,MAAM,EAAE;QACd,cAAc,GAAG,qBAAqB;eAC/B,OAAO;eACP,SAAS;mDASiE,CAAC"}
@@ -1,5 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import EventEmitter from 'events';
3
+ import { LowlevelTransportSharedPlugin } from '@onekeyfe/hd-transport';
3
4
  import { CoreMessage } from '../events';
4
5
  import type { ConnectSettings } from '../types';
5
6
  import DeviceConnector from '../device/DeviceConnector';
@@ -11,5 +12,5 @@ export default class Core extends EventEmitter {
11
12
  }
12
13
  export declare const initCore: () => Core;
13
14
  export declare const initConnector: () => DeviceConnector;
14
- export declare const init: (settings: ConnectSettings, Transport: any) => Promise<Core | undefined>;
15
+ export declare const init: (settings: ConnectSettings, Transport: any, plugin?: LowlevelTransportSharedPlugin | undefined) => Promise<Core | undefined>;
15
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAqBlC,OAAO,EAEL,WAAW,EAWZ,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAE7D,OAAO,eAAe,MAAM,2BAA2B,CAAC;AA4BxD,eAAO,MAAM,OAAO,YAAmB,WAAW,iBAgRjD,CAAC;AAuMF,eAAO,MAAM,MAAM,0CAkBlB,CAAC;AAoJF,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,YAAY;IACtC,aAAa,CAAC,OAAO,EAAE,WAAW;IA8CxC,OAAO;CAGR;AAED,eAAO,MAAM,QAAQ,YAGpB,CAAC;AAEF,eAAO,MAAM,aAAa,uBAIzB,CAAC;AAMF,eAAO,MAAM,IAAI,aAAoB,eAAe,aAAa,GAAG,8BAmBnE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAY,6BAA6B,EAAoB,MAAM,wBAAwB,CAAC;AAoBnG,OAAO,EAEL,WAAW,EAWZ,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAE7D,OAAO,eAAe,MAAM,2BAA2B,CAAC;AA4BxD,eAAO,MAAM,OAAO,YAAmB,WAAW,iBAgRjD,CAAC;AAuMF,eAAO,MAAM,MAAM,0CAkBlB,CAAC;AAoJF,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,YAAY;IACtC,aAAa,CAAC,OAAO,EAAE,WAAW;IA8CxC,OAAO;CAGR;AAED,eAAO,MAAM,QAAQ,YAGpB,CAAC;AAEF,eAAO,MAAM,aAAa,uBAIzB,CAAC;AAMF,eAAO,MAAM,IAAI,aACL,eAAe,aACd,GAAG,kFAqBf,CAAC"}
@@ -1,5 +1,5 @@
1
- import { IDeviceModel, IDeviceType } from '../../types';
2
- import { MessageVersion } from '../../data-manager/DataManager';
1
+ import { IDeviceModel, IDeviceType } from '../types';
2
+ import { MessageVersion } from './DataManager';
3
3
  declare type DeviceVersionConfig = {
4
4
  [deviceType in IDeviceType | IDeviceModel]?: {
5
5
  minVersion: string;
@@ -8,4 +8,4 @@ declare type DeviceVersionConfig = {
8
8
  };
9
9
  export declare const PROTOBUF_MESSAGE_CONFIG: DeviceVersionConfig;
10
10
  export {};
11
- //# sourceMappingURL=index.d.ts.map
11
+ //# sourceMappingURL=MessagesConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessagesConfig.d.ts","sourceRoot":"","sources":["../../src/data-manager/MessagesConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,aAAK,mBAAmB,GAAG;KACxB,UAAU,IAAI,WAAW,GAAG,YAAY,CAAC,CAAC,EAAE;QAC3C,UAAU,EAAE,MAAM,CAAC;QACnB,cAAc,EAAE,cAAc,CAAC;KAChC,EAAE;CACJ,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,mBASrC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Transport } from '@onekeyfe/hd-transport';
1
+ import { LowlevelTransportSharedPlugin, Transport } from '@onekeyfe/hd-transport';
2
2
  import { MessageVersion } from './DataManager';
3
3
  import { Features } from '../types';
4
4
  export default class TransportManager {
@@ -7,10 +7,11 @@ export default class TransportManager {
7
7
  static currentMessages: JSON | Record<string, any>;
8
8
  static reactNativeInit: boolean;
9
9
  static messageVersion: MessageVersion;
10
+ static plugin: LowlevelTransportSharedPlugin | null;
10
11
  static load(): void;
11
12
  static configure(): Promise<void>;
12
13
  static reconfigure(features?: Features | undefined): Promise<void>;
13
- static setTransport(TransportConstructor: any): void;
14
+ static setTransport(TransportConstructor: any, plugin?: LowlevelTransportSharedPlugin): void;
14
15
  static getTransport(): Transport;
15
16
  static getDefaultMessages(): JSON | Record<string, any>;
16
17
  static getCurrentMessages(): JSON | Record<string, any>;
@@ -1 +1 @@
1
- {"version":3,"file":"TransportManager.d.ts","sourceRoot":"","sources":["../../src/data-manager/TransportManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAoB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAK5D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAWpC,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC;IAE5B,MAAM,CAAC,eAAe,EAAE,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEnD,MAAM,CAAC,eAAe,EAAE,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEnD,MAAM,CAAC,eAAe,UAAS;IAE/B,MAAM,CAAC,cAAc,EAAE,cAAc,CAAY;IAEjD,MAAM,CAAC,IAAI;WAOE,SAAS;WAyBT,WAAW,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS;IAsBxD,MAAM,CAAC,YAAY,CAAC,oBAAoB,EAAE,GAAG;IAY7C,MAAM,CAAC,YAAY;IAInB,MAAM,CAAC,kBAAkB;IAIzB,MAAM,CAAC,kBAAkB;IAIzB,MAAM,CAAC,iBAAiB;CAGzB"}
1
+ {"version":3,"file":"TransportManager.d.ts","sourceRoot":"","sources":["../../src/data-manager/TransportManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAElF,OAAoB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAK5D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAYpC,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC;IAE5B,MAAM,CAAC,eAAe,EAAE,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEnD,MAAM,CAAC,eAAe,EAAE,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEnD,MAAM,CAAC,eAAe,UAAS;IAE/B,MAAM,CAAC,cAAc,EAAE,cAAc,CAAY;IAEjD,MAAM,CAAC,MAAM,EAAE,6BAA6B,GAAG,IAAI,CAAQ;IAE3D,MAAM,CAAC,IAAI;WAOE,SAAS;WAiCT,WAAW,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS;IAsBxD,MAAM,CAAC,YAAY,CAAC,oBAAoB,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,6BAA6B;IAgBrF,MAAM,CAAC,YAAY;IAInB,MAAM,CAAC,kBAAkB;IAIzB,MAAM,CAAC,kBAAkB;IAIzB,MAAM,CAAC,iBAAiB;CAGzB"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import EventEmitter$1, { EventEmitter } from 'events';
2
2
  import * as _onekeyfe_hd_transport from '@onekeyfe/hd-transport';
3
- import { Messages, Success as Success$1, RecoveryDeviceType, SafetyCheckLevel, ResourceType, CipheredKeyValue as CipheredKeyValue$1, EthereumPublicKey, EthereumMessageSignature, Address, MultisigRedeemScriptType, InputScriptType, PublicKey, MessageSignature, PrevInput, TxOutputBinType, TxInput, TxOutputType, TxInputType, StarcoinAddress as StarcoinAddress$1, StarcoinPublicKey as StarcoinPublicKey$1, StarcoinMessageSignature, StarcoinSignedTx, NEMAddress as NEMAddress$1, NEMSignedTx, SolanaAddress as SolanaAddress$1, SolanaSignedTx as SolanaSignedTx$1, StellarAddress as StellarAddress$1, StellarSignedTx, TronAddress as TronAddress$1, UintType, TronResourceCode, TronSignedTx, TronMessageSignature, ConfluxAddress as ConfluxAddress$1, ConfluxMessageSignature, NearAddress as NearAddress$1, NearSignedTx, AptosAddress as AptosAddress$1, AptosMessageSignature as AptosMessageSignature$1, AptosSignedTx as AptosSignedTx$1, AlgorandAddress, AlgorandSignedTx, CosmosAddress as CosmosAddress$1, CosmosSignedTx as CosmosSignedTx$1, SuiAddress as SuiAddress$1, CardanoAddressParametersType, CardanoMessageSignature, FilecoinAddress as FilecoinAddress$1, FilecoinSignedTx as FilecoinSignedTx$1, PolkadotAddress as PolkadotAddress$1, PolkadotSignedTx as PolkadotSignedTx$1, KaspaAddress as KaspaAddress$1, OneKeyDeviceInfo, Transport, ChangeOutputScriptType } from '@onekeyfe/hd-transport';
3
+ import { Messages, LowlevelTransportSharedPlugin, Success as Success$1, RecoveryDeviceType, SafetyCheckLevel, ResourceType, CipheredKeyValue as CipheredKeyValue$1, EthereumPublicKey, EthereumMessageSignature, Address, MultisigRedeemScriptType, InputScriptType, PublicKey, MessageSignature, PrevInput, TxOutputBinType, TxInput, TxOutputType, TxInputType, StarcoinAddress as StarcoinAddress$1, StarcoinPublicKey as StarcoinPublicKey$1, StarcoinMessageSignature, StarcoinSignedTx, NEMAddress as NEMAddress$1, NEMSignedTx, SolanaAddress as SolanaAddress$1, SolanaSignedTx as SolanaSignedTx$1, StellarAddress as StellarAddress$1, StellarSignedTx, TronAddress as TronAddress$1, UintType, TronResourceCode, TronSignedTx, TronMessageSignature, ConfluxAddress as ConfluxAddress$1, ConfluxMessageSignature, NearAddress as NearAddress$1, NearSignedTx, AptosAddress as AptosAddress$1, AptosMessageSignature as AptosMessageSignature$1, AptosSignedTx as AptosSignedTx$1, AlgorandAddress, AlgorandSignedTx, CosmosAddress as CosmosAddress$1, CosmosSignedTx as CosmosSignedTx$1, SuiAddress as SuiAddress$1, CardanoAddressParametersType, CardanoMessageSignature, FilecoinAddress as FilecoinAddress$1, FilecoinSignedTx as FilecoinSignedTx$1, PolkadotAddress as PolkadotAddress$1, PolkadotSignedTx as PolkadotSignedTx$1, KaspaAddress as KaspaAddress$1, OneKeyDeviceInfo, Transport, ChangeOutputScriptType } from '@onekeyfe/hd-transport';
4
4
  export { Messages as PROTO } from '@onekeyfe/hd-transport';
5
5
  import { Deferred } from '@onekeyfe/hd-shared';
6
6
 
@@ -159,7 +159,7 @@ declare type ConnectSettings = {
159
159
  priority: number;
160
160
  trustedHost: boolean;
161
161
  supportedBrowser?: boolean;
162
- env: 'node' | 'web' | 'webextension' | 'electron' | 'react-native' | 'webusb';
162
+ env: 'node' | 'web' | 'webextension' | 'electron' | 'react-native' | 'webusb' | 'lowlevel';
163
163
  timestamp: number;
164
164
  isFrame?: boolean;
165
165
  preRelease?: boolean;
@@ -223,7 +223,7 @@ declare type RemoteConfigResponse = {
223
223
  bridge: AssetsMap['bridge'];
224
224
  } & DeviceTypeMap;
225
225
 
226
- declare function init$1(settings: Partial<ConnectSettings>, lowLevelApi?: LowLevelCoreApi): Promise<boolean>;
226
+ declare function init$1(settings: Partial<ConnectSettings>, lowLevelApi?: LowLevelCoreApi, pulgin?: LowlevelTransportSharedPlugin): Promise<boolean>;
227
227
  declare function updateSettings(settings: Partial<ConnectSettings>): Promise<boolean>;
228
228
 
229
229
  declare function getLogs(): Response<string[]>;
@@ -2237,7 +2237,7 @@ declare class Core extends EventEmitter$1 {
2237
2237
  handleMessage(message: CoreMessage): Promise<any>;
2238
2238
  dispose(): void;
2239
2239
  }
2240
- declare const init: (settings: ConnectSettings, Transport: any) => Promise<Core | undefined>;
2240
+ declare const init: (settings: ConnectSettings, Transport: any, plugin?: LowlevelTransportSharedPlugin | undefined) => Promise<Core | undefined>;
2241
2241
 
2242
2242
  declare const httpRequest: (url: string, type: string) => any;
2243
2243
  declare const getTimeStamp: () => number;
@@ -2330,6 +2330,7 @@ declare enum LoggerNames {
2330
2330
  HdCommonConnectSdk = "@onekey/common-connect-sdk",
2331
2331
  HdBleSdk = "@onekey/hd-ble-sdk",
2332
2332
  HdTransportHttp = "@onekey/hd-transport-http",
2333
+ HdTransportLowLevel = "@onekey/hd-transport-lowlevel",
2333
2334
  HdBleTransport = "@onekey/hd-ble-transport",
2334
2335
  Connect = "@onekey/connect",
2335
2336
  Iframe = "IFrame",
package/dist/index.js CHANGED
@@ -22497,6 +22497,7 @@ exports.LoggerNames = void 0;
22497
22497
  LoggerNames["HdCommonConnectSdk"] = "@onekey/common-connect-sdk";
22498
22498
  LoggerNames["HdBleSdk"] = "@onekey/hd-ble-sdk";
22499
22499
  LoggerNames["HdTransportHttp"] = "@onekey/hd-transport-http";
22500
+ LoggerNames["HdTransportLowLevel"] = "@onekey/hd-transport-lowlevel";
22500
22501
  LoggerNames["HdBleTransport"] = "@onekey/hd-ble-transport";
22501
22502
  LoggerNames["Connect"] = "@onekey/connect";
22502
22503
  LoggerNames["Iframe"] = "IFrame";
@@ -22514,6 +22515,7 @@ const LoggerMap = {
22514
22515
  [exports.LoggerNames.HdBleSdk]: initLog(exports.LoggerNames.HdBleSdk),
22515
22516
  [exports.LoggerNames.HdTransportHttp]: initLog(exports.LoggerNames.HdTransportHttp),
22516
22517
  [exports.LoggerNames.HdBleTransport]: initLog(exports.LoggerNames.HdBleTransport),
22518
+ [exports.LoggerNames.HdTransportLowLevel]: initLog(exports.LoggerNames.HdTransportLowLevel),
22517
22519
  [exports.LoggerNames.Connect]: initLog(exports.LoggerNames.Connect),
22518
22520
  [exports.LoggerNames.Iframe]: initLog(exports.LoggerNames.Iframe),
22519
22521
  [exports.LoggerNames.SendMessage]: initLog(exports.LoggerNames.SendMessage),
@@ -23505,6 +23507,7 @@ DevicePool.emitter = new events.exports();
23505
23507
  const Log$7 = getLogger(exports.LoggerNames.Transport);
23506
23508
  const BleLogger = getLogger(exports.LoggerNames.HdBleTransport);
23507
23509
  const HttpLogger = getLogger(exports.LoggerNames.HdTransportHttp);
23510
+ const LowLevelLogger = getLogger(exports.LoggerNames.HdTransportLowLevel);
23508
23511
  class TransportManager {
23509
23512
  static load() {
23510
23513
  Log$7.debug('transport manager load');
@@ -23526,6 +23529,12 @@ class TransportManager {
23526
23529
  Log$7.debug('React Native Do Not Initializing transports');
23527
23530
  }
23528
23531
  }
23532
+ else if (env === 'lowlevel') {
23533
+ if (!this.plugin) {
23534
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportNotConfigured, 'Lowlevel transport mast have plugin');
23535
+ }
23536
+ yield this.transport.init(LowLevelLogger, DevicePool.emitter, this.plugin);
23537
+ }
23529
23538
  else {
23530
23539
  yield this.transport.init(HttpLogger);
23531
23540
  }
@@ -23559,7 +23568,7 @@ class TransportManager {
23559
23568
  }
23560
23569
  });
23561
23570
  }
23562
- static setTransport(TransportConstructor) {
23571
+ static setTransport(TransportConstructor, plugin) {
23563
23572
  const env = DataManager.getSettings('env');
23564
23573
  if (env === 'react-native') {
23565
23574
  this.transport = new TransportConstructor({ scanTimeout: 3000 });
@@ -23567,6 +23576,10 @@ class TransportManager {
23567
23576
  else {
23568
23577
  this.transport = new TransportConstructor();
23569
23578
  }
23579
+ if (plugin) {
23580
+ this.plugin = plugin;
23581
+ Log$7.debug('set transport plugin: ', this.plugin);
23582
+ }
23570
23583
  Log$7.debug('set transport: ', this.transport);
23571
23584
  }
23572
23585
  static getTransport() {
@@ -23584,6 +23597,7 @@ class TransportManager {
23584
23597
  }
23585
23598
  TransportManager.reactNativeInit = false;
23586
23599
  TransportManager.messageVersion = 'latest';
23600
+ TransportManager.plugin = null;
23587
23601
 
23588
23602
  const assertType = (res, resType) => {
23589
23603
  const splitResTypes = Array.isArray(resType) ? resType : resType.split('|');
@@ -27133,7 +27147,7 @@ const processTxRequest = ({ typedCall, request, data, chainId, supportTrezor, })
27133
27147
  supportTrezor,
27134
27148
  });
27135
27149
  });
27136
- const evmSignTx$1 = ({ typedCall, addressN, tx, supportTrezor, }) => __awaiter(void 0, void 0, void 0, function* () {
27150
+ const evmSignTx = ({ typedCall, addressN, tx, supportTrezor, }) => __awaiter(void 0, void 0, void 0, function* () {
27137
27151
  const { to, value, gasPrice, gasLimit, nonce, data, chainId, txType } = tx;
27138
27152
  const length = data == null ? 0 : data.length / 2;
27139
27153
  const [first, rest] = cutString(data, 1024 * 2);
@@ -27167,7 +27181,7 @@ const evmSignTx$1 = ({ typedCall, addressN, tx, supportTrezor, }) => __awaiter(v
27167
27181
  supportTrezor,
27168
27182
  });
27169
27183
  });
27170
- const evmSignTxEip1559$1 = ({ typedCall, addressN, tx, supportTrezor, }) => __awaiter(void 0, void 0, void 0, function* () {
27184
+ const evmSignTxEip1559 = ({ typedCall, addressN, tx, supportTrezor, }) => __awaiter(void 0, void 0, void 0, function* () {
27171
27185
  const { to, value, gasLimit, nonce, data, chainId, maxFeePerGas, maxPriorityFeePerGas, accessList, } = tx;
27172
27186
  const length = data == null ? 0 : data.length / 2;
27173
27187
  const [first, rest] = cutString(data, 1024 * 2);
@@ -27198,59 +27212,19 @@ const evmSignTxEip1559$1 = ({ typedCall, addressN, tx, supportTrezor, }) => __aw
27198
27212
  });
27199
27213
  const signTransaction$1 = ({ typedCall, isEIP1559, addressN, tx, }) => __awaiter(void 0, void 0, void 0, function* () {
27200
27214
  return isEIP1559
27201
- ? evmSignTxEip1559$1({ typedCall, addressN, tx: tx })
27202
- : evmSignTx$1({ typedCall, addressN, tx: tx });
27215
+ ? evmSignTxEip1559({ typedCall, addressN, tx: tx })
27216
+ : evmSignTx({ typedCall, addressN, tx: tx });
27203
27217
  });
27204
27218
 
27205
- const evmSignTx = (typedCall, addressN, tx) => __awaiter(void 0, void 0, void 0, function* () {
27206
- const { to, value, gasPrice, gasLimit, nonce, data, chainId, txType } = tx;
27207
- const length = data == null ? 0 : data.length / 2;
27208
- const [first, rest] = cutString(data, 1024 * 2);
27209
- let message = {
27210
- address_n: addressN,
27211
- nonce: stripHexStartZeroes(nonce),
27212
- gas_price: stripHexStartZeroes(gasPrice),
27213
- gas_limit: stripHexStartZeroes(gasLimit),
27214
- to,
27215
- value: stripHexStartZeroes(value),
27216
- chain_id: chainId,
27217
- };
27218
- if (length !== 0) {
27219
- message = Object.assign(Object.assign({}, message), { data_length: length, data_initial_chunk: first });
27220
- }
27221
- if (txType !== null) {
27222
- message = Object.assign(Object.assign({}, message), { tx_type: txType });
27223
- }
27224
- const response = yield typedCall('EthereumSignTx', 'EthereumTxRequest', message);
27225
- return processTxRequest({ typedCall, request: response.message, data: rest, chainId });
27226
- });
27227
- const evmSignTxEip1559 = (typedCall, addressN, tx) => __awaiter(void 0, void 0, void 0, function* () {
27228
- const { to, value, gasLimit, nonce, data, chainId, maxFeePerGas, maxPriorityFeePerGas, accessList, } = tx;
27229
- const length = data == null ? 0 : data.length / 2;
27230
- const [first, rest] = cutString(data, 1024 * 2);
27231
- const message = {
27232
- address_n: addressN,
27233
- nonce: stripHexStartZeroes(nonce),
27234
- max_gas_fee: stripHexStartZeroes(maxFeePerGas),
27235
- max_priority_fee: stripHexStartZeroes(maxPriorityFeePerGas),
27236
- gas_limit: stripHexStartZeroes(gasLimit),
27237
- to,
27238
- value: stripHexStartZeroes(value),
27239
- data_length: length,
27240
- data_initial_chunk: first,
27241
- chain_id: chainId,
27242
- access_list: (accessList || []).map(a => ({
27243
- address: a.address,
27244
- storage_keys: a.storageKeys,
27245
- })),
27246
- };
27247
- const response = yield typedCall('EthereumSignTxEIP1559', 'EthereumTxRequest', message);
27248
- return processTxRequest({ typedCall, request: response.message, data: rest });
27249
- });
27250
27219
  const signTransaction = ({ typedCall, isEIP1559, addressN, tx, }) => __awaiter(void 0, void 0, void 0, function* () {
27251
27220
  return isEIP1559
27252
- ? evmSignTxEip1559(typedCall, addressN, tx)
27253
- : evmSignTx(typedCall, addressN, tx);
27221
+ ? evmSignTxEip1559({
27222
+ typedCall,
27223
+ addressN,
27224
+ tx: tx,
27225
+ supportTrezor: true,
27226
+ })
27227
+ : evmSignTx({ typedCall, addressN, tx: tx, supportTrezor: true });
27254
27228
  });
27255
27229
 
27256
27230
  class EVMSignTransaction extends BaseMethod {
@@ -32046,14 +32020,14 @@ const initConnector = () => {
32046
32020
  DevicePool.emitter.on(DEVICE.DISCONNECT, onDeviceDisconnectHandler);
32047
32021
  return _connector;
32048
32022
  };
32049
- const initTransport = (Transport) => {
32050
- TransportManager.setTransport(Transport);
32023
+ const initTransport = (Transport, plugin) => {
32024
+ TransportManager.setTransport(Transport, plugin);
32051
32025
  };
32052
- const init = (settings, Transport) => __awaiter(void 0, void 0, void 0, function* () {
32026
+ const init = (settings, Transport, plugin) => __awaiter(void 0, void 0, void 0, function* () {
32053
32027
  try {
32054
32028
  try {
32055
32029
  yield DataManager.load(settings);
32056
- initTransport(Transport);
32030
+ initTransport(Transport, plugin);
32057
32031
  }
32058
32032
  catch (_b) {
32059
32033
  Log.error('DataManager.load error');
@@ -1,5 +1,6 @@
1
+ import type { LowlevelTransportSharedPlugin } from '@onekeyfe/hd-transport';
1
2
  import { LowLevelCoreApi } from '../../lowLevelInject';
2
3
  import type { ConnectSettings } from '../settings';
3
- export declare function init(settings: Partial<ConnectSettings>, lowLevelApi?: LowLevelCoreApi): Promise<boolean>;
4
+ export declare function init(settings: Partial<ConnectSettings>, lowLevelApi?: LowLevelCoreApi, pulgin?: LowlevelTransportSharedPlugin): Promise<boolean>;
4
5
  export declare function updateSettings(settings: Partial<ConnectSettings>): Promise<boolean>;
5
6
  //# sourceMappingURL=init.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/types/api/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,CAAC,OAAO,UAAU,IAAI,CAC1B,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,EAClC,WAAW,CAAC,EAAE,eAAe,GAC5B,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/types/api/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,CAAC,OAAO,UAAU,IAAI,CAC1B,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,EAClC,WAAW,CAAC,EAAE,eAAe,EAC7B,MAAM,CAAC,EAAE,6BAA6B,GACrC,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC"}
@@ -12,7 +12,7 @@ export declare type ConnectSettings = {
12
12
  priority: number;
13
13
  trustedHost: boolean;
14
14
  supportedBrowser?: boolean;
15
- env: 'node' | 'web' | 'webextension' | 'electron' | 'react-native' | 'webusb';
15
+ env: 'node' | 'web' | 'webextension' | 'electron' | 'react-native' | 'webusb' | 'lowlevel';
16
16
  timestamp: number;
17
17
  isFrame?: boolean;
18
18
  preRelease?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/types/settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,oBAAY,eAAe,GAAG;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,GAAG,EAAE,MAAM,GAAG,KAAK,GAAG,cAAc,GAAG,UAAU,GAAG,cAAc,GAAG,QAAQ,CAAC;IAC9E,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,oBAAY,aAAa,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAErD,oBAAY,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAGxC,oBAAY,oBAAoB,GAAG;IACjC,QAAQ,EAAE,OAAO,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IAEZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iBAAiB,CAAC,EAAE,aAA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Y,oBAAoB,GAAG;IACjC,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;CAC7B,GAAG,aAAa,CAAC"}
@@ -32,6 +32,7 @@ export declare enum LoggerNames {
32
32
  HdCommonConnectSdk = "@onekey/common-connect-sdk",
33
33
  HdBleSdk = "@onekey/hd-ble-sdk",
34
34
  HdTransportHttp = "@onekey/hd-transport-http",
35
+ HdTransportLowLevel = "@onekey/hd-transport-lowlevel",
35
36
  HdBleTransport = "@onekey/hd-ble-transport",
36
37
  Connect = "@onekey/connect",
37
38
  Iframe = "IFrame",
@@ -49,6 +50,7 @@ export declare const LoggerMap: {
49
50
  "@onekey/hd-ble-sdk": Log;
50
51
  "@onekey/hd-transport-http": Log;
51
52
  "@onekey/hd-ble-transport": Log;
53
+ "@onekey/hd-transport-lowlevel": Log;
52
54
  "@onekey/connect": Log;
53
55
  IFrame: Log;
54
56
  "[SendMessage]": Log;
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC,aAAK,UAAU,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,GAAG,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAMF,cAAM,GAAG;IACP,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,EAAE,OAAO,CAAC;IAEjB,QAAQ,EAAE,UAAU,EAAE,CAAC;gBAEX,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAM5C,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAYxD,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IASlB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IASpB,I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M5C,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAYxD,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IASlB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IASpB,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IASnB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;CAQrB;AAID,eAAO,MAAM,OAAO,WAAY,MAAM,uCAIrC,CAAC;AAEF,eAAO,MAAM,SAAS,yCAIrB,CAAC;AAEF,eAAO,MAAM,iBAAiB,WAAY,MAAM,WAAW,OAAO,SAIjE,CAAC;AAEF,eAAO,MAAM,MAAM,oBAOlB,CAAC;AAEF,eAAO,MAAM,oBAAoB,4BAA6B,WAAW,KAAK,IAAI,SAEjF,CAAC;AAuCF,oBAAY,WAAW;IACrB,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,cAAc,mBAAmB;IACjC,eAAe,oBAAoB;IACnC,UAAU,eAAe;IACzB,UAAU,eAAe;IACzB,kBAAkB,+BAA+B;IACjD,QAAQ,uBAAuB;IAC/B,eAAe,8BAA8B;IAC7C,mBAAmB,kCAAkC;IACrD,cAAc,6BAA6B;IAC3C,OAAO,oBAAoB;IAC3B,MAAM,WAAW;IACjB,WAAW,kBAAkB;IAC7B,MAAM,aAAa;CACpB;AAED,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;CAiBrB,CAAC;AAEF,eAAO,MAAM,SAAS,QAAS,WAAW,QAAmB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "0.3.21",
3
+ "version": "0.3.23-alpha.0",
4
4
  "description": "> TODO: description",
5
5
  "author": "OneKey",
6
6
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
@@ -25,8 +25,8 @@
25
25
  "url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
26
26
  },
27
27
  "dependencies": {
28
- "@onekeyfe/hd-shared": "^0.3.21",
29
- "@onekeyfe/hd-transport": "^0.3.21",
28
+ "@onekeyfe/hd-shared": "^0.3.23-alpha.0",
29
+ "@onekeyfe/hd-transport": "^0.3.23-alpha.0",
30
30
  "axios": "^0.27.2",
31
31
  "bignumber.js": "^9.0.2",
32
32
  "bytebuffer": "^5.0.1",
@@ -44,5 +44,5 @@
44
44
  "@types/semver": "^7.3.9",
45
45
  "ripple-keypairs": "^1.1.4"
46
46
  },
47
- "gitHead": "7d052f9affce1324c5585ebd918d4ce3bc275406"
47
+ "gitHead": "da0fd219f855c9883ad308fa839cf379b6107c93"
48
48
  }
@@ -69,7 +69,7 @@ export const processTxRequest = async ({
69
69
  });
70
70
  };
71
71
 
72
- const evmSignTx = async ({
72
+ export const evmSignTx = async ({
73
73
  typedCall,
74
74
  addressN,
75
75
  tx,
@@ -127,7 +127,7 @@ const evmSignTx = async ({
127
127
  });
128
128
  };
129
129
 
130
- const evmSignTxEip1559 = async ({
130
+ export const evmSignTxEip1559 = async ({
131
131
  typedCall,
132
132
  addressN,
133
133
  tx,
@@ -1,88 +1,7 @@
1
- import { EthereumSignTx, EthereumSignTxEIP1559, TypedCall } from '@onekeyfe/hd-transport';
1
+ import { TypedCall } from '@onekeyfe/hd-transport';
2
2
  import { EVMTransaction, EVMTransactionEIP1559 } from '../../../types';
3
- import { cutString } from '../../helpers/stringUtils';
4
- import { stripHexStartZeroes } from '../../helpers/hexUtils';
5
- import { processTxRequest } from '../latest/signTransaction';
3
+ import { evmSignTx, evmSignTxEip1559 } from '../latest/signTransaction';
6
4
 
7
- const evmSignTx = async (typedCall: TypedCall, addressN: number[], tx: EVMTransaction) => {
8
- const { to, value, gasPrice, gasLimit, nonce, data, chainId, txType } = tx;
9
-
10
- const length = data == null ? 0 : data.length / 2;
11
-
12
- const [first, rest] = cutString(data, 1024 * 2);
13
-
14
- let message: EthereumSignTx = {
15
- address_n: addressN,
16
- nonce: stripHexStartZeroes(nonce),
17
- gas_price: stripHexStartZeroes(gasPrice),
18
- gas_limit: stripHexStartZeroes(gasLimit),
19
- to,
20
- value: stripHexStartZeroes(value),
21
- chain_id: chainId,
22
- };
23
-
24
- if (length !== 0) {
25
- message = {
26
- ...message,
27
- data_length: length,
28
- data_initial_chunk: first,
29
- };
30
- }
31
-
32
- if (txType !== null) {
33
- message = {
34
- ...message,
35
- tx_type: txType,
36
- };
37
- }
38
-
39
- const response = await typedCall('EthereumSignTx', 'EthereumTxRequest', message);
40
-
41
- return processTxRequest({ typedCall, request: response.message, data: rest, chainId });
42
- };
43
-
44
- const evmSignTxEip1559 = async (
45
- typedCall: TypedCall,
46
- addressN: number[],
47
- tx: EVMTransactionEIP1559
48
- ) => {
49
- const {
50
- to,
51
- value,
52
- gasLimit,
53
- nonce,
54
- data,
55
- chainId,
56
- maxFeePerGas,
57
- maxPriorityFeePerGas,
58
- accessList,
59
- } = tx;
60
-
61
- const length = data == null ? 0 : data.length / 2;
62
-
63
- const [first, rest] = cutString(data, 1024 * 2);
64
-
65
- const message: EthereumSignTxEIP1559 = {
66
- address_n: addressN,
67
- nonce: stripHexStartZeroes(nonce),
68
- max_gas_fee: stripHexStartZeroes(maxFeePerGas),
69
- max_priority_fee: stripHexStartZeroes(maxPriorityFeePerGas),
70
- gas_limit: stripHexStartZeroes(gasLimit),
71
- to,
72
- value: stripHexStartZeroes(value),
73
- data_length: length,
74
- data_initial_chunk: first,
75
- chain_id: chainId,
76
- access_list: (accessList || []).map(a => ({
77
- address: a.address,
78
- storage_keys: a.storageKeys,
79
- })),
80
- };
81
-
82
- const response = await typedCall('EthereumSignTxEIP1559', 'EthereumTxRequest', message);
83
-
84
- return processTxRequest({ typedCall, request: response.message, data: rest });
85
- };
86
5
  export const signTransaction = async ({
87
6
  typedCall,
88
7
  isEIP1559,
@@ -95,5 +14,10 @@ export const signTransaction = async ({
95
14
  typedCall: TypedCall;
96
15
  }) =>
97
16
  isEIP1559
98
- ? evmSignTxEip1559(typedCall, addressN, tx as EVMTransactionEIP1559)
99
- : evmSignTx(typedCall, addressN, tx as EVMTransaction);
17
+ ? evmSignTxEip1559({
18
+ typedCall,
19
+ addressN,
20
+ tx: tx as EVMTransactionEIP1559,
21
+ supportTrezor: true,
22
+ })
23
+ : evmSignTx({ typedCall, addressN, tx: tx as EVMTransaction, supportTrezor: true });
package/src/core/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import semver from 'semver';
2
2
  import EventEmitter from 'events';
3
- import { Features, OneKeyDeviceInfo } from '@onekeyfe/hd-transport';
3
+ import { Features, LowlevelTransportSharedPlugin, OneKeyDeviceInfo } from '@onekeyfe/hd-transport';
4
4
  import {
5
5
  createDeferred,
6
6
  Deferred,
@@ -765,15 +765,19 @@ export const initConnector = () => {
765
765
  return _connector;
766
766
  };
767
767
 
768
- const initTransport = (Transport: any) => {
769
- TransportManager.setTransport(Transport);
768
+ const initTransport = (Transport: any, plugin?: LowlevelTransportSharedPlugin) => {
769
+ TransportManager.setTransport(Transport, plugin);
770
770
  };
771
771
 
772
- export const init = async (settings: ConnectSettings, Transport: any) => {
772
+ export const init = async (
773
+ settings: ConnectSettings,
774
+ Transport: any,
775
+ plugin?: LowlevelTransportSharedPlugin
776
+ ) => {
773
777
  try {
774
778
  try {
775
779
  await DataManager.load(settings);
776
- initTransport(Transport);
780
+ initTransport(Transport, plugin);
777
781
  } catch {
778
782
  Log.error('DataManager.load error');
779
783
  }
@@ -1,5 +1,5 @@
1
- import { IDeviceModel, IDeviceType } from '../../types';
2
- import { MessageVersion } from '../../data-manager/DataManager';
1
+ import { IDeviceModel, IDeviceType } from '../types';
2
+ import { MessageVersion } from './DataManager';
3
3
 
4
4
  type DeviceVersionConfig = {
5
5
  [deviceType in IDeviceType | IDeviceModel]?: {
@@ -1,4 +1,4 @@
1
- import { Transport } from '@onekeyfe/hd-transport';
1
+ import { LowlevelTransportSharedPlugin, Transport } from '@onekeyfe/hd-transport';
2
2
  import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
3
3
  import DataManager, { MessageVersion } from './DataManager';
4
4
  import { getLogger, LoggerNames } from '../utils';
@@ -10,6 +10,7 @@ import { Features } from '../types';
10
10
  const Log = getLogger(LoggerNames.Transport);
11
11
  const BleLogger = getLogger(LoggerNames.HdBleTransport);
12
12
  const HttpLogger = getLogger(LoggerNames.HdTransportHttp);
13
+ const LowLevelLogger = getLogger(LoggerNames.HdTransportLowLevel);
13
14
 
14
15
  /**
15
16
  * transport 在同一个环境中只会存在一个
@@ -27,6 +28,8 @@ export default class TransportManager {
27
28
 
28
29
  static messageVersion: MessageVersion = 'latest';
29
30
 
31
+ static plugin: LowlevelTransportSharedPlugin | null = null;
32
+
30
33
  static load() {
31
34
  Log.debug('transport manager load');
32
35
  this.defaultMessages = DataManager.getProtobufMessages();
@@ -45,6 +48,14 @@ export default class TransportManager {
45
48
  } else {
46
49
  Log.debug('React Native Do Not Initializing transports');
47
50
  }
51
+ } else if (env === 'lowlevel') {
52
+ if (!this.plugin) {
53
+ throw ERRORS.TypedError(
54
+ HardwareErrorCode.TransportNotConfigured,
55
+ 'Lowlevel transport mast have plugin'
56
+ );
57
+ }
58
+ await this.transport.init(LowLevelLogger, DevicePool.emitter, this.plugin);
48
59
  } else {
49
60
  await this.transport.init(HttpLogger);
50
61
  }
@@ -81,7 +92,7 @@ export default class TransportManager {
81
92
  }
82
93
  }
83
94
 
84
- static setTransport(TransportConstructor: any) {
95
+ static setTransport(TransportConstructor: any, plugin?: LowlevelTransportSharedPlugin) {
85
96
  const env = DataManager.getSettings('env');
86
97
  if (env === 'react-native') {
87
98
  /** Actually initializes the ReactNativeTransport */
@@ -90,6 +101,10 @@ export default class TransportManager {
90
101
  /** Actually initializes the HttpTransport */
91
102
  this.transport = new TransportConstructor() as unknown as Transport;
92
103
  }
104
+ if (plugin) {
105
+ this.plugin = plugin;
106
+ Log.debug('set transport plugin: ', this.plugin);
107
+ }
93
108
  Log.debug('set transport: ', this.transport);
94
109
  }
95
110
 
@@ -1,9 +1,11 @@
1
+ import type { LowlevelTransportSharedPlugin } from '@onekeyfe/hd-transport';
1
2
  import { LowLevelCoreApi } from '../../lowLevelInject';
2
3
  import type { ConnectSettings } from '../settings';
3
4
 
4
5
  export declare function init(
5
6
  settings: Partial<ConnectSettings>,
6
- lowLevelApi?: LowLevelCoreApi
7
+ lowLevelApi?: LowLevelCoreApi,
8
+ pulgin?: LowlevelTransportSharedPlugin
7
9
  ): Promise<boolean>;
8
10
 
9
11
  export declare function updateSettings(settings: Partial<ConnectSettings>): Promise<boolean>;
@@ -14,7 +14,7 @@ export type ConnectSettings = {
14
14
  priority: number;
15
15
  trustedHost: boolean;
16
16
  supportedBrowser?: boolean;
17
- env: 'node' | 'web' | 'webextension' | 'electron' | 'react-native' | 'webusb';
17
+ env: 'node' | 'web' | 'webextension' | 'electron' | 'react-native' | 'webusb' | 'lowlevel';
18
18
  timestamp: number;
19
19
  isFrame?: boolean;
20
20
  preRelease?: boolean;
@@ -11,7 +11,7 @@ import type {
11
11
  } from '../types';
12
12
  import { DeviceTypeToModels } from '../types';
13
13
  import DataManager, { MessageVersion } from '../data-manager/DataManager';
14
- import { PROTOBUF_MESSAGE_CONFIG } from '../data/messages-config';
14
+ import { PROTOBUF_MESSAGE_CONFIG } from '../data-manager/MessagesConfig';
15
15
 
16
16
  export const getDeviceModel = (features?: Features): IDeviceModel => {
17
17
  if (!features || typeof features !== 'object') {
@@ -155,6 +155,7 @@ export enum LoggerNames {
155
155
  HdCommonConnectSdk = '@onekey/common-connect-sdk',
156
156
  HdBleSdk = '@onekey/hd-ble-sdk',
157
157
  HdTransportHttp = '@onekey/hd-transport-http',
158
+ HdTransportLowLevel = '@onekey/hd-transport-lowlevel',
158
159
  HdBleTransport = '@onekey/hd-ble-transport',
159
160
  Connect = '@onekey/connect',
160
161
  Iframe = 'IFrame',
@@ -173,6 +174,7 @@ export const LoggerMap = {
173
174
  [LoggerNames.HdBleSdk]: initLog(LoggerNames.HdBleSdk),
174
175
  [LoggerNames.HdTransportHttp]: initLog(LoggerNames.HdTransportHttp),
175
176
  [LoggerNames.HdBleTransport]: initLog(LoggerNames.HdBleTransport),
177
+ [LoggerNames.HdTransportLowLevel]: initLog(LoggerNames.HdTransportLowLevel),
176
178
  [LoggerNames.Connect]: initLog(LoggerNames.Connect),
177
179
  [LoggerNames.Iframe]: initLog(LoggerNames.Iframe),
178
180
  [LoggerNames.SendMessage]: initLog(LoggerNames.SendMessage),
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/data/messages-config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,aAAK,mBAAmB,GAAG;KACxB,UAAU,IAAI,WAAW,GAAG,YAAY,CAAC,CAAC,EAAE;QAC3C,UAAU,EAAE,MAAM,CAAC;QACnB,cAAc,EAAE,cAAc,CAAC;KAChC,EAAE;CACJ,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,mBASrC,CAAC"}