@onekeyfe/hd-core 0.3.21 → 0.3.22

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,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"}
package/dist/index.js CHANGED
@@ -27133,7 +27133,7 @@ const processTxRequest = ({ typedCall, request, data, chainId, supportTrezor, })
27133
27133
  supportTrezor,
27134
27134
  });
27135
27135
  });
27136
- const evmSignTx$1 = ({ typedCall, addressN, tx, supportTrezor, }) => __awaiter(void 0, void 0, void 0, function* () {
27136
+ const evmSignTx = ({ typedCall, addressN, tx, supportTrezor, }) => __awaiter(void 0, void 0, void 0, function* () {
27137
27137
  const { to, value, gasPrice, gasLimit, nonce, data, chainId, txType } = tx;
27138
27138
  const length = data == null ? 0 : data.length / 2;
27139
27139
  const [first, rest] = cutString(data, 1024 * 2);
@@ -27167,7 +27167,7 @@ const evmSignTx$1 = ({ typedCall, addressN, tx, supportTrezor, }) => __awaiter(v
27167
27167
  supportTrezor,
27168
27168
  });
27169
27169
  });
27170
- const evmSignTxEip1559$1 = ({ typedCall, addressN, tx, supportTrezor, }) => __awaiter(void 0, void 0, void 0, function* () {
27170
+ const evmSignTxEip1559 = ({ typedCall, addressN, tx, supportTrezor, }) => __awaiter(void 0, void 0, void 0, function* () {
27171
27171
  const { to, value, gasLimit, nonce, data, chainId, maxFeePerGas, maxPriorityFeePerGas, accessList, } = tx;
27172
27172
  const length = data == null ? 0 : data.length / 2;
27173
27173
  const [first, rest] = cutString(data, 1024 * 2);
@@ -27198,59 +27198,19 @@ const evmSignTxEip1559$1 = ({ typedCall, addressN, tx, supportTrezor, }) => __aw
27198
27198
  });
27199
27199
  const signTransaction$1 = ({ typedCall, isEIP1559, addressN, tx, }) => __awaiter(void 0, void 0, void 0, function* () {
27200
27200
  return isEIP1559
27201
- ? evmSignTxEip1559$1({ typedCall, addressN, tx: tx })
27202
- : evmSignTx$1({ typedCall, addressN, tx: tx });
27201
+ ? evmSignTxEip1559({ typedCall, addressN, tx: tx })
27202
+ : evmSignTx({ typedCall, addressN, tx: tx });
27203
27203
  });
27204
27204
 
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
27205
  const signTransaction = ({ typedCall, isEIP1559, addressN, tx, }) => __awaiter(void 0, void 0, void 0, function* () {
27251
27206
  return isEIP1559
27252
- ? evmSignTxEip1559(typedCall, addressN, tx)
27253
- : evmSignTx(typedCall, addressN, tx);
27207
+ ? evmSignTxEip1559({
27208
+ typedCall,
27209
+ addressN,
27210
+ tx: tx,
27211
+ supportTrezor: true,
27212
+ })
27213
+ : evmSignTx({ typedCall, addressN, tx: tx, supportTrezor: true });
27254
27214
  });
27255
27215
 
27256
27216
  class EVMSignTransaction extends BaseMethod {
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.22",
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.22",
29
+ "@onekeyfe/hd-transport": "^0.3.22",
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": "c6a9dda00f6a16ee19d9d6e3d417744f67e70c01"
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 });
@@ -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]?: {
@@ -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') {
@@ -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"}