@onekeyfe/hd-core 0.0.8 → 0.1.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.
- package/dist/api/BaseMethod.d.ts +4 -0
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CipherKeyValue.d.ts +9 -0
- package/dist/api/CipherKeyValue.d.ts.map +1 -0
- package/dist/api/FirmwareUpdate.d.ts +14 -0
- package/dist/api/FirmwareUpdate.d.ts.map +1 -0
- package/dist/api/device/DeviceRebootToBootloader.d.ts +8 -0
- package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessageEIP712.d.ts +5 -0
- package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTransaction.d.ts +5 -0
- package/dist/api/evm/EVMSignTransaction.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts +7 -1
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +33 -0
- package/dist/api/firmware/getBinary.d.ts.map +1 -0
- package/dist/api/firmware/uploadFirmware.d.ts +8 -0
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -0
- package/dist/api/helpers/hexUtils.d.ts.map +1 -1
- package/dist/api/index.d.ts +8 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/nem/NEMGetAddress.d.ts +9 -0
- package/dist/api/nem/NEMGetAddress.d.ts.map +1 -0
- package/dist/api/nem/NEMSignTransaction.d.ts +20 -0
- package/dist/api/nem/NEMSignTransaction.d.ts.map +1 -0
- package/dist/api/solana/SolGetAddress.d.ts +9 -0
- package/dist/api/solana/SolGetAddress.d.ts.map +1 -0
- package/dist/api/solana/SolSignTransaction.d.ts +17 -0
- package/dist/api/solana/SolSignTransaction.d.ts.map +1 -0
- package/dist/api/stellar/StellarGetAddress.d.ts +9 -0
- package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -0
- package/dist/api/stellar/StellarSignTransaction.d.ts +335 -0
- package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -0
- package/dist/constants/errors.d.ts +1 -0
- package/dist/constants/errors.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data/version.d.ts +1 -1
- package/dist/data/version.d.ts.map +1 -1
- package/dist/device/Device.d.ts +1 -0
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +1 -0
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +9 -1
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +364 -5
- package/dist/index.js +845 -21
- package/dist/inject.d.ts.map +1 -1
- package/dist/types/api/cipherKeyValue.d.ts +19 -0
- package/dist/types/api/cipherKeyValue.d.ts.map +1 -0
- package/dist/types/api/export.d.ts +7 -0
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +13 -0
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -0
- package/dist/types/api/index.d.ts +16 -0
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/nemGetAddress.d.ts +15 -0
- package/dist/types/api/nemGetAddress.d.ts.map +1 -0
- package/dist/types/api/nemSignTransaction.d.ts +93 -0
- package/dist/types/api/nemSignTransaction.d.ts.map +1 -0
- package/dist/types/api/solGetAddress.d.ts +14 -0
- package/dist/types/api/solGetAddress.d.ts.map +1 -0
- package/dist/types/api/solSignTransaction.d.ts +14 -0
- package/dist/types/api/solSignTransaction.d.ts.map +1 -0
- package/dist/types/api/stellarGetAddress.d.ts +14 -0
- package/dist/types/api/stellarGetAddress.d.ts.map +1 -0
- package/dist/types/api/stellarSignTransaction.d.ts +130 -0
- package/dist/types/api/stellarSignTransaction.d.ts.map +1 -0
- package/dist/types/device.d.ts +45 -0
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/firmware.d.ts +2 -1
- package/dist/types/firmware.d.ts.map +1 -1
- package/dist/types/params.d.ts +3 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/utils/assets.d.ts +1 -1
- package/dist/utils/assets.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +49 -2
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/networkUtils.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/api/BaseMethod.ts +9 -0
- package/src/api/CipherKeyValue.ts +66 -0
- package/src/api/FirmwareUpdate.ts +78 -0
- package/src/api/device/DeviceRebootToBootloader.ts +11 -0
- package/src/api/evm/EVMSignMessageEIP712.ts +8 -0
- package/src/api/evm/EVMSignTransaction.ts +15 -0
- package/src/api/evm/EVMSignTypedData.ts +55 -15
- package/src/api/firmware/getBinary.ts +46 -0
- package/src/api/firmware/uploadFirmware.ts +72 -0
- package/src/api/helpers/hexUtils.ts +0 -1
- package/src/api/index.ts +12 -0
- package/src/api/nem/NEMGetAddress.ts +61 -0
- package/src/api/nem/NEMSignTransaction.ts +246 -0
- package/src/api/solana/SolGetAddress.ts +59 -0
- package/src/api/solana/SolSignTransaction.ts +69 -0
- package/src/api/stellar/StellarGetAddress.ts +59 -0
- package/src/api/stellar/StellarSignTransaction.ts +213 -0
- package/src/constants/errors.ts +1 -0
- package/src/core/index.ts +40 -5
- package/src/data/version.ts +1 -1
- package/src/device/Device.ts +4 -0
- package/src/device/DeviceCommands.ts +2 -0
- package/src/events/ui-request.ts +15 -1
- package/src/inject.ts +17 -0
- package/src/types/api/cipherKeyValue.ts +26 -0
- package/src/types/api/export.ts +27 -0
- package/src/types/api/firmwareUpdate.ts +21 -0
- package/src/types/api/index.ts +21 -0
- package/src/types/api/nemGetAddress.ts +22 -0
- package/src/types/api/nemSignTransaction.ts +117 -0
- package/src/types/api/solGetAddress.ts +21 -0
- package/src/types/api/solSignTransaction.ts +21 -0
- package/src/types/api/stellarGetAddress.ts +21 -0
- package/src/types/api/stellarSignTransaction.ts +153 -0
- package/src/types/device.ts +52 -0
- package/src/types/firmware.ts +2 -1
- package/src/types/params.ts +2 -0
- package/src/utils/assets.ts +1 -1
- package/src/utils/deviceFeaturesUtils.ts +16 -2
- package/src/utils/networkUtils.ts +3 -1
package/src/core/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import semver from 'semver';
|
|
1
2
|
import EventEmitter from 'events';
|
|
2
3
|
import { OneKeyDeviceInfo } from '@onekeyfe/hd-transport';
|
|
3
4
|
import { ERRORS } from '../constants';
|
|
@@ -25,6 +26,11 @@ import type { BaseMethod } from '../api/BaseMethod';
|
|
|
25
26
|
import type { ConnectSettings, KnownDevice } from '../types';
|
|
26
27
|
import TransportManager from '../data-manager/TransportManager';
|
|
27
28
|
import DeviceConnector from '../device/DeviceConnector';
|
|
29
|
+
import {
|
|
30
|
+
getDeviceFirmwareVersion,
|
|
31
|
+
getDeviceModel,
|
|
32
|
+
getDeviceType,
|
|
33
|
+
} from '../utils/deviceFeaturesUtils';
|
|
28
34
|
|
|
29
35
|
const Log = initLog('Core');
|
|
30
36
|
|
|
@@ -51,6 +57,7 @@ export const callAPI = async (message: CoreMessage) => {
|
|
|
51
57
|
try {
|
|
52
58
|
method = findMethod(message as IFrameCallMessage);
|
|
53
59
|
method.connector = _connector;
|
|
60
|
+
method.postMessage = postMessage;
|
|
54
61
|
method.init();
|
|
55
62
|
} catch (error) {
|
|
56
63
|
return Promise.reject(error);
|
|
@@ -100,11 +107,38 @@ export const callAPI = async (message: CoreMessage) => {
|
|
|
100
107
|
|
|
101
108
|
try {
|
|
102
109
|
const inner = async (): Promise<void> => {
|
|
103
|
-
// check firmware
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
// check firmware version
|
|
111
|
+
const deviceType = getDeviceType(device.features);
|
|
112
|
+
const deviceModel = getDeviceModel(device.features);
|
|
113
|
+
const versionRangeType = method.getVersionRange()[deviceType];
|
|
114
|
+
const versionRangeModel = method.getVersionRange()[deviceModel];
|
|
115
|
+
|
|
116
|
+
// Type has a higher priority than Model
|
|
117
|
+
const versionRange = versionRangeType ?? versionRangeModel;
|
|
118
|
+
|
|
119
|
+
if (versionRange && device.features) {
|
|
120
|
+
const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
121
|
+
if (semver.valid(versionRange.min) && semver.lt(currentVersion, versionRange.min)) {
|
|
122
|
+
return Promise.reject(
|
|
123
|
+
ERRORS.TypedError(
|
|
124
|
+
'Device_FwException',
|
|
125
|
+
`Device firmware version is too low, please update to ${versionRange.min}`
|
|
126
|
+
)
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
if (
|
|
130
|
+
versionRange.max &&
|
|
131
|
+
semver.valid(versionRange.max) &&
|
|
132
|
+
semver.gt(currentVersion, versionRange.max)
|
|
133
|
+
) {
|
|
134
|
+
return Promise.reject(
|
|
135
|
+
ERRORS.TypedError(
|
|
136
|
+
'Device_FwException',
|
|
137
|
+
`Device firmware version is too high, this method has been deprecated in ${versionRange.max}`
|
|
138
|
+
)
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
108
142
|
|
|
109
143
|
// check call method mode
|
|
110
144
|
const unexpectedMode = device.hasUnexpectedMode(
|
|
@@ -149,6 +183,7 @@ export const callAPI = async (message: CoreMessage) => {
|
|
|
149
183
|
} catch (error) {
|
|
150
184
|
messageResponse = createResponseMessage(method.responseID, false, error);
|
|
151
185
|
_callPromise?.reject(ERRORS.TypedError('Call_API', error));
|
|
186
|
+
Log.debug('Call API - Run Error: ', error);
|
|
152
187
|
} finally {
|
|
153
188
|
const response = messageResponse;
|
|
154
189
|
|
package/src/data/version.ts
CHANGED
package/src/device/Device.ts
CHANGED
package/src/events/ui-request.ts
CHANGED
|
@@ -14,6 +14,8 @@ export const UI_REQUEST = {
|
|
|
14
14
|
|
|
15
15
|
BLUETOOTH_PERMISSION: 'ui-bluetooth_permission',
|
|
16
16
|
LOCATION_PERMISSION: 'ui-location_permission',
|
|
17
|
+
|
|
18
|
+
FIRMWARE_PROGRESS: 'ui-firmware-progress',
|
|
17
19
|
} as const;
|
|
18
20
|
|
|
19
21
|
export interface UiRequestWithoutPayload {
|
|
@@ -37,7 +39,19 @@ export interface UiRequestButton {
|
|
|
37
39
|
payload: DeviceButtonRequest['payload'];
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
export
|
|
42
|
+
export interface FirmwareProgress {
|
|
43
|
+
type: typeof UI_REQUEST.FIRMWARE_PROGRESS;
|
|
44
|
+
payload: {
|
|
45
|
+
device: Device;
|
|
46
|
+
progress: number;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type UiEvent =
|
|
51
|
+
| UiRequestWithoutPayload
|
|
52
|
+
| UiRequestDeviceAction
|
|
53
|
+
| UiRequestButton
|
|
54
|
+
| FirmwareProgress;
|
|
41
55
|
|
|
42
56
|
export type UiEventMessage = UiEvent & { event: typeof UI_EVENT };
|
|
43
57
|
|
package/src/inject.ts
CHANGED
|
@@ -66,6 +66,8 @@ export const inject = ({
|
|
|
66
66
|
*/
|
|
67
67
|
checkTransportRelease: () => call({ method: 'checkTransportRelease' }),
|
|
68
68
|
|
|
69
|
+
cipherKeyValue: (connectId, params) => call({ ...params, connectId, method: 'cipherKeyValue' }),
|
|
70
|
+
|
|
69
71
|
deviceBackup: connectId => call({ connectId, method: 'deviceBackup' }),
|
|
70
72
|
deviceChangePin: (connectId, params) =>
|
|
71
73
|
call({ ...params, connectId, method: 'deviceChangePin' }),
|
|
@@ -109,6 +111,21 @@ export const inject = ({
|
|
|
109
111
|
call({ ...params, connectId, method: 'starcoinSignTransaction' }),
|
|
110
112
|
starcoinVerifyMessage: (connectId, params) =>
|
|
111
113
|
call({ ...params, connectId, method: 'starcoinVerifyMessage' }),
|
|
114
|
+
|
|
115
|
+
nemGetAddress: (connectId, params) => call({ ...params, connectId, method: 'nemGetAddress' }),
|
|
116
|
+
nemSignTransaction: (connectId, params) =>
|
|
117
|
+
call({ ...params, connectId, method: 'nemSignTransaction' }),
|
|
118
|
+
|
|
119
|
+
solGetAddress: (connectId, params) => call({ ...params, connectId, method: 'solGetAddress' }),
|
|
120
|
+
solSignTransaction: (connectId, params) =>
|
|
121
|
+
call({ ...params, connectId, method: 'solSignTransaction' }),
|
|
122
|
+
|
|
123
|
+
stellarGetAddress: (connectId, params) =>
|
|
124
|
+
call({ ...params, connectId, method: 'stellarGetAddress' }),
|
|
125
|
+
stellarSignTransaction: (connectId, params) =>
|
|
126
|
+
call({ ...params, connectId, method: 'stellarSignTransaction' }),
|
|
127
|
+
|
|
128
|
+
firmwareUpdate: (connectId, params) => call({ ...params, connectId, method: 'firmwareUpdate' }),
|
|
112
129
|
};
|
|
113
130
|
return api;
|
|
114
131
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CipheredKeyValue as HardwareCipheredKeyValue } from '@onekeyfe/hd-transport/src/types/messages';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export type CipheredKeyValue = {
|
|
5
|
+
path: string;
|
|
6
|
+
} & HardwareCipheredKeyValue;
|
|
7
|
+
|
|
8
|
+
export type CipheredKeyValueParams = {
|
|
9
|
+
path: string | number[];
|
|
10
|
+
key: string;
|
|
11
|
+
value: string;
|
|
12
|
+
encrypt?: boolean;
|
|
13
|
+
askOnEncrypt?: boolean;
|
|
14
|
+
askOnDecrypt?: boolean;
|
|
15
|
+
iv?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export declare function cipherKeyValue(
|
|
19
|
+
connectId: string,
|
|
20
|
+
params: CommonParams & CipheredKeyValueParams
|
|
21
|
+
): Response<CipheredKeyValue>;
|
|
22
|
+
|
|
23
|
+
export declare function cipherKeyValue(
|
|
24
|
+
connectId: string,
|
|
25
|
+
params: CommonParams & { bundle?: CipheredKeyValueParams[] }
|
|
26
|
+
): Response<Array<CipheredKeyValue>>;
|
package/src/types/api/export.ts
CHANGED
|
@@ -11,6 +11,8 @@ export type {
|
|
|
11
11
|
TransactionOptions,
|
|
12
12
|
} from './btcSignTransaction';
|
|
13
13
|
|
|
14
|
+
export type { CipheredKeyValue, CipheredKeyValueParams } from './cipherKeyValue';
|
|
15
|
+
|
|
14
16
|
export type { DeviceChangePinParams } from './deviceChangePin';
|
|
15
17
|
export type { DeviceFlagsParams } from './deviceFlags';
|
|
16
18
|
export type { DeviceRecoveryParams } from './deviceRecovery';
|
|
@@ -41,3 +43,28 @@ export type { StarcoinPublicKey, StarcoinGetPublicKeyParams } from './starcoinGe
|
|
|
41
43
|
export type { StarcoinSignMessageParams } from './starcoinSignMessage';
|
|
42
44
|
export type { StarcoinSignTransactionParams } from './starcoinSignTransaction';
|
|
43
45
|
export type { StarcoinVerifyMessageParams } from './starcoinVerifyMessage';
|
|
46
|
+
|
|
47
|
+
export type { NEMAddress, NEMGetAddressParams } from './nemGetAddress';
|
|
48
|
+
export type {
|
|
49
|
+
NEMAggregateModificationTransaction,
|
|
50
|
+
NEMImportanceTransaction,
|
|
51
|
+
NEMMosaic,
|
|
52
|
+
NEMMosaicCreationTransaction,
|
|
53
|
+
NEMMultisigTransaction,
|
|
54
|
+
NEMProvisionNamespaceTransaction,
|
|
55
|
+
NEMSupplyChangeTransaction,
|
|
56
|
+
NEMTransferTransaction,
|
|
57
|
+
NEMTransaction,
|
|
58
|
+
NEMSignTransactionParams,
|
|
59
|
+
} from './nemSignTransaction';
|
|
60
|
+
|
|
61
|
+
export type { SolanaAddress, SolanaGetAddressParams } from './solGetAddress';
|
|
62
|
+
export type { SolanaSignedTx, SolanaSignTransactionParams } from './solSignTransaction';
|
|
63
|
+
|
|
64
|
+
export type { StellarAddress, StellarGetAddressParams } from './stellarGetAddress';
|
|
65
|
+
export type {
|
|
66
|
+
StellarAsset,
|
|
67
|
+
StellarOperation,
|
|
68
|
+
StellarTransaction,
|
|
69
|
+
StellarSignTransactionParams,
|
|
70
|
+
} from './stellarSignTransaction';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PROTO } from '../../constants';
|
|
2
|
+
import type { Params, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export interface FirmwareUpdateBinary {
|
|
5
|
+
binary: ArrayBuffer;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface FirmwareUpdate {
|
|
9
|
+
version: number[];
|
|
10
|
+
btcOnly?: boolean;
|
|
11
|
+
updateType: 'firmware' | 'ble';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export declare function firmwareUpdate(
|
|
15
|
+
connectId: string | undefined,
|
|
16
|
+
params: Params<FirmwareUpdate>
|
|
17
|
+
): Response<PROTO.Success>;
|
|
18
|
+
export declare function firmwareUpdate(
|
|
19
|
+
connectId: string | undefined,
|
|
20
|
+
params: Params<FirmwareUpdateBinary>
|
|
21
|
+
): Response<PROTO.Success>;
|
package/src/types/api/index.ts
CHANGED
|
@@ -32,6 +32,14 @@ import { starcoinGetPublicKey } from './starcoinGetPublicKey';
|
|
|
32
32
|
import { starcoinSignMessage } from './starcoinSignMessage';
|
|
33
33
|
import { starcoinSignTransaction } from './starcoinSignTransaction';
|
|
34
34
|
import { starcoinVerifyMessage } from './starcoinVerifyMessage';
|
|
35
|
+
import { nemGetAddress } from './nemGetAddress';
|
|
36
|
+
import { nemSignTransaction } from './nemSignTransaction';
|
|
37
|
+
import { solGetAddress } from './solGetAddress';
|
|
38
|
+
import { solSignTransaction } from './solSignTransaction';
|
|
39
|
+
import { stellarGetAddress } from './stellarGetAddress';
|
|
40
|
+
import { stellarSignTransaction } from './stellarSignTransaction';
|
|
41
|
+
import { cipherKeyValue } from './cipherKeyValue';
|
|
42
|
+
import { firmwareUpdate } from './firmwareUpdate';
|
|
35
43
|
|
|
36
44
|
export * from './export';
|
|
37
45
|
|
|
@@ -61,6 +69,8 @@ export type CoreApi = {
|
|
|
61
69
|
|
|
62
70
|
checkTransportRelease: typeof checkTransportRelease;
|
|
63
71
|
|
|
72
|
+
cipherKeyValue: typeof cipherKeyValue;
|
|
73
|
+
|
|
64
74
|
deviceBackup: typeof deviceBackup;
|
|
65
75
|
deviceChangePin: typeof deviceChangePin;
|
|
66
76
|
deviceFlags: typeof deviceFlags;
|
|
@@ -90,4 +100,15 @@ export type CoreApi = {
|
|
|
90
100
|
starcoinSignMessage: typeof starcoinSignMessage;
|
|
91
101
|
starcoinSignTransaction: typeof starcoinSignTransaction;
|
|
92
102
|
starcoinVerifyMessage: typeof starcoinVerifyMessage;
|
|
103
|
+
|
|
104
|
+
nemGetAddress: typeof nemGetAddress;
|
|
105
|
+
nemSignTransaction: typeof nemSignTransaction;
|
|
106
|
+
|
|
107
|
+
solGetAddress: typeof solGetAddress;
|
|
108
|
+
solSignTransaction: typeof solSignTransaction;
|
|
109
|
+
|
|
110
|
+
stellarGetAddress: typeof stellarGetAddress;
|
|
111
|
+
stellarSignTransaction: typeof stellarSignTransaction;
|
|
112
|
+
|
|
113
|
+
firmwareUpdate: typeof firmwareUpdate;
|
|
93
114
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NEMAddress as HardwareNEMAddress } from '@onekeyfe/hd-transport/src/types/messages';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export type NEMAddress = {
|
|
5
|
+
path: string;
|
|
6
|
+
} & HardwareNEMAddress;
|
|
7
|
+
|
|
8
|
+
export type NEMGetAddressParams = {
|
|
9
|
+
path: string | number[];
|
|
10
|
+
network?: number;
|
|
11
|
+
showOnOneKey?: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export declare function nemGetAddress(
|
|
15
|
+
connectId: string,
|
|
16
|
+
params: CommonParams & NEMGetAddressParams
|
|
17
|
+
): Response<NEMAddress>;
|
|
18
|
+
|
|
19
|
+
export declare function nemGetAddress(
|
|
20
|
+
connectId: string,
|
|
21
|
+
params: CommonParams & { bundle?: NEMGetAddressParams[] }
|
|
22
|
+
): Response<Array<NEMAddress>>;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { NEMSignedTx } from '@onekeyfe/hd-transport/src/types/messages';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
type MosaicID = {
|
|
5
|
+
namespaceId: string;
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type MosaicDefinition = {
|
|
10
|
+
levy?: {
|
|
11
|
+
type?: number;
|
|
12
|
+
fee?: number;
|
|
13
|
+
recipient?: string;
|
|
14
|
+
mosaicId?: MosaicID;
|
|
15
|
+
};
|
|
16
|
+
id: MosaicID;
|
|
17
|
+
description: string;
|
|
18
|
+
properties?: Array<{
|
|
19
|
+
name: 'divisibility' | 'initialSupply' | 'supplyMutable' | 'transferable';
|
|
20
|
+
value: string;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type NEMMosaic = {
|
|
25
|
+
mosaicId: MosaicID;
|
|
26
|
+
quantity: number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type Modification = {
|
|
30
|
+
modificationType: number;
|
|
31
|
+
cosignatoryAccount: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
type Message = {
|
|
35
|
+
payload?: string;
|
|
36
|
+
type?: number;
|
|
37
|
+
publicKey?: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type TransactionCommon = {
|
|
41
|
+
version: number;
|
|
42
|
+
timeStamp: number;
|
|
43
|
+
fee: number;
|
|
44
|
+
deadline?: number;
|
|
45
|
+
signer?: string;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type NEMTransferTransaction = TransactionCommon & {
|
|
49
|
+
type: 0x0101;
|
|
50
|
+
recipient: string;
|
|
51
|
+
amount: number | string;
|
|
52
|
+
mosaics?: NEMMosaic[];
|
|
53
|
+
message?: Message;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type NEMImportanceTransaction = TransactionCommon & {
|
|
57
|
+
type: 0x0801;
|
|
58
|
+
importanceTransfer: {
|
|
59
|
+
mode: number;
|
|
60
|
+
publicKey: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type NEMAggregateModificationTransaction = TransactionCommon & {
|
|
65
|
+
type: 0x1001;
|
|
66
|
+
modifications?: Modification[];
|
|
67
|
+
minCosignatories: {
|
|
68
|
+
relativeChange: number;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type NEMProvisionNamespaceTransaction = TransactionCommon & {
|
|
73
|
+
type: 0x2001;
|
|
74
|
+
newPart?: string;
|
|
75
|
+
parent?: string;
|
|
76
|
+
rentalFeeSink?: string;
|
|
77
|
+
rentalFee?: number;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export type NEMMosaicCreationTransaction = TransactionCommon & {
|
|
81
|
+
type: 0x4001;
|
|
82
|
+
mosaicDefinition: MosaicDefinition;
|
|
83
|
+
creationFeeSink?: string;
|
|
84
|
+
creationFee?: number;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export type NEMSupplyChangeTransaction = TransactionCommon & {
|
|
88
|
+
type: 0x4002;
|
|
89
|
+
mosaicId: MosaicID;
|
|
90
|
+
supplyType: number;
|
|
91
|
+
delta?: number;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
type Transaction =
|
|
95
|
+
| NEMTransferTransaction
|
|
96
|
+
| NEMImportanceTransaction
|
|
97
|
+
| NEMAggregateModificationTransaction
|
|
98
|
+
| NEMProvisionNamespaceTransaction
|
|
99
|
+
| NEMMosaicCreationTransaction
|
|
100
|
+
| NEMSupplyChangeTransaction;
|
|
101
|
+
|
|
102
|
+
export type NEMMultisigTransaction = TransactionCommon & {
|
|
103
|
+
type: 0x0102 | 0x1002 | 0x1004;
|
|
104
|
+
otherTrans: Transaction;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export type NEMTransaction = Transaction | NEMMultisigTransaction;
|
|
108
|
+
|
|
109
|
+
export type NEMSignTransactionParams = {
|
|
110
|
+
path: string | number[];
|
|
111
|
+
transaction: NEMTransaction;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export declare function nemSignTransaction(
|
|
115
|
+
connectId: string,
|
|
116
|
+
params: CommonParams & NEMSignTransactionParams
|
|
117
|
+
): Response<NEMSignedTx>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SolanaAddress as HardwareSolanaAddress } from '@onekeyfe/hd-transport/src/types/messages';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export type SolanaAddress = {
|
|
5
|
+
path: string;
|
|
6
|
+
} & HardwareSolanaAddress;
|
|
7
|
+
|
|
8
|
+
export type SolanaGetAddressParams = {
|
|
9
|
+
path: string | number[];
|
|
10
|
+
showOnOneKey?: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export declare function solGetAddress(
|
|
14
|
+
connectId: string,
|
|
15
|
+
params: CommonParams & SolanaGetAddressParams
|
|
16
|
+
): Response<SolanaAddress>;
|
|
17
|
+
|
|
18
|
+
export declare function solGetAddress(
|
|
19
|
+
connectId: string,
|
|
20
|
+
params: CommonParams & { bundle?: SolanaGetAddressParams[] }
|
|
21
|
+
): Response<Array<SolanaAddress>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SolanaSignedTx as HardwareSolanaSignedTx } from '@onekeyfe/hd-transport/src/types/messages';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export type SolanaSignedTx = {
|
|
5
|
+
path: string;
|
|
6
|
+
} & HardwareSolanaSignedTx;
|
|
7
|
+
|
|
8
|
+
export type SolanaSignTransactionParams = {
|
|
9
|
+
path: string | number[];
|
|
10
|
+
rawTx?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export declare function solSignTransaction(
|
|
14
|
+
connectId: string,
|
|
15
|
+
params: CommonParams & SolanaSignTransactionParams
|
|
16
|
+
): Response<SolanaSignedTx>;
|
|
17
|
+
|
|
18
|
+
export declare function solSignTransaction(
|
|
19
|
+
connectId: string,
|
|
20
|
+
params: CommonParams & { bundle?: SolanaSignTransactionParams[] }
|
|
21
|
+
): Response<Array<SolanaSignedTx>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { StellarAddress as HardwareStellarAddress } from '@onekeyfe/hd-transport/src/types/messages';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export type StellarAddress = {
|
|
5
|
+
path: string;
|
|
6
|
+
} & HardwareStellarAddress;
|
|
7
|
+
|
|
8
|
+
export type StellarGetAddressParams = {
|
|
9
|
+
path: string | number[];
|
|
10
|
+
showOnOneKey?: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export declare function stellarGetAddress(
|
|
14
|
+
connectId: string,
|
|
15
|
+
params: CommonParams & StellarGetAddressParams
|
|
16
|
+
): Response<StellarAddress>;
|
|
17
|
+
|
|
18
|
+
export declare function stellarGetAddress(
|
|
19
|
+
connectId: string,
|
|
20
|
+
params: CommonParams & { bundle?: StellarGetAddressParams[] }
|
|
21
|
+
): Response<Array<StellarAddress>>;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { StellarSignedTx } from '@onekeyfe/hd-transport/src/types/messages';
|
|
2
|
+
import { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export type StellarAsset = {
|
|
5
|
+
type: 0 | 1 | 2; // 0: native, 1: credit_alphanum4, 2: credit_alphanum12
|
|
6
|
+
code: string;
|
|
7
|
+
issuer?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type StellarCreateAccountOperation = {
|
|
11
|
+
type: 'createAccount';
|
|
12
|
+
source?: string;
|
|
13
|
+
destination: string;
|
|
14
|
+
startingBalance: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type StellarPaymentOperation = {
|
|
18
|
+
type: 'payment';
|
|
19
|
+
source?: string;
|
|
20
|
+
destination: string;
|
|
21
|
+
asset?: StellarAsset | typeof undefined;
|
|
22
|
+
amount: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type StellarPathPaymentOperation = {
|
|
26
|
+
type: 'pathPayment';
|
|
27
|
+
source?: string;
|
|
28
|
+
sendAsset: StellarAsset;
|
|
29
|
+
sendMax: string;
|
|
30
|
+
destination: string;
|
|
31
|
+
destAsset: StellarAsset;
|
|
32
|
+
destAmount: string;
|
|
33
|
+
path?: StellarAsset[];
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
type StellarPassiveOfferOperation = {
|
|
37
|
+
type: 'createPassiveOffer';
|
|
38
|
+
source?: string;
|
|
39
|
+
buying: StellarAsset;
|
|
40
|
+
selling: StellarAsset;
|
|
41
|
+
amount: string;
|
|
42
|
+
price: { n: number; d: number };
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
type StellarManageOfferOperation = {
|
|
46
|
+
type: 'manageOffer';
|
|
47
|
+
source?: string;
|
|
48
|
+
buying: StellarAsset;
|
|
49
|
+
selling: StellarAsset;
|
|
50
|
+
amount: string;
|
|
51
|
+
offerId?: string;
|
|
52
|
+
price: { n: number; d: number };
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
type StellarSetOptionsOperation = {
|
|
56
|
+
type: 'setOptions';
|
|
57
|
+
source?: string;
|
|
58
|
+
signer?: {
|
|
59
|
+
type: 0 | 1 | 2;
|
|
60
|
+
key: string | Buffer;
|
|
61
|
+
weight?: number;
|
|
62
|
+
};
|
|
63
|
+
inflationDest?: string;
|
|
64
|
+
clearFlags?: number;
|
|
65
|
+
setFlags?: number;
|
|
66
|
+
masterWeight?: number | string;
|
|
67
|
+
lowThreshold?: number | string;
|
|
68
|
+
medThreshold?: number | string;
|
|
69
|
+
highThreshold?: number | string;
|
|
70
|
+
homeDomain?: string;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
type StellarChangeTrustOperation = {
|
|
74
|
+
type: 'changeTrust';
|
|
75
|
+
source?: string;
|
|
76
|
+
line: StellarAsset;
|
|
77
|
+
limit?: string;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
type StellarAllowTrustOperation = {
|
|
81
|
+
type: 'allowTrust';
|
|
82
|
+
source?: string;
|
|
83
|
+
trustor: string;
|
|
84
|
+
assetCode: string;
|
|
85
|
+
assetType: number;
|
|
86
|
+
authorize?: boolean | typeof undefined;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
type StellarAccountMergeOperation = {
|
|
90
|
+
type: 'accountMerge';
|
|
91
|
+
source?: string;
|
|
92
|
+
destination: string;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
type StellarManageDataOperation = {
|
|
96
|
+
type: 'manageData';
|
|
97
|
+
source?: string;
|
|
98
|
+
name: string;
|
|
99
|
+
value?: Buffer | string;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
type StellarBumpSequenceOperation = {
|
|
103
|
+
type: 'bumpSequence';
|
|
104
|
+
source?: string;
|
|
105
|
+
bumpTo: string;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
type StellarInflationOperation = {
|
|
109
|
+
type: 'inflation';
|
|
110
|
+
source?: string;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export type StellarOperation =
|
|
114
|
+
| StellarCreateAccountOperation
|
|
115
|
+
| StellarPaymentOperation
|
|
116
|
+
| StellarPathPaymentOperation
|
|
117
|
+
| StellarPassiveOfferOperation
|
|
118
|
+
| StellarManageOfferOperation
|
|
119
|
+
| StellarSetOptionsOperation
|
|
120
|
+
| StellarChangeTrustOperation
|
|
121
|
+
| StellarAllowTrustOperation
|
|
122
|
+
| StellarAccountMergeOperation
|
|
123
|
+
| StellarInflationOperation
|
|
124
|
+
| StellarManageDataOperation
|
|
125
|
+
| StellarBumpSequenceOperation;
|
|
126
|
+
|
|
127
|
+
export type StellarTransaction = {
|
|
128
|
+
source: string;
|
|
129
|
+
fee: number;
|
|
130
|
+
sequence: string | number;
|
|
131
|
+
timebounds?: {
|
|
132
|
+
minTime: number;
|
|
133
|
+
maxTime: number;
|
|
134
|
+
};
|
|
135
|
+
memo?: {
|
|
136
|
+
type: 0 | 1 | 2 | 3 | 4;
|
|
137
|
+
id?: string;
|
|
138
|
+
text?: string;
|
|
139
|
+
hash?: string | Buffer;
|
|
140
|
+
};
|
|
141
|
+
operations: StellarOperation[];
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export type StellarSignTransactionParams = {
|
|
145
|
+
path: string | number[];
|
|
146
|
+
networkPassphrase: string;
|
|
147
|
+
transaction: StellarTransaction;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export declare function stellarSignTransaction(
|
|
151
|
+
connectId: string,
|
|
152
|
+
params: CommonParams & StellarSignTransactionParams
|
|
153
|
+
): Response<StellarSignedTx>;
|