@onekeyfe/hd-core 0.3.20 → 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.
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/evm/latest/signTransaction.d.ts +12 -0
- package/dist/api/evm/latest/signTransaction.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/signTransaction.d.ts.map +1 -1
- package/dist/{data/messages-config/index.d.ts → data-manager/MessagesConfig.d.ts} +3 -3
- package/dist/data-manager/MessagesConfig.d.ts.map +1 -0
- package/dist/index.js +17 -56
- package/package.json +4 -4
- package/src/api/evm/EVMSignTypedData.ts +7 -5
- package/src/api/evm/latest/signTransaction.ts +2 -2
- package/src/api/evm/legacyV1/signTransaction.ts +9 -85
- package/src/{data/messages-config/index.ts → data-manager/MessagesConfig.ts} +2 -2
- package/src/utils/deviceFeaturesUtils.ts +1 -1
- package/dist/data/messages-config/index.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EVMSignTypedData.d.ts","sourceRoot":"","sources":["../../../src/api/evm/EVMSignTypedData.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,UAAU,EACV,eAAe,EACf,SAAS,EACV,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,OAAO,KAAK,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAQ5F,oBAAY,sBAAsB,GAAG;IACnC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,IAAI,EAAE,4BAA4B,CAAC,0BAA0B,CAAC,CAAC;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,UAAU,CAAC,sBAAsB,CAAC;IAC9E,IAAI;IAqCE,mBAAmB,CAAC,EACxB,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,aAAa,GACd,EAAE;QACD,SAAS,EAAE,SAAS,CAAC;QACrB,QAAQ,EAAE,4BAA4B,CAAC,0BAA0B,CAAC,CAAC;QACnE,QAAQ,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;QACtC,aAAa,EAAE,OAAO,CAAC;KACxB;;;;IAuIK,aAAa;;;;IAsCnB,aAAa,CAAC,EACZ,SAAS,EACT,QAAQ,EACR,OAAO,EACP,UAAU,EACV,WAAW,GACZ,EAAE;QACD,SAAS,EAAE,SAAS,CAAC;QACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;KACjC;IA4BD,eAAe;;;;;IAQf,aAAa,CAAC,IAAI,EAAE,4BAA4B,CAAC,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"EVMSignTypedData.d.ts","sourceRoot":"","sources":["../../../src/api/evm/EVMSignTypedData.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,UAAU,EACV,eAAe,EACf,SAAS,EACV,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,OAAO,KAAK,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAQ5F,oBAAY,sBAAsB,GAAG;IACnC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,IAAI,EAAE,4BAA4B,CAAC,0BAA0B,CAAC,CAAC;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,UAAU,CAAC,sBAAsB,CAAC;IAC9E,IAAI;IAqCE,mBAAmB,CAAC,EACxB,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,aAAa,GACd,EAAE;QACD,SAAS,EAAE,SAAS,CAAC;QACrB,QAAQ,EAAE,4BAA4B,CAAC,0BAA0B,CAAC,CAAC;QACnE,QAAQ,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;QACtC,aAAa,EAAE,OAAO,CAAC;KACxB;;;;IAuIK,aAAa;;;;IAsCnB,aAAa,CAAC,EACZ,SAAS,EACT,QAAQ,EACR,OAAO,EACP,UAAU,EACV,WAAW,GACZ,EAAE;QACD,SAAS,EAAE,SAAS,CAAC;QACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;KACjC;IA4BD,eAAe;;;;;IAQf,aAAa,CAAC,IAAI,EAAE,4BAA4B,CAAC,0BAA0B,CAAC;IAiB5E,eAAe,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO;IA8BnC,gBAAgB;IAcV,GAAG;CAsEV"}
|
|
@@ -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;
|
|
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,
|
|
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 '
|
|
2
|
-
import { MessageVersion } from '
|
|
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=
|
|
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
|
|
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
|
|
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
|
|
27202
|
-
: evmSignTx
|
|
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(
|
|
27253
|
-
|
|
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 {
|
|
@@ -27694,13 +27654,14 @@ class EVMSignTypedData extends BaseMethod {
|
|
|
27694
27654
|
const data = lodash.get(item.message, 'data', undefined);
|
|
27695
27655
|
if (!data)
|
|
27696
27656
|
return false;
|
|
27697
|
-
let biggerLimit =
|
|
27657
|
+
let biggerLimit = 1024;
|
|
27698
27658
|
const currentVersion = getDeviceFirmwareVersion(this.device.features).join('.');
|
|
27699
|
-
const
|
|
27700
|
-
if (semver__default["default"].
|
|
27701
|
-
biggerLimit =
|
|
27659
|
+
const supportBiggerDataVersion = '4.4.0';
|
|
27660
|
+
if (semver__default["default"].gte(currentVersion, supportBiggerDataVersion)) {
|
|
27661
|
+
biggerLimit = 1536;
|
|
27702
27662
|
}
|
|
27703
|
-
|
|
27663
|
+
const startIndex = data.startsWith('0x') ? 2 : 0;
|
|
27664
|
+
return (data.length - startIndex) / 2 > biggerLimit;
|
|
27704
27665
|
}
|
|
27705
27666
|
hasNestedArrays(item) {
|
|
27706
27667
|
if (!item)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "0.3.
|
|
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.
|
|
29
|
-
"@onekeyfe/hd-transport": "^0.3.
|
|
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": "
|
|
47
|
+
"gitHead": "c6a9dda00f6a16ee19d9d6e3d417744f67e70c01"
|
|
48
48
|
}
|
|
@@ -304,15 +304,17 @@ export default class EVMSignTypedData extends BaseMethod<EVMSignTypedDataParams>
|
|
|
304
304
|
const data = get(item.message, 'data', undefined) as string | undefined;
|
|
305
305
|
if (!data) return false;
|
|
306
306
|
|
|
307
|
-
let biggerLimit =
|
|
307
|
+
let biggerLimit = 1024; // 1k
|
|
308
|
+
|
|
308
309
|
const currentVersion = getDeviceFirmwareVersion(this.device.features).join('.');
|
|
309
|
-
const
|
|
310
|
+
const supportBiggerDataVersion = '4.4.0';
|
|
310
311
|
|
|
311
|
-
if (semver.
|
|
312
|
-
biggerLimit =
|
|
312
|
+
if (semver.gte(currentVersion, supportBiggerDataVersion)) {
|
|
313
|
+
biggerLimit = 1536; // 1.5k
|
|
313
314
|
}
|
|
314
315
|
|
|
315
|
-
|
|
316
|
+
const startIndex = data.startsWith('0x') ? 2 : 0;
|
|
317
|
+
return (data.length - startIndex) / 2 > biggerLimit;
|
|
316
318
|
}
|
|
317
319
|
|
|
318
320
|
hasNestedArrays(item: any): boolean {
|
|
@@ -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 {
|
|
1
|
+
import { TypedCall } from '@onekeyfe/hd-transport';
|
|
2
2
|
import { EVMTransaction, EVMTransactionEIP1559 } from '../../../types';
|
|
3
|
-
import {
|
|
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(
|
|
99
|
-
|
|
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 '
|
|
2
|
-
import { MessageVersion } from '
|
|
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/
|
|
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"}
|