@onekeyfe/hd-core 0.2.49-alpha.0 → 0.2.49
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.
- package/dist/api/stellar/StellarSignTransaction.d.ts +1 -1
- package/dist/index.d.ts +6 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +152 -198
- package/dist/inject.d.ts +0 -1
- package/dist/inject.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +0 -1
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/init.d.ts +1 -2
- package/dist/types/api/init.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/cardano/CardanoGetAddress.ts +1 -1
- package/src/api/cardano/CardanoGetPublicKey.ts +1 -1
- package/src/api/cardano/CardanoSignMessage.ts +1 -1
- package/src/api/cardano/CardanoSignTransaction.ts +1 -1
- package/src/index.ts +0 -28
- package/src/inject.ts +187 -203
- package/src/types/api/index.ts +0 -1
- package/src/types/api/init.ts +1 -5
- package/dist/lowLevelInject.d.ts +0 -20
- package/dist/lowLevelInject.d.ts.map +0 -1
- package/dist/topLevelInject.d.ts +0 -7
- package/dist/topLevelInject.d.ts.map +0 -1
- package/src/lowLevelInject.ts +0 -52
- package/src/topLevelInject.ts +0 -55
package/src/topLevelInject.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import EventEmitter from 'events';
|
|
2
|
-
import { CoreApi } from './types/api';
|
|
3
|
-
import { createCoreApi } from './inject';
|
|
4
|
-
import type { LowLevelCoreApi } from './lowLevelInject';
|
|
5
|
-
|
|
6
|
-
export interface TopLevelInjectApi {
|
|
7
|
-
init: CoreApi['init'];
|
|
8
|
-
call: CoreApi['call'];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const eventEmitter = new EventEmitter();
|
|
12
|
-
|
|
13
|
-
const EmptyFN = () => {};
|
|
14
|
-
|
|
15
|
-
export const topLevelInject = () => {
|
|
16
|
-
let lowLevelApi: LowLevelCoreApi | undefined;
|
|
17
|
-
const call = (params: any) => {
|
|
18
|
-
if (!lowLevelApi) return Promise.resolve(undefined);
|
|
19
|
-
return lowLevelApi.call(params);
|
|
20
|
-
};
|
|
21
|
-
const api: CoreApi = {
|
|
22
|
-
on: <T extends string, P extends (...args: any[]) => any>(type: T, fn: P) => {
|
|
23
|
-
eventEmitter.on(type, fn);
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
emit: (eventName: string, ...args: any[]) => {
|
|
27
|
-
eventEmitter.emit(eventName, ...args);
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
off: (type, fn) => {
|
|
31
|
-
eventEmitter.emit(type, fn);
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
init: (settings, hardwareLowLeverApi) => {
|
|
35
|
-
lowLevelApi = hardwareLowLeverApi;
|
|
36
|
-
return lowLevelApi?.init(settings) ?? Promise.resolve(false);
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
call,
|
|
40
|
-
|
|
41
|
-
...createCoreApi(call),
|
|
42
|
-
|
|
43
|
-
removeAllListeners: type => {
|
|
44
|
-
eventEmitter.removeAllListeners(type);
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
dispose: lowLevelApi?.dispose ?? EmptyFN,
|
|
48
|
-
|
|
49
|
-
uiResponse: lowLevelApi?.uiResponse ?? EmptyFN,
|
|
50
|
-
|
|
51
|
-
cancel: lowLevelApi?.cancel ?? EmptyFN,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
return api;
|
|
55
|
-
};
|