@onekeyfe/hd-core 1.1.10-alpha.0 → 1.1.10-alpha.1
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.
|
@@ -5,6 +5,8 @@ export default class EVMSignTransaction extends BaseMethod {
|
|
|
5
5
|
isEIP1559: boolean;
|
|
6
6
|
isEIP7702: boolean;
|
|
7
7
|
formattedTx: EVMTransaction | EVMTransactionEIP1559 | EVMTransactionEIP7702 | undefined;
|
|
8
|
+
private hasEIP7702Features;
|
|
9
|
+
private hasEIP1559Features;
|
|
8
10
|
init(): void;
|
|
9
11
|
getVersionRange(): {
|
|
10
12
|
model_mini: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EVMSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/api/evm/EVMSignTransaction.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAEL,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAMrB,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,UAAU;IACxD,QAAQ,EAAE,MAAM,EAAE,CAAM;IAExB,SAAS,UAAS;IAElB,SAAS,UAAS;IAElB,WAAW,EAAE,cAAc,GAAG,qBAAqB,GAAG,qBAAqB,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"EVMSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/api/evm/EVMSignTransaction.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAEL,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAMrB,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,UAAU;IACxD,QAAQ,EAAE,MAAM,EAAE,CAAM;IAExB,SAAS,UAAS;IAElB,SAAS,UAAS;IAElB,WAAW,EAAE,cAAc,GAAG,qBAAqB,GAAG,qBAAqB,GAAG,SAAS,CAAC;IAMxF,OAAO,CAAC,kBAAkB;IAS1B,OAAO,CAAC,kBAAkB;IAI1B,IAAI;IA+CJ,eAAe;;;;;IAyBT,GAAG;CAyBV"}
|
package/dist/index.js
CHANGED
|
@@ -32265,7 +32265,7 @@ const evmSignTxEip7702 = ({ typedCall, addressN, tx, supportTrezor, }) => __awai
|
|
|
32265
32265
|
authorization_list: authorizationList.map(auth => ({
|
|
32266
32266
|
address_n: auth.addressN || [],
|
|
32267
32267
|
chain_id: auth.chainId,
|
|
32268
|
-
address: auth.address,
|
|
32268
|
+
address: addHexPrefix(auth.address),
|
|
32269
32269
|
nonce: stripHexStartZeroes(auth.nonce),
|
|
32270
32270
|
signature: auth.signature
|
|
32271
32271
|
? {
|
|
@@ -32312,6 +32312,13 @@ class EVMSignTransaction extends BaseMethod {
|
|
|
32312
32312
|
this.isEIP1559 = false;
|
|
32313
32313
|
this.isEIP7702 = false;
|
|
32314
32314
|
}
|
|
32315
|
+
hasEIP7702Features(tx) {
|
|
32316
|
+
const authList = tx.authorizationList;
|
|
32317
|
+
return !!(authList && Array.isArray(authList) && authList.length > 0);
|
|
32318
|
+
}
|
|
32319
|
+
hasEIP1559Features(tx) {
|
|
32320
|
+
return !!(tx.maxFeePerGas && tx.maxPriorityFeePerGas);
|
|
32321
|
+
}
|
|
32315
32322
|
init() {
|
|
32316
32323
|
this.checkDeviceId = true;
|
|
32317
32324
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -32322,8 +32329,8 @@ class EVMSignTransaction extends BaseMethod {
|
|
|
32322
32329
|
const { path, transaction } = this.payload;
|
|
32323
32330
|
this.addressN = validatePath(path, 3);
|
|
32324
32331
|
const tx = transaction;
|
|
32325
|
-
this.
|
|
32326
|
-
this.
|
|
32332
|
+
this.isEIP7702 = this.hasEIP7702Features(tx);
|
|
32333
|
+
this.isEIP1559 = this.hasEIP1559Features(tx) && !this.isEIP7702;
|
|
32327
32334
|
const schema = [
|
|
32328
32335
|
{ name: 'to', type: 'hexString', required: true },
|
|
32329
32336
|
{ name: 'value', type: 'hexString', required: true },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.1.10-alpha.
|
|
3
|
+
"version": "1.1.10-alpha.1",
|
|
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": "1.1.10-alpha.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.1.10-alpha.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.1.10-alpha.1",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.1.10-alpha.1",
|
|
30
30
|
"axios": "^0.27.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"bytebuffer": "^5.0.1",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"@types/web-bluetooth": "^0.0.21",
|
|
47
47
|
"ripple-keypairs": "^1.3.1"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "d4e21e9c899e22fdb925dd96c140138b476d7437"
|
|
50
50
|
}
|
|
@@ -23,6 +23,23 @@ export default class EVMSignTransaction extends BaseMethod {
|
|
|
23
23
|
|
|
24
24
|
formattedTx: EVMTransaction | EVMTransactionEIP1559 | EVMTransactionEIP7702 | undefined;
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Check if transaction has EIP7702 authorization list
|
|
28
|
+
* Following ethereumjs pattern for type detection
|
|
29
|
+
*/
|
|
30
|
+
private hasEIP7702Features(tx: EVMSignTransactionParams['transaction']): boolean {
|
|
31
|
+
const authList = (tx as EVMTransactionEIP7702).authorizationList;
|
|
32
|
+
return !!(authList && Array.isArray(authList) && authList.length > 0);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Check if transaction has EIP1559 fee market features
|
|
37
|
+
* Both maxFeePerGas and maxPriorityFeePerGas must be present
|
|
38
|
+
*/
|
|
39
|
+
private hasEIP1559Features(tx: EVMSignTransactionParams['transaction']): boolean {
|
|
40
|
+
return !!(tx.maxFeePerGas && tx.maxPriorityFeePerGas);
|
|
41
|
+
}
|
|
42
|
+
|
|
26
43
|
init() {
|
|
27
44
|
this.checkDeviceId = true;
|
|
28
45
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
|
|
@@ -36,8 +53,14 @@ export default class EVMSignTransaction extends BaseMethod {
|
|
|
36
53
|
|
|
37
54
|
const tx: EVMSignTransactionParams['transaction'] = transaction;
|
|
38
55
|
|
|
39
|
-
|
|
40
|
-
|
|
56
|
+
// Transaction type detection based on distinctive features
|
|
57
|
+
// Following ethereumjs pattern: check most specific features first
|
|
58
|
+
|
|
59
|
+
// EIP7702: Has authorizationList (extends EIP1559)
|
|
60
|
+
this.isEIP7702 = this.hasEIP7702Features(tx);
|
|
61
|
+
|
|
62
|
+
// EIP1559: Has EIP1559 fee fields but no authorizationList (extends EIP2930)
|
|
63
|
+
this.isEIP1559 = this.hasEIP1559Features(tx) && !this.isEIP7702;
|
|
41
64
|
|
|
42
65
|
// check if transaction is valid
|
|
43
66
|
const schema: SchemaParam[] = [
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
EVMTransactionEIP7702,
|
|
15
15
|
} from '../../../types';
|
|
16
16
|
import { cutString } from '../../helpers/stringUtils';
|
|
17
|
-
import { stripHexStartZeroes } from '../../helpers/hexUtils';
|
|
17
|
+
import { stripHexStartZeroes, addHexPrefix } from '../../helpers/hexUtils';
|
|
18
18
|
|
|
19
19
|
export const processTxRequest = async ({
|
|
20
20
|
typedCall,
|
|
@@ -245,7 +245,7 @@ export const evmSignTxEip7702 = async ({
|
|
|
245
245
|
authorization_list: authorizationList.map(auth => ({
|
|
246
246
|
address_n: auth.addressN || [],
|
|
247
247
|
chain_id: auth.chainId,
|
|
248
|
-
address: auth.address,
|
|
248
|
+
address: addHexPrefix(auth.address),
|
|
249
249
|
nonce: stripHexStartZeroes(auth.nonce),
|
|
250
250
|
signature: auth.signature
|
|
251
251
|
? {
|