@onekeyfe/hd-core 0.0.2 → 0.0.3

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.
Files changed (144) hide show
  1. package/dist/api/{BTCGetAddress.d.ts → btc/BTCGetAddress.d.ts} +2 -2
  2. package/dist/api/btc/BTCGetAddress.d.ts.map +1 -0
  3. package/dist/api/{BTCGetPublicKey.d.ts → btc/BTCGetPublicKey.d.ts} +2 -2
  4. package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -0
  5. package/dist/api/{BTCSignMessage.d.ts → btc/BTCSignMessage.d.ts} +1 -1
  6. package/dist/api/btc/BTCSignMessage.d.ts.map +1 -0
  7. package/dist/api/{BTCSignTransaction.d.ts → btc/BTCSignTransaction.d.ts} +3 -3
  8. package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -0
  9. package/dist/api/{BTCVerifyMessage.d.ts → btc/BTCVerifyMessage.d.ts} +1 -1
  10. package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -0
  11. package/dist/api/{helpers → btc/helpers}/btcParamsUtils.d.ts +0 -0
  12. package/dist/api/btc/helpers/btcParamsUtils.d.ts.map +1 -0
  13. package/dist/api/{helpers/btc → btc/helpers}/signtx.d.ts +0 -0
  14. package/dist/api/{helpers/btc → btc/helpers}/signtx.d.ts.map +1 -1
  15. package/dist/api/{helpers/btc → btc/helpers}/signtxLegacy.d.ts +0 -0
  16. package/dist/api/{helpers/btc → btc/helpers}/signtxLegacy.d.ts.map +1 -1
  17. package/dist/api/{DeviceBackup.d.ts → device/DeviceBackup.d.ts} +1 -1
  18. package/dist/api/device/DeviceBackup.d.ts.map +1 -0
  19. package/dist/api/{DeviceChangePin.d.ts → device/DeviceChangePin.d.ts} +1 -1
  20. package/dist/api/device/DeviceChangePin.d.ts.map +1 -0
  21. package/dist/api/{DeviceFlags.d.ts → device/DeviceFlags.d.ts} +1 -1
  22. package/dist/api/device/DeviceFlags.d.ts.map +1 -0
  23. package/dist/api/{DeviceRebootToBootloader.d.ts → device/DeviceRebootToBootloader.d.ts} +1 -1
  24. package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -0
  25. package/dist/api/{DeviceRecovery.d.ts → device/DeviceRecovery.d.ts} +1 -1
  26. package/dist/api/device/DeviceRecovery.d.ts.map +1 -0
  27. package/dist/api/{DeviceReset.d.ts → device/DeviceReset.d.ts} +1 -1
  28. package/dist/api/device/DeviceReset.d.ts.map +1 -0
  29. package/dist/api/{DeviceSettings.d.ts → device/DeviceSettings.d.ts} +1 -1
  30. package/dist/api/device/DeviceSettings.d.ts.map +1 -0
  31. package/dist/api/{DeviceUpdateReboot.d.ts → device/DeviceUpdateReboot.d.ts} +1 -1
  32. package/dist/api/device/DeviceUpdateReboot.d.ts.map +1 -0
  33. package/dist/api/{DeviceWipe.d.ts → device/DeviceWipe.d.ts} +1 -1
  34. package/dist/api/device/DeviceWipe.d.ts.map +1 -0
  35. package/dist/api/{EVMGetAddress.d.ts → evm/EVMGetAddress.d.ts} +2 -2
  36. package/dist/api/evm/EVMGetAddress.d.ts.map +1 -0
  37. package/dist/api/{EVMGetPublicKey.d.ts → evm/EVMGetPublicKey.d.ts} +2 -2
  38. package/dist/api/evm/EVMGetPublicKey.d.ts.map +1 -0
  39. package/dist/api/{EVMSignMessage.d.ts → evm/EVMSignMessage.d.ts} +1 -1
  40. package/dist/api/evm/EVMSignMessage.d.ts.map +1 -0
  41. package/dist/api/{EVMSignMessageEIP712.d.ts → evm/EVMSignMessageEIP712.d.ts} +1 -1
  42. package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -0
  43. package/dist/api/{EVMSignTransaction.d.ts → evm/EVMSignTransaction.d.ts} +2 -2
  44. package/dist/api/evm/EVMSignTransaction.d.ts.map +1 -0
  45. package/dist/api/{EVMSignTypedData.d.ts → evm/EVMSignTypedData.d.ts} +3 -3
  46. package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -0
  47. package/dist/api/{EVMVerifyMessage.d.ts → evm/EVMVerifyMessage.d.ts} +1 -1
  48. package/dist/api/evm/EVMVerifyMessage.d.ts.map +1 -0
  49. package/dist/api/index.d.ts +26 -21
  50. package/dist/api/index.d.ts.map +1 -1
  51. package/dist/api/starcoin/StarcoinGetAddress.d.ts +9 -0
  52. package/dist/api/starcoin/StarcoinGetAddress.d.ts.map +1 -0
  53. package/dist/api/starcoin/StarcoinGetPublicKey.d.ts +9 -0
  54. package/dist/api/starcoin/StarcoinGetPublicKey.d.ts.map +1 -0
  55. package/dist/api/starcoin/StarcoinSignMessage.d.ts +10 -0
  56. package/dist/api/starcoin/StarcoinSignMessage.d.ts.map +1 -0
  57. package/dist/api/starcoin/StarcoinSignTransaction.d.ts +10 -0
  58. package/dist/api/starcoin/StarcoinSignTransaction.d.ts.map +1 -0
  59. package/dist/api/starcoin/StarcoinVerifyMessage.d.ts +9 -0
  60. package/dist/api/starcoin/StarcoinVerifyMessage.d.ts.map +1 -0
  61. package/dist/index.d.ts +103 -3
  62. package/dist/index.js +203 -43
  63. package/dist/inject.d.ts.map +1 -1
  64. package/dist/types/api/export.d.ts +22 -0
  65. package/dist/types/api/export.d.ts.map +1 -0
  66. package/dist/types/api/index.d.ts +11 -0
  67. package/dist/types/api/index.d.ts.map +1 -1
  68. package/dist/types/api/init.d.ts +1 -1
  69. package/dist/types/api/init.d.ts.map +1 -1
  70. package/dist/types/api/starcoinGetAddress.d.ts +14 -0
  71. package/dist/types/api/starcoinGetAddress.d.ts.map +1 -0
  72. package/dist/types/api/starcoinGetPublicKey.d.ts +14 -0
  73. package/dist/types/api/starcoinGetPublicKey.d.ts.map +1 -0
  74. package/dist/types/api/starcoinSignMessage.d.ts +8 -0
  75. package/dist/types/api/starcoinSignMessage.d.ts.map +1 -0
  76. package/dist/types/api/starcoinSignTransaction.d.ts +8 -0
  77. package/dist/types/api/starcoinSignTransaction.d.ts.map +1 -0
  78. package/dist/types/api/starcoinVerifyMessage.d.ts +9 -0
  79. package/dist/types/api/starcoinVerifyMessage.d.ts.map +1 -0
  80. package/dist/utils/index.d.ts +1 -0
  81. package/dist/utils/index.d.ts.map +1 -1
  82. package/package.json +3 -3
  83. package/src/api/{BTCGetAddress.ts → btc/BTCGetAddress.ts} +5 -5
  84. package/src/api/{BTCGetPublicKey.ts → btc/BTCGetPublicKey.ts} +6 -6
  85. package/src/api/{BTCSignMessage.ts → btc/BTCSignMessage.ts} +5 -5
  86. package/src/api/{BTCSignTransaction.ts → btc/BTCSignTransaction.ts} +8 -8
  87. package/src/api/{BTCVerifyMessage.ts → btc/BTCVerifyMessage.ts} +4 -4
  88. package/src/api/{helpers → btc/helpers}/btcParamsUtils.ts +3 -3
  89. package/src/api/{helpers/btc → btc/helpers}/signtx.ts +0 -0
  90. package/src/api/{helpers/btc → btc/helpers}/signtxLegacy.ts +0 -0
  91. package/src/api/{DeviceBackup.ts → device/DeviceBackup.ts} +1 -1
  92. package/src/api/{DeviceChangePin.ts → device/DeviceChangePin.ts} +2 -2
  93. package/src/api/{DeviceFlags.ts → device/DeviceFlags.ts} +2 -2
  94. package/src/api/{DeviceRebootToBootloader.ts → device/DeviceRebootToBootloader.ts} +1 -1
  95. package/src/api/{DeviceRecovery.ts → device/DeviceRecovery.ts} +2 -2
  96. package/src/api/{DeviceReset.ts → device/DeviceReset.ts} +2 -2
  97. package/src/api/{DeviceSettings.ts → device/DeviceSettings.ts} +2 -2
  98. package/src/api/{DeviceUpdateReboot.ts → device/DeviceUpdateReboot.ts} +1 -1
  99. package/src/api/{DeviceWipe.ts → device/DeviceWipe.ts} +1 -1
  100. package/src/api/{EVMGetAddress.ts → evm/EVMGetAddress.ts} +5 -5
  101. package/src/api/{EVMGetPublicKey.ts → evm/EVMGetPublicKey.ts} +5 -5
  102. package/src/api/{EVMSignMessage.ts → evm/EVMSignMessage.ts} +5 -5
  103. package/src/api/{EVMSignMessageEIP712.ts → evm/EVMSignMessageEIP712.ts} +5 -5
  104. package/src/api/{EVMSignTransaction.ts → evm/EVMSignTransaction.ts} +9 -9
  105. package/src/api/{EVMSignTypedData.ts → evm/EVMSignTypedData.ts} +8 -8
  106. package/src/api/{EVMVerifyMessage.ts → evm/EVMVerifyMessage.ts} +4 -4
  107. package/src/api/index.ts +26 -21
  108. package/src/api/starcoin/StarcoinGetAddress.ts +57 -0
  109. package/src/api/starcoin/StarcoinGetPublicKey.ts +64 -0
  110. package/src/api/starcoin/StarcoinSignMessage.ts +40 -0
  111. package/src/api/starcoin/StarcoinSignTransaction.ts +36 -0
  112. package/src/api/starcoin/StarcoinVerifyMessage.ts +33 -0
  113. package/src/inject.ts +12 -1
  114. package/src/types/api/export.ts +35 -0
  115. package/src/types/api/index.ts +13 -0
  116. package/src/types/api/init.ts +1 -1
  117. package/src/types/api/starcoinGetAddress.ts +21 -0
  118. package/src/types/api/starcoinGetPublicKey.ts +21 -0
  119. package/src/types/api/starcoinSignMessage.ts +12 -0
  120. package/src/types/api/starcoinSignTransaction.ts +12 -0
  121. package/src/types/api/starcoinVerifyMessage.ts +13 -0
  122. package/src/utils/index.ts +1 -0
  123. package/dist/api/BTCGetAddress.d.ts.map +0 -1
  124. package/dist/api/BTCGetPublicKey.d.ts.map +0 -1
  125. package/dist/api/BTCSignMessage.d.ts.map +0 -1
  126. package/dist/api/BTCSignTransaction.d.ts.map +0 -1
  127. package/dist/api/BTCVerifyMessage.d.ts.map +0 -1
  128. package/dist/api/DeviceBackup.d.ts.map +0 -1
  129. package/dist/api/DeviceChangePin.d.ts.map +0 -1
  130. package/dist/api/DeviceFlags.d.ts.map +0 -1
  131. package/dist/api/DeviceRebootToBootloader.d.ts.map +0 -1
  132. package/dist/api/DeviceRecovery.d.ts.map +0 -1
  133. package/dist/api/DeviceReset.d.ts.map +0 -1
  134. package/dist/api/DeviceSettings.d.ts.map +0 -1
  135. package/dist/api/DeviceUpdateReboot.d.ts.map +0 -1
  136. package/dist/api/DeviceWipe.d.ts.map +0 -1
  137. package/dist/api/EVMGetAddress.d.ts.map +0 -1
  138. package/dist/api/EVMGetPublicKey.d.ts.map +0 -1
  139. package/dist/api/EVMSignMessage.d.ts.map +0 -1
  140. package/dist/api/EVMSignMessageEIP712.d.ts.map +0 -1
  141. package/dist/api/EVMSignTransaction.d.ts.map +0 -1
  142. package/dist/api/EVMSignTypedData.d.ts.map +0 -1
  143. package/dist/api/EVMVerifyMessage.d.ts.map +0 -1
  144. package/dist/api/helpers/btcParamsUtils.d.ts.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { BackupDevice } from '@onekeyfe/hd-transport/src/types/messages';
2
- import { BaseMethod } from './BaseMethod';
2
+ import { BaseMethod } from '../BaseMethod';
3
3
 
4
4
  export default class DeviceBackup extends BaseMethod<BackupDevice> {
5
5
  init() {}
@@ -1,6 +1,6 @@
1
1
  import { ChangePin } from '@onekeyfe/hd-transport/src/types/messages';
2
- import { BaseMethod } from './BaseMethod';
3
- import { validateParams } from './helpers/paramsValidator';
2
+ import { BaseMethod } from '../BaseMethod';
3
+ import { validateParams } from '../helpers/paramsValidator';
4
4
 
5
5
  export default class DeviceChangePin extends BaseMethod<ChangePin> {
6
6
  init() {
@@ -1,6 +1,6 @@
1
1
  import { ApplyFlags } from '@onekeyfe/hd-transport/src/types/messages';
2
- import { BaseMethod } from './BaseMethod';
3
- import { validateParams } from './helpers/paramsValidator';
2
+ import { BaseMethod } from '../BaseMethod';
3
+ import { validateParams } from '../helpers/paramsValidator';
4
4
 
5
5
  export default class DeviceFlags extends BaseMethod<ApplyFlags> {
6
6
  init() {
@@ -1,5 +1,5 @@
1
1
  import { RebootToBootloader } from '@onekeyfe/hd-transport/src/types/messages';
2
- import { BaseMethod } from './BaseMethod';
2
+ import { BaseMethod } from '../BaseMethod';
3
3
 
4
4
  // Reboot BootLoader
5
5
  export default class DeviceRebootToBootloader extends BaseMethod<RebootToBootloader> {
@@ -1,6 +1,6 @@
1
1
  import { RecoveryDevice } from '@onekeyfe/hd-transport/src/types/messages';
2
- import { BaseMethod } from './BaseMethod';
3
- import { validateParams } from './helpers/paramsValidator';
2
+ import { BaseMethod } from '../BaseMethod';
3
+ import { validateParams } from '../helpers/paramsValidator';
4
4
 
5
5
  export default class DeviceRecovery extends BaseMethod<RecoveryDevice> {
6
6
  init() {
@@ -1,6 +1,6 @@
1
1
  import { ResetDevice } from '@onekeyfe/hd-transport/src/types/messages';
2
- import { BaseMethod } from './BaseMethod';
3
- import { validateParams } from './helpers/paramsValidator';
2
+ import { BaseMethod } from '../BaseMethod';
3
+ import { validateParams } from '../helpers/paramsValidator';
4
4
 
5
5
  export default class DeviceReset extends BaseMethod<ResetDevice> {
6
6
  init() {
@@ -1,6 +1,6 @@
1
1
  import { ApplySettings } from '@onekeyfe/hd-transport/src/types/messages';
2
- import { BaseMethod } from './BaseMethod';
3
- import { validateParams } from './helpers/paramsValidator';
2
+ import { BaseMethod } from '../BaseMethod';
3
+ import { validateParams } from '../helpers/paramsValidator';
4
4
 
5
5
  export default class DeviceSettings extends BaseMethod<ApplySettings> {
6
6
  init() {
@@ -1,5 +1,5 @@
1
1
  import { BixinReboot } from '@onekeyfe/hd-transport/src/types/messages';
2
- import { BaseMethod } from './BaseMethod';
2
+ import { BaseMethod } from '../BaseMethod';
3
3
 
4
4
  // Upload hint Reboot BootLoader
5
5
  export default class DeviceUpdateReboot extends BaseMethod<BixinReboot> {
@@ -1,5 +1,5 @@
1
1
  import { WipeDevice } from '@onekeyfe/hd-transport/src/types/messages';
2
- import { BaseMethod } from './BaseMethod';
2
+ import { BaseMethod } from '../BaseMethod';
3
3
 
4
4
  export default class DeviceWipe extends BaseMethod<WipeDevice> {
5
5
  init() {}
@@ -1,9 +1,9 @@
1
1
  import { EthereumGetAddress } from '@onekeyfe/hd-transport/src/types/messages';
2
- import { UI_REQUEST } from '../constants/ui-request';
3
- import { serializedPath, validatePath } from './helpers/pathUtils';
4
- import { BaseMethod } from './BaseMethod';
5
- import { validateParams } from './helpers/paramsValidator';
6
- import { EVMAddress, EVMGetAddressParams } from '../types/api/evmGetAddress';
2
+ import { UI_REQUEST } from '../../constants/ui-request';
3
+ import { serializedPath, validatePath } from '../helpers/pathUtils';
4
+ import { BaseMethod } from '../BaseMethod';
5
+ import { validateParams } from '../helpers/paramsValidator';
6
+ import { EVMAddress, EVMGetAddressParams } from '../../types/api/evmGetAddress';
7
7
 
8
8
  export default class EvmGetAddress extends BaseMethod<EthereumGetAddress[]> {
9
9
  hasBundle = false;
@@ -1,9 +1,9 @@
1
1
  import { EthereumGetPublicKey } from '@onekeyfe/hd-transport/src/types/messages';
2
- import { UI_REQUEST } from '../constants/ui-request';
3
- import { serializedPath, validatePath } from './helpers/pathUtils';
4
- import { BaseMethod } from './BaseMethod';
5
- import { validateParams } from './helpers/paramsValidator';
6
- import { EVMGetPublicKeyParams, EVMPublicKey } from '../types/api/evmGetPublicKey';
2
+ import { UI_REQUEST } from '../../constants/ui-request';
3
+ import { serializedPath, validatePath } from '../helpers/pathUtils';
4
+ import { BaseMethod } from '../BaseMethod';
5
+ import { validateParams } from '../helpers/paramsValidator';
6
+ import { EVMGetPublicKeyParams, EVMPublicKey } from '../../types/api/evmGetPublicKey';
7
7
 
8
8
  export default class EVMGetPublicKey extends BaseMethod<EthereumGetPublicKey[]> {
9
9
  hasBundle = false;
@@ -1,9 +1,9 @@
1
1
  import { EthereumSignMessage } from '@onekeyfe/hd-transport/src/types/messages';
2
- import { UI_REQUEST } from '../constants/ui-request';
3
- import { validatePath } from './helpers/pathUtils';
4
- import { BaseMethod } from './BaseMethod';
5
- import { validateParams } from './helpers/paramsValidator';
6
- import { formatAnyHex } from './helpers/hexUtils';
2
+ import { UI_REQUEST } from '../../constants/ui-request';
3
+ import { validatePath } from '../helpers/pathUtils';
4
+ import { BaseMethod } from '../BaseMethod';
5
+ import { validateParams } from '../helpers/paramsValidator';
6
+ import { formatAnyHex } from '../helpers/hexUtils';
7
7
 
8
8
  export default class EVMSignMessage extends BaseMethod<EthereumSignMessage> {
9
9
  init() {
@@ -1,9 +1,9 @@
1
1
  import { EthereumSignMessageEIP712 } from '@onekeyfe/hd-transport/src/types/messages';
2
- import { UI_REQUEST } from '../constants/ui-request';
3
- import { validatePath } from './helpers/pathUtils';
4
- import { BaseMethod } from './BaseMethod';
5
- import { validateParams } from './helpers/paramsValidator';
6
- import { formatAnyHex } from './helpers/hexUtils';
2
+ import { UI_REQUEST } from '../../constants/ui-request';
3
+ import { validatePath } from '../helpers/pathUtils';
4
+ import { BaseMethod } from '../BaseMethod';
5
+ import { validateParams } from '../helpers/paramsValidator';
6
+ import { formatAnyHex } from '../helpers/hexUtils';
7
7
 
8
8
  export default class EVMSignMessageEIP712 extends BaseMethod<EthereumSignMessageEIP712> {
9
9
  init() {
@@ -4,19 +4,19 @@ import {
4
4
  EthereumTxRequest,
5
5
  } from '@onekeyfe/hd-transport/src/types/messages';
6
6
 
7
- import { UI_REQUEST } from '../constants/ui-request';
8
- import { validatePath } from './helpers/pathUtils';
9
- import { BaseMethod } from './BaseMethod';
10
- import { SchemaParam, validateParams } from './helpers/paramsValidator';
7
+ import { UI_REQUEST } from '../../constants/ui-request';
8
+ import { validatePath } from '../helpers/pathUtils';
9
+ import { BaseMethod } from '../BaseMethod';
10
+ import { SchemaParam, validateParams } from '../helpers/paramsValidator';
11
11
  import {
12
12
  EVMSignedTx,
13
13
  EVMSignTransactionParams,
14
14
  EVMTransaction,
15
15
  EVMTransactionEIP1559,
16
- } from '../types/api/evmSignTransaction';
17
- import { cutString } from './helpers/stringUtils';
18
- import { formatAnyHex, stripHexStartZeroes } from './helpers/hexUtils';
19
- import { ERRORS } from '../constants';
16
+ } from '../../types/api/evmSignTransaction';
17
+ import { cutString } from '../helpers/stringUtils';
18
+ import { formatAnyHex, stripHexStartZeroes } from '../helpers/hexUtils';
19
+ import { ERRORS } from '../../constants';
20
20
 
21
21
  export default class EVMSignTransaction extends BaseMethod {
22
22
  addressN: number[] = [];
@@ -70,7 +70,7 @@ export default class EVMSignTransaction extends BaseMethod {
70
70
  const r = request.signature_r;
71
71
  const s = request.signature_s;
72
72
 
73
- if (!v || !r || !s) {
73
+ if (v == null || r == null || s == null) {
74
74
  throw ERRORS.TypedError('Runtime', 'processTxRequest: Unexpected request');
75
75
  }
76
76
 
@@ -3,17 +3,17 @@ import {
3
3
  EthereumTypedDataStructAck,
4
4
  MessageKey,
5
5
  } from '@onekeyfe/hd-transport/src/types/messages';
6
- import { UI_REQUEST } from '../constants/ui-request';
7
- import { validatePath } from './helpers/pathUtils';
8
- import { BaseMethod } from './BaseMethod';
9
- import { validateParams } from './helpers/paramsValidator';
10
- import { formatAnyHex } from './helpers/hexUtils';
11
- import { ERRORS } from '../constants';
12
- import { encodeData, getFieldType, parseArrayType } from './helpers/typeNameUtils';
6
+ import { UI_REQUEST } from '../../constants/ui-request';
7
+ import { validatePath } from '../helpers/pathUtils';
8
+ import { BaseMethod } from '../BaseMethod';
9
+ import { validateParams } from '../helpers/paramsValidator';
10
+ import { formatAnyHex } from '../helpers/hexUtils';
11
+ import { ERRORS } from '../../constants';
12
+ import { encodeData, getFieldType, parseArrayType } from '../helpers/typeNameUtils';
13
13
  import {
14
14
  EthereumSignTypedDataMessage,
15
15
  EthereumSignTypedDataTypes,
16
- } from '../types/api/evmSignTypedData';
16
+ } from '../../types/api/evmSignTypedData';
17
17
 
18
18
  export type EVMSignTypedDataParams = {
19
19
  addressN: number[];
@@ -1,8 +1,8 @@
1
1
  import { EthereumVerifyMessage } from '@onekeyfe/hd-transport/src/types/messages';
2
- import { UI_REQUEST } from '../constants/ui-request';
3
- import { BaseMethod } from './BaseMethod';
4
- import { validateParams } from './helpers/paramsValidator';
5
- import { formatAnyHex } from './helpers/hexUtils';
2
+ import { UI_REQUEST } from '../../constants/ui-request';
3
+ import { BaseMethod } from '../BaseMethod';
4
+ import { validateParams } from '../helpers/paramsValidator';
5
+ import { formatAnyHex } from '../helpers/hexUtils';
6
6
 
7
7
  export default class EVMSignMessage extends BaseMethod<EthereumVerifyMessage> {
8
8
  init() {
package/src/api/index.ts CHANGED
@@ -1,26 +1,31 @@
1
1
  export { default as searchDevices } from './SearchDevices';
2
2
  export { default as getFeatures } from './GetFeatures';
3
- export { default as btcGetAddress } from './BTCGetAddress';
4
- export { default as btcGetPublicKey } from './BTCGetPublicKey';
5
- export { default as btcSignMessage } from './BTCSignMessage';
6
- export { default as btcSignTransaction } from './BTCSignTransaction';
7
- export { default as btcVerifyMessage } from './BTCVerifyMessage';
3
+ export { default as btcGetAddress } from './btc/BTCGetAddress';
4
+ export { default as btcGetPublicKey } from './btc/BTCGetPublicKey';
5
+ export { default as btcSignMessage } from './btc/BTCSignMessage';
6
+ export { default as btcSignTransaction } from './btc/BTCSignTransaction';
7
+ export { default as btcVerifyMessage } from './btc/BTCVerifyMessage';
8
8
  export { default as checkFirmwareRelease } from './CheckFirmwareRelease';
9
9
  export { default as checkBLEFirmwareRelease } from './CheckBLEFirmwareRelease';
10
10
  export { default as checkTransportRelease } from './CheckTransportRelease';
11
- export { default as deviceBackup } from './DeviceBackup';
12
- export { default as deviceChangePin } from './DeviceChangePin';
13
- export { default as deviceFlags } from './DeviceFlags';
14
- export { default as deviceRebootToBootloader } from './DeviceRebootToBootloader';
15
- export { default as deviceRecovery } from './DeviceRecovery';
16
- export { default as deviceReset } from './DeviceReset';
17
- export { default as deviceSettings } from './DeviceSettings';
18
- export { default as deviceUpdateReboot } from './DeviceUpdateReboot';
19
- export { default as deviceWipe } from './DeviceWipe';
20
- export { default as evmGetAddress } from './EVMGetAddress';
21
- export { default as evmGetPublicKey } from './EVMGetPublicKey';
22
- export { default as evmSignMessage } from './EVMSignMessage';
23
- export { default as evmSignMessageEIP712 } from './EVMSignMessageEIP712';
24
- export { default as evmSignTransaction } from './EVMSignTransaction';
25
- export { default as evmSignTypedData } from './EVMSignTypedData';
26
- export { default as evmVerifyMessage } from './EVMVerifyMessage';
11
+ export { default as deviceBackup } from './device/DeviceBackup';
12
+ export { default as deviceChangePin } from './device/DeviceChangePin';
13
+ export { default as deviceFlags } from './device/DeviceFlags';
14
+ export { default as deviceRebootToBootloader } from './device/DeviceRebootToBootloader';
15
+ export { default as deviceRecovery } from './device/DeviceRecovery';
16
+ export { default as deviceReset } from './device/DeviceReset';
17
+ export { default as deviceSettings } from './device/DeviceSettings';
18
+ export { default as deviceUpdateReboot } from './device/DeviceUpdateReboot';
19
+ export { default as deviceWipe } from './device/DeviceWipe';
20
+ export { default as evmGetAddress } from './evm/EVMGetAddress';
21
+ export { default as evmGetPublicKey } from './evm/EVMGetPublicKey';
22
+ export { default as evmSignMessage } from './evm/EVMSignMessage';
23
+ export { default as evmSignMessageEIP712 } from './evm/EVMSignMessageEIP712';
24
+ export { default as evmSignTransaction } from './evm/EVMSignTransaction';
25
+ export { default as evmSignTypedData } from './evm/EVMSignTypedData';
26
+ export { default as evmVerifyMessage } from './evm/EVMVerifyMessage';
27
+ export { default as starcoinGetAddress } from './starcoin/StarcoinGetAddress';
28
+ export { default as starcoinGetPublicKey } from './starcoin/StarcoinGetPublicKey';
29
+ export { default as starcoinSignMessage } from './starcoin/StarcoinSignMessage';
30
+ export { default as starcoinSignTransaction } from './starcoin/StarcoinSignTransaction';
31
+ export { default as starcoinVerifyMessage } from './starcoin/StarcoinVerifyMessage';
@@ -0,0 +1,57 @@
1
+ import { StarcoinGetAddress as HardwareStarcoinGetAddress } from '@onekeyfe/hd-transport/src/types/messages';
2
+ import { UI_REQUEST } from '../../constants/ui-request';
3
+ import { validatePath, serializedPath } from '../helpers/pathUtils';
4
+ import { BaseMethod } from '../BaseMethod';
5
+ import { validateParams } from '../helpers/paramsValidator';
6
+ import { StarcoinAddress, StarcoinGetAddressParams } from '../../types/api/starcoinGetAddress';
7
+
8
+ export default class StarcoinGetAddress extends BaseMethod<HardwareStarcoinGetAddress[]> {
9
+ hasBundle = false;
10
+
11
+ init() {
12
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
13
+
14
+ this.hasBundle = !!this.payload?.bundle;
15
+ const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
16
+
17
+ // check payload
18
+ validateParams(payload, [{ name: 'bundle', type: 'array' }]);
19
+
20
+ // init params
21
+ this.params = [];
22
+ payload.bundle.forEach((batch: StarcoinGetAddressParams) => {
23
+ const addressN = validatePath(batch.path, 3);
24
+
25
+ validateParams(batch, [
26
+ { name: 'path', required: true },
27
+ { name: 'showOnOneKey', type: 'boolean' },
28
+ ]);
29
+
30
+ const showOnOneKey = batch.showOnOneKey ?? true;
31
+
32
+ this.params.push({
33
+ address_n: addressN,
34
+ show_display: showOnOneKey,
35
+ });
36
+ });
37
+ }
38
+
39
+ async run() {
40
+ const responses: StarcoinAddress[] = [];
41
+
42
+ for (let i = 0; i < this.params.length; i++) {
43
+ const param = this.params[i];
44
+
45
+ const res = await this.device.commands.typedCall('StarcoinGetAddress', 'StarcoinAddress', {
46
+ ...param,
47
+ });
48
+
49
+ responses.push({
50
+ path: serializedPath(param.address_n),
51
+ ...res.message,
52
+ });
53
+ }
54
+
55
+ return Promise.resolve(this.hasBundle ? responses : responses[0]);
56
+ }
57
+ }
@@ -0,0 +1,64 @@
1
+ import { StarcoinGetPublicKey as HardwareStarcoinGetPublicKey } from '@onekeyfe/hd-transport/src/types/messages';
2
+ import { UI_REQUEST } from '../../constants/ui-request';
3
+ import { validatePath, serializedPath } from '../helpers/pathUtils';
4
+ import { BaseMethod } from '../BaseMethod';
5
+ import { validateParams } from '../helpers/paramsValidator';
6
+ import {
7
+ StarcoinPublicKey,
8
+ StarcoinGetPublicKeyParams,
9
+ } from '../../types/api/starcoinGetPublicKey';
10
+
11
+ export default class StarcoinGetPublicKey extends BaseMethod<HardwareStarcoinGetPublicKey[]> {
12
+ hasBundle = false;
13
+
14
+ init() {
15
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
16
+
17
+ this.hasBundle = !!this.payload?.bundle;
18
+ const payload = this.hasBundle ? this.payload : { bundle: [this.payload] };
19
+
20
+ // check payload
21
+ validateParams(payload, [{ name: 'bundle', type: 'array' }]);
22
+
23
+ // init params
24
+ this.params = [];
25
+ payload.bundle.forEach((batch: StarcoinGetPublicKeyParams) => {
26
+ const addressN = validatePath(batch.path, 3);
27
+
28
+ validateParams(batch, [
29
+ { name: 'path', required: true },
30
+ { name: 'showOnOneKey', type: 'boolean' },
31
+ ]);
32
+
33
+ const showOnOneKey = batch.showOnOneKey ?? true;
34
+
35
+ this.params.push({
36
+ address_n: addressN,
37
+ show_display: showOnOneKey,
38
+ });
39
+ });
40
+ }
41
+
42
+ async run() {
43
+ const responses: StarcoinPublicKey[] = [];
44
+
45
+ for (let i = 0; i < this.params.length; i++) {
46
+ const param = this.params[i];
47
+
48
+ const res = await this.device.commands.typedCall(
49
+ 'StarcoinGetPublicKey',
50
+ 'StarcoinPublicKey',
51
+ {
52
+ ...param,
53
+ }
54
+ );
55
+
56
+ responses.push({
57
+ path: serializedPath(param.address_n),
58
+ ...res.message,
59
+ });
60
+ }
61
+
62
+ return Promise.resolve(this.hasBundle ? responses : responses[0]);
63
+ }
64
+ }
@@ -0,0 +1,40 @@
1
+ import { StarcoinSignMessage as HardwareStarcoinSignMessage } from '@onekeyfe/hd-transport/src/types/messages';
2
+ import { UI_REQUEST } from '../../constants/ui-request';
3
+ import { validatePath } from '../helpers/pathUtils';
4
+ import { BaseMethod } from '../BaseMethod';
5
+ import { validateParams } from '../helpers/paramsValidator';
6
+ import { formatAnyHex } from '../helpers/hexUtils';
7
+
8
+ export default class StarcoinSignMessage extends BaseMethod<HardwareStarcoinSignMessage> {
9
+ init() {
10
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
11
+
12
+ // check payload
13
+ validateParams(this.payload, [
14
+ { name: 'path', required: true },
15
+ { name: 'messageHex', type: 'hexString', required: true },
16
+ ]);
17
+
18
+ const { path, messageHex } = this.payload;
19
+
20
+ const addressN = validatePath(path, 3);
21
+
22
+ // init params
23
+ this.params = {
24
+ address_n: addressN,
25
+ message: formatAnyHex(messageHex),
26
+ };
27
+ }
28
+
29
+ async run() {
30
+ const res = await this.device.commands.typedCall(
31
+ 'StarcoinSignMessage',
32
+ 'StarcoinMessageSignature',
33
+ {
34
+ ...this.params,
35
+ }
36
+ );
37
+
38
+ return Promise.resolve(res.message);
39
+ }
40
+ }
@@ -0,0 +1,36 @@
1
+ import { StarcoinSignTx } from '@onekeyfe/hd-transport/src/types/messages';
2
+ import { UI_REQUEST } from '../../constants/ui-request';
3
+ import { validatePath } from '../helpers/pathUtils';
4
+ import { BaseMethod } from '../BaseMethod';
5
+ import { validateParams } from '../helpers/paramsValidator';
6
+ import { formatAnyHex } from '../helpers/hexUtils';
7
+
8
+ export default class StarcoinSignTransaction extends BaseMethod<StarcoinSignTx> {
9
+ init() {
10
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
11
+
12
+ // check payload
13
+ validateParams(this.payload, [
14
+ { name: 'path', required: true },
15
+ { name: 'rawTx', type: 'hexString', required: true },
16
+ ]);
17
+
18
+ const { path, rawTx } = this.payload;
19
+
20
+ const addressN = validatePath(path, 3);
21
+
22
+ // init params
23
+ this.params = {
24
+ address_n: addressN,
25
+ raw_tx: formatAnyHex(rawTx),
26
+ };
27
+ }
28
+
29
+ async run() {
30
+ const res = await this.device.commands.typedCall('StarcoinSignTx', 'StarcoinSignedTx', {
31
+ ...this.params,
32
+ });
33
+
34
+ return Promise.resolve(res.message);
35
+ }
36
+ }
@@ -0,0 +1,33 @@
1
+ import { StarcoinVerifyMessage as HardwareStarcoinVerifyMessage } from '@onekeyfe/hd-transport/src/types/messages';
2
+ import { UI_REQUEST } from '../../constants/ui-request';
3
+ import { BaseMethod } from '../BaseMethod';
4
+ import { validateParams } from '../helpers/paramsValidator';
5
+ import { formatAnyHex } from '../helpers/hexUtils';
6
+
7
+ export default class EVMSignMessage extends BaseMethod<HardwareStarcoinVerifyMessage> {
8
+ init() {
9
+ this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
10
+
11
+ validateParams(this.payload, [
12
+ { name: 'publicKey', type: 'string', required: true },
13
+ { name: 'messageHex', type: 'hexString', required: true },
14
+ { name: 'signature', type: 'hexString', required: true },
15
+ ]);
16
+
17
+ const { publicKey, messageHex, signature } = formatAnyHex(this.payload);
18
+
19
+ this.params = {
20
+ public_key: publicKey,
21
+ message: messageHex,
22
+ signature,
23
+ };
24
+ }
25
+
26
+ async run() {
27
+ const res = await this.device.commands.typedCall('StarcoinVerifyMessage', 'Success', {
28
+ ...this.params,
29
+ });
30
+
31
+ return Promise.resolve(res.message);
32
+ }
33
+ }
package/src/inject.ts CHANGED
@@ -73,7 +73,7 @@ export const inject = ({
73
73
  deviceRebootToBootloader: connectId => call({ connectId, method: 'deviceRebootToBootloader' }),
74
74
  deviceRecovery: (connectId, params) => call({ ...params, connectId, method: 'deviceRecovery' }),
75
75
  deviceReset: (connectId, params) => call({ ...params, connectId, method: 'deviceReset' }),
76
- deviceSettings: connectId => call({ connectId, method: 'deviceSettings' }),
76
+ deviceSettings: (connectId, params) => call({ ...params, connectId, method: 'deviceSettings' }),
77
77
  deviceUpdateReboot: connectId => call({ connectId, method: 'deviceUpdateReboot' }),
78
78
  deviceWipe: connectId => call({ connectId, method: 'deviceWipe' }),
79
79
 
@@ -98,6 +98,17 @@ export const inject = ({
98
98
  call({ ...params, connectId, method: 'btcSignTransaction' }),
99
99
  btcVerifyMessage: (connectId, params) =>
100
100
  call({ ...params, connectId, method: 'btcVerifyMessage' }),
101
+
102
+ starcoinGetAddress: (connectId, params) =>
103
+ call({ ...params, connectId, method: 'starcoinGetAddress' }),
104
+ starcoinGetPublicKey: (connectId, params) =>
105
+ call({ ...params, connectId, method: 'starcoinGetPublicKey' }),
106
+ starcoinSignMessage: (connectId, params) =>
107
+ call({ ...params, connectId, method: 'starcoinSignMessage' }),
108
+ starcoinSignTransaction: (connectId, params) =>
109
+ call({ ...params, connectId, method: 'starcoinSignTransaction' }),
110
+ starcoinVerifyMessage: (connectId, params) =>
111
+ call({ ...params, connectId, method: 'starcoinVerifyMessage' }),
101
112
  };
102
113
  return api;
103
114
  };
@@ -0,0 +1,35 @@
1
+ export type { BTCAddress, BTCGetAddressParams } from './btcGetAddress';
2
+ export type { BTCPublicKey, BTCGetPublicKeyParams } from './btcGetPublicKey';
3
+ export type { BTCSignMessageParams } from './btcSignMessage';
4
+ export type { BTCVerifyMessageParams } from './btcVerifyMessage';
5
+
6
+ export type { DeviceChangePinParams } from './deviceChangePin';
7
+ export type { DeviceFlagsParams } from './deviceFlags';
8
+ export type { DeviceRecoveryParams } from './deviceRecovery';
9
+ export type { DeviceResetParams } from './deviceReset';
10
+ export type { DeviceSettingsParams } from './deviceSettings';
11
+
12
+ export type { EVMAddress, EVMGetAddressParams } from './evmGetAddress';
13
+ export type { EVMPublicKey, EVMGetPublicKeyParams } from './evmGetPublicKey';
14
+ export type { EVMSignMessageParams } from './evmSignMessage';
15
+ export type { EVMSignMessageEIP712Params } from './evmSignMessageEIP712';
16
+ export type {
17
+ EVMTransaction,
18
+ EVMTransactionEIP1559,
19
+ EVMSignedTx,
20
+ EVMSignTransactionParams,
21
+ EVMAccessList,
22
+ } from './evmSignTransaction';
23
+ export type {
24
+ EthereumSignTypedDataTypes,
25
+ EthereumSignTypedDataTypeProperty,
26
+ EthereumSignTypedDataMessage,
27
+ EVMSignTypedDataParams,
28
+ } from './evmSignTypedData';
29
+ export type { EVMVerifyMessageParams } from './evmVerifyMessage';
30
+
31
+ export type { StarcoinAddress, StarcoinGetAddressParams } from './starcoinGetAddress';
32
+ export type { StarcoinPublicKey, StarcoinGetPublicKeyParams } from './starcoinGetPublicKey';
33
+ export type { StarcoinSignMessageParams } from './starcoinSignMessage';
34
+ export type { StarcoinSignTransactionParams } from './starcoinSignTransaction';
35
+ export type { StarcoinVerifyMessageParams } from './starcoinVerifyMessage';
@@ -27,6 +27,13 @@ import { deviceChangePin } from './deviceChangePin';
27
27
  import { deviceSettings } from './deviceSettings';
28
28
  import { deviceFlags } from './deviceFlags';
29
29
  import { deviceUpdateReboot } from './deviceUpdateReboot';
30
+ import { starcoinGetAddress } from './starcoinGetAddress';
31
+ import { starcoinGetPublicKey } from './starcoinGetPublicKey';
32
+ import { starcoinSignMessage } from './starcoinSignMessage';
33
+ import { starcoinSignTransaction } from './starcoinSignTransaction';
34
+ import { starcoinVerifyMessage } from './starcoinVerifyMessage';
35
+
36
+ export * from './export';
30
37
 
31
38
  export type CoreApi = {
32
39
  /**
@@ -77,4 +84,10 @@ export type CoreApi = {
77
84
  btcSignMessage: typeof btcSignMessage;
78
85
  btcSignTransaction: typeof btcSignTransaction;
79
86
  btcVerifyMessage: typeof btcVerifyMessage;
87
+
88
+ starcoinGetAddress: typeof starcoinGetAddress;
89
+ starcoinGetPublicKey: typeof starcoinGetPublicKey;
90
+ starcoinSignMessage: typeof starcoinSignMessage;
91
+ starcoinSignTransaction: typeof starcoinSignTransaction;
92
+ starcoinVerifyMessage: typeof starcoinVerifyMessage;
80
93
  };
@@ -1,3 +1,3 @@
1
1
  import type { ConnectSettings } from '../settings';
2
2
 
3
- export declare function init(settings: Partial<ConnectSettings>): Promise<void> | void;
3
+ export declare function init(settings: Partial<ConnectSettings>): Promise<boolean>;
@@ -0,0 +1,21 @@
1
+ import { StarcoinAddress as HardwareStarcoinAddress } from '@onekeyfe/hd-transport/src/types/messages';
2
+ import type { CommonParams, Response } from '../params';
3
+
4
+ export type StarcoinAddress = {
5
+ path: string;
6
+ } & HardwareStarcoinAddress;
7
+
8
+ export type StarcoinGetAddressParams = {
9
+ path: string | number[];
10
+ showOnOneKey?: boolean;
11
+ };
12
+
13
+ export declare function starcoinGetAddress(
14
+ connectId: string,
15
+ params: CommonParams & StarcoinGetAddressParams
16
+ ): Response<StarcoinAddress>;
17
+
18
+ export declare function starcoinGetAddress(
19
+ connectId: string,
20
+ params: CommonParams & { bundle?: StarcoinGetAddressParams[] }
21
+ ): Response<Array<StarcoinAddress>>;