@onekeyfe/hd-core 1.1.9-alpha.0 → 1.1.9
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/EVMSignTransaction.d.ts +2 -3
- package/dist/api/evm/EVMSignTransaction.d.ts.map +1 -1
- package/dist/api/evm/latest/signTransaction.d.ts +3 -10
- package/dist/api/evm/latest/signTransaction.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +1 -1
- package/dist/index.d.ts +4 -29
- package/dist/index.js +13 -192
- package/dist/inject.d.ts.map +1 -1
- package/dist/types/api/evmSignTransaction.d.ts +1 -26
- package/dist/types/api/evmSignTransaction.d.ts.map +1 -1
- package/dist/types/settings.d.ts +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +1 -1
- package/package.json +4 -4
- package/src/api/evm/EVMSignTransaction.ts +4 -25
- package/src/api/evm/latest/signTransaction.ts +4 -79
- package/src/data/messages/messages.json +0 -125
- package/src/data-manager/DataManager.ts +1 -1
- package/src/inject.ts +4 -3
- package/src/types/api/evmSignTransaction.ts +1 -29
- package/src/types/settings.ts +1 -1
- package/src/utils/deviceFeaturesUtils.ts +9 -9
- package/__tests__/evmSignTransactionEIP7702.test.ts +0 -216
- package/validate-eip7702.js +0 -120
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
import { EVMTransaction, EVMTransactionEIP1559
|
|
2
|
+
import { EVMTransaction, EVMTransactionEIP1559 } from '../../types';
|
|
3
3
|
export default class EVMSignTransaction extends BaseMethod {
|
|
4
4
|
addressN: number[];
|
|
5
5
|
isEIP1559: boolean;
|
|
6
|
-
|
|
7
|
-
formattedTx: EVMTransaction | EVMTransactionEIP1559 | EVMTransactionEIP7702 | undefined;
|
|
6
|
+
formattedTx: EVMTransaction | EVMTransactionEIP1559 | undefined;
|
|
8
7
|
init(): void;
|
|
9
8
|
getVersionRange(): {
|
|
10
9
|
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,EAA4B,cAAc,EAAE,qBAAqB,EAAE,
|
|
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,EAA4B,cAAc,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAM9F,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,UAAU;IACxD,QAAQ,EAAE,MAAM,EAAE,CAAM;IAExB,SAAS,UAAS;IAElB,WAAW,EAAE,cAAc,GAAG,qBAAqB,GAAG,SAAS,CAAC;IAEhE,IAAI;IAoCJ,eAAe;;;;;IAeT,GAAG;CAqBV"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EthereumTxRequestOneKey, TypedCall } from '@onekeyfe/hd-transport';
|
|
2
|
-
import { EVMSignedTx, EVMTransaction, EVMTransactionEIP1559
|
|
2
|
+
import { EVMSignedTx, EVMTransaction, EVMTransactionEIP1559 } from '../../../types';
|
|
3
3
|
export declare const processTxRequest: ({ typedCall, request, data, chainId, supportTrezor, }: {
|
|
4
4
|
typedCall: TypedCall;
|
|
5
5
|
request: EthereumTxRequestOneKey;
|
|
@@ -19,17 +19,10 @@ export declare const evmSignTxEip1559: ({ typedCall, addressN, tx, supportTrezor
|
|
|
19
19
|
tx: EVMTransactionEIP1559;
|
|
20
20
|
supportTrezor?: boolean | undefined;
|
|
21
21
|
}) => Promise<EVMSignedTx>;
|
|
22
|
-
export declare const
|
|
23
|
-
typedCall: TypedCall;
|
|
24
|
-
addressN: number[];
|
|
25
|
-
tx: EVMTransactionEIP7702;
|
|
26
|
-
supportTrezor?: boolean | undefined;
|
|
27
|
-
}) => Promise<EVMSignedTx>;
|
|
28
|
-
export declare const signTransaction: ({ typedCall, isEIP1559, isEIP7702, addressN, tx, }: {
|
|
22
|
+
export declare const signTransaction: ({ typedCall, isEIP1559, addressN, tx, }: {
|
|
29
23
|
addressN: number[];
|
|
30
|
-
tx: EVMTransaction | EVMTransactionEIP1559
|
|
24
|
+
tx: EVMTransaction | EVMTransactionEIP1559;
|
|
31
25
|
isEIP1559: boolean;
|
|
32
|
-
isEIP7702?: boolean | undefined;
|
|
33
26
|
typedCall: TypedCall;
|
|
34
27
|
}) => Promise<EVMSignedTx>;
|
|
35
28
|
//# sourceMappingURL=signTransaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signTransaction.d.ts","sourceRoot":"","sources":["../../../../src/api/evm/latest/signTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import type { AssetsMap, ConnectSettings, DeviceTypeMap, Features, IDeviceBLEFirmwareStatus, IDeviceFirmwareStatus, ITransportStatus, IVersionArray } from '../types';
|
|
2
|
-
export type IFirmwareField = 'firmware' | 'firmware-v2' | 'firmware-
|
|
2
|
+
export type IFirmwareField = 'firmware' | 'firmware-v2' | 'firmware-v7';
|
|
3
3
|
export type MessageVersion = 'latest' | 'v1';
|
|
4
4
|
export default class DataManager {
|
|
5
5
|
static deviceMap: DeviceTypeMap;
|
package/dist/index.d.ts
CHANGED
|
@@ -215,7 +215,7 @@ type DeviceTypeMap = {
|
|
|
215
215
|
[k in IKnownDevice]: {
|
|
216
216
|
firmware: IFirmwareReleaseInfo[];
|
|
217
217
|
'firmware-v2'?: IFirmwareReleaseInfo[];
|
|
218
|
-
'firmware-
|
|
218
|
+
'firmware-v7'?: IFirmwareReleaseInfo[];
|
|
219
219
|
ble: IBLEFirmwareReleaseInfo[];
|
|
220
220
|
};
|
|
221
221
|
};
|
|
@@ -791,34 +791,9 @@ type EVMTransactionEIP1559 = {
|
|
|
791
791
|
maxPriorityFeePerGas: string;
|
|
792
792
|
accessList?: EVMAccessList[];
|
|
793
793
|
};
|
|
794
|
-
type EVMAuthorizationSignature = {
|
|
795
|
-
yParity: number;
|
|
796
|
-
r: string;
|
|
797
|
-
s: string;
|
|
798
|
-
};
|
|
799
|
-
type EVMAuthorization = {
|
|
800
|
-
addressN?: number[];
|
|
801
|
-
chainId: number;
|
|
802
|
-
address: string;
|
|
803
|
-
nonce: string;
|
|
804
|
-
signature?: EVMAuthorizationSignature;
|
|
805
|
-
};
|
|
806
|
-
type EVMTransactionEIP7702 = {
|
|
807
|
-
to: string;
|
|
808
|
-
value: string;
|
|
809
|
-
gasLimit: string;
|
|
810
|
-
gasPrice?: typeof undefined;
|
|
811
|
-
nonce: string;
|
|
812
|
-
data?: string;
|
|
813
|
-
chainId: number;
|
|
814
|
-
maxFeePerGas: string;
|
|
815
|
-
maxPriorityFeePerGas: string;
|
|
816
|
-
accessList?: EVMAccessList[];
|
|
817
|
-
authorizationList: EVMAuthorization[];
|
|
818
|
-
};
|
|
819
794
|
type EVMSignTransactionParams = {
|
|
820
795
|
path: string | number[];
|
|
821
|
-
transaction: EVMTransaction | EVMTransactionEIP1559
|
|
796
|
+
transaction: EVMTransaction | EVMTransactionEIP1559;
|
|
822
797
|
};
|
|
823
798
|
declare function evmSignTransaction(connectId: string, deviceId: string, params: CommonParams & EVMSignTransactionParams): Response<EVMSignedTx>;
|
|
824
799
|
|
|
@@ -3145,7 +3120,7 @@ declare const getDeviceBLEFirmwareVersion: (features: Features) => IVersionArray
|
|
|
3145
3120
|
declare const getDeviceBootloaderVersion: (features: Features | undefined) => IVersionArray;
|
|
3146
3121
|
declare const getDeviceBoardloaderVersion: (features: Features) => IVersionArray;
|
|
3147
3122
|
|
|
3148
|
-
type IFirmwareField = 'firmware' | 'firmware-v2' | 'firmware-
|
|
3123
|
+
type IFirmwareField = 'firmware' | 'firmware-v2' | 'firmware-v7';
|
|
3149
3124
|
type MessageVersion = 'latest' | 'v1';
|
|
3150
3125
|
declare class DataManager {
|
|
3151
3126
|
static deviceMap: DeviceTypeMap;
|
|
@@ -3193,7 +3168,7 @@ declare const getFirmwareUpdateField: ({ features, updateType, targetVersion, }:
|
|
|
3193
3168
|
updateType: 'firmware' | 'ble';
|
|
3194
3169
|
targetVersion?: string | undefined;
|
|
3195
3170
|
}) => 'ble' | IFirmwareField;
|
|
3196
|
-
declare const getFirmwareUpdateFieldArray: (features: Features, updateType: 'firmware' | 'ble' | 'bootloader') => ('firmware' | 'ble' | 'firmware-v2' | 'firmware-
|
|
3171
|
+
declare const getFirmwareUpdateFieldArray: (features: Features, updateType: 'firmware' | 'ble' | 'bootloader') => ('firmware' | 'ble' | 'firmware-v2' | 'firmware-v7')[];
|
|
3197
3172
|
|
|
3198
3173
|
declare function checkNeedUpdateBootForTouch(features: Features): boolean;
|
|
3199
3174
|
declare function checkNeedUpdateBootForClassicAndMini(features: Features, willUpdateFirmware?: string): boolean;
|
package/dist/index.js
CHANGED
|
@@ -158,8 +158,8 @@ const createCoreApi = (call) => ({
|
|
|
158
158
|
const callbackId = generateCallbackId();
|
|
159
159
|
registerCallback(callbackId, onLoopItemResponse);
|
|
160
160
|
const callbackIdFinish = generateCallbackId();
|
|
161
|
-
registerCallback(callbackIdFinish, (data) => {
|
|
162
|
-
onAllItemsResponse === null || onAllItemsResponse === void 0 ? void 0 : onAllItemsResponse(data);
|
|
161
|
+
registerCallback(callbackIdFinish, (data, error) => {
|
|
162
|
+
onAllItemsResponse === null || onAllItemsResponse === void 0 ? void 0 : onAllItemsResponse(data, error);
|
|
163
163
|
cleanupCallback(callbackIdFinish);
|
|
164
164
|
cleanupCallback(callbackId);
|
|
165
165
|
});
|
|
@@ -6684,125 +6684,6 @@ var nested$1 = {
|
|
|
6684
6684
|
}
|
|
6685
6685
|
}
|
|
6686
6686
|
},
|
|
6687
|
-
EthereumAuthorizationSignature: {
|
|
6688
|
-
fields: {
|
|
6689
|
-
y_parity: {
|
|
6690
|
-
rule: "required",
|
|
6691
|
-
type: "uint32",
|
|
6692
|
-
id: 1
|
|
6693
|
-
},
|
|
6694
|
-
r: {
|
|
6695
|
-
rule: "required",
|
|
6696
|
-
type: "bytes",
|
|
6697
|
-
id: 2
|
|
6698
|
-
},
|
|
6699
|
-
s: {
|
|
6700
|
-
rule: "required",
|
|
6701
|
-
type: "bytes",
|
|
6702
|
-
id: 3
|
|
6703
|
-
}
|
|
6704
|
-
}
|
|
6705
|
-
},
|
|
6706
|
-
EthereumAuthorizationOneKey: {
|
|
6707
|
-
fields: {
|
|
6708
|
-
address_n: {
|
|
6709
|
-
rule: "repeated",
|
|
6710
|
-
type: "uint32",
|
|
6711
|
-
id: 1,
|
|
6712
|
-
options: {
|
|
6713
|
-
packed: false
|
|
6714
|
-
}
|
|
6715
|
-
},
|
|
6716
|
-
chain_id: {
|
|
6717
|
-
rule: "required",
|
|
6718
|
-
type: "uint64",
|
|
6719
|
-
id: 2
|
|
6720
|
-
},
|
|
6721
|
-
address: {
|
|
6722
|
-
rule: "required",
|
|
6723
|
-
type: "string",
|
|
6724
|
-
id: 3
|
|
6725
|
-
},
|
|
6726
|
-
nonce: {
|
|
6727
|
-
rule: "required",
|
|
6728
|
-
type: "bytes",
|
|
6729
|
-
id: 4
|
|
6730
|
-
},
|
|
6731
|
-
signature: {
|
|
6732
|
-
type: "EthereumAuthorizationSignature",
|
|
6733
|
-
id: 5
|
|
6734
|
-
}
|
|
6735
|
-
}
|
|
6736
|
-
},
|
|
6737
|
-
EthereumSignTxEIP7702OneKey: {
|
|
6738
|
-
fields: {
|
|
6739
|
-
address_n: {
|
|
6740
|
-
rule: "repeated",
|
|
6741
|
-
type: "uint32",
|
|
6742
|
-
id: 1,
|
|
6743
|
-
options: {
|
|
6744
|
-
packed: false
|
|
6745
|
-
}
|
|
6746
|
-
},
|
|
6747
|
-
nonce: {
|
|
6748
|
-
rule: "required",
|
|
6749
|
-
type: "bytes",
|
|
6750
|
-
id: 2
|
|
6751
|
-
},
|
|
6752
|
-
max_gas_fee: {
|
|
6753
|
-
rule: "required",
|
|
6754
|
-
type: "bytes",
|
|
6755
|
-
id: 3
|
|
6756
|
-
},
|
|
6757
|
-
max_priority_fee: {
|
|
6758
|
-
rule: "required",
|
|
6759
|
-
type: "bytes",
|
|
6760
|
-
id: 4
|
|
6761
|
-
},
|
|
6762
|
-
gas_limit: {
|
|
6763
|
-
rule: "required",
|
|
6764
|
-
type: "bytes",
|
|
6765
|
-
id: 5
|
|
6766
|
-
},
|
|
6767
|
-
to: {
|
|
6768
|
-
rule: "required",
|
|
6769
|
-
type: "string",
|
|
6770
|
-
id: 6
|
|
6771
|
-
},
|
|
6772
|
-
value: {
|
|
6773
|
-
rule: "required",
|
|
6774
|
-
type: "bytes",
|
|
6775
|
-
id: 7
|
|
6776
|
-
},
|
|
6777
|
-
data_initial_chunk: {
|
|
6778
|
-
type: "bytes",
|
|
6779
|
-
id: 8,
|
|
6780
|
-
options: {
|
|
6781
|
-
"default": ""
|
|
6782
|
-
}
|
|
6783
|
-
},
|
|
6784
|
-
data_length: {
|
|
6785
|
-
rule: "required",
|
|
6786
|
-
type: "uint32",
|
|
6787
|
-
id: 9
|
|
6788
|
-
},
|
|
6789
|
-
chain_id: {
|
|
6790
|
-
rule: "required",
|
|
6791
|
-
type: "uint64",
|
|
6792
|
-
id: 10
|
|
6793
|
-
},
|
|
6794
|
-
access_list: {
|
|
6795
|
-
rule: "repeated",
|
|
6796
|
-
type: "EthereumAccessListOneKey",
|
|
6797
|
-
id: 11
|
|
6798
|
-
},
|
|
6799
|
-
authorization_list: {
|
|
6800
|
-
rule: "repeated",
|
|
6801
|
-
type: "EthereumAuthorizationOneKey",
|
|
6802
|
-
id: 12
|
|
6803
|
-
}
|
|
6804
|
-
}
|
|
6805
|
-
},
|
|
6806
6687
|
EthereumTxRequestOneKey: {
|
|
6807
6688
|
fields: {
|
|
6808
6689
|
data_length: {
|
|
@@ -6820,11 +6701,6 @@ var nested$1 = {
|
|
|
6820
6701
|
signature_s: {
|
|
6821
6702
|
type: "bytes",
|
|
6822
6703
|
id: 4
|
|
6823
|
-
},
|
|
6824
|
-
authorization_signatures: {
|
|
6825
|
-
rule: "repeated",
|
|
6826
|
-
type: "EthereumAuthorizationSignature",
|
|
6827
|
-
id: 10
|
|
6828
6704
|
}
|
|
6829
6705
|
}
|
|
6830
6706
|
},
|
|
@@ -13419,7 +13295,6 @@ var nested$1 = {
|
|
|
13419
13295
|
MessageType_EthereumAddressOneKey: 20103,
|
|
13420
13296
|
MessageType_EthereumSignTxOneKey: 20104,
|
|
13421
13297
|
MessageType_EthereumSignTxEIP1559OneKey: 20105,
|
|
13422
|
-
MessageType_EthereumSignTxEIP7702OneKey: 20120,
|
|
13423
13298
|
MessageType_EthereumTxRequestOneKey: 20106,
|
|
13424
13299
|
MessageType_EthereumTxAckOneKey: 20107,
|
|
13425
13300
|
MessageType_EthereumSignMessageOneKey: 20108,
|
|
@@ -25294,21 +25169,21 @@ const getFirmwareUpdateField = ({ features, updateType, targetVersion, }) => {
|
|
|
25294
25169
|
return 'ble';
|
|
25295
25170
|
}
|
|
25296
25171
|
if (DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
25297
|
-
return 'firmware-
|
|
25172
|
+
return 'firmware-v7';
|
|
25298
25173
|
}
|
|
25299
25174
|
if (deviceType === hdShared.EDeviceType.Touch) {
|
|
25300
25175
|
if (targetVersion) {
|
|
25301
25176
|
if (semver__default["default"].eq(targetVersion, '4.0.0'))
|
|
25302
25177
|
return 'firmware-v2';
|
|
25303
25178
|
if (semver__default["default"].gt(targetVersion, '4.0.0'))
|
|
25304
|
-
return 'firmware-
|
|
25179
|
+
return 'firmware-v7';
|
|
25305
25180
|
}
|
|
25306
25181
|
if (semver__default["default"].lt(deviceFirmwareVersion.join('.'), '3.4.0'))
|
|
25307
25182
|
return 'firmware';
|
|
25308
|
-
return 'firmware-
|
|
25183
|
+
return 'firmware-v7';
|
|
25309
25184
|
}
|
|
25310
25185
|
if (deviceType === hdShared.EDeviceType.Pro) {
|
|
25311
|
-
return 'firmware-
|
|
25186
|
+
return 'firmware-v7';
|
|
25312
25187
|
}
|
|
25313
25188
|
return 'firmware';
|
|
25314
25189
|
};
|
|
@@ -25321,23 +25196,23 @@ const getFirmwareUpdateFieldArray = (features, updateType) => {
|
|
|
25321
25196
|
deviceType === 'classic1s' ||
|
|
25322
25197
|
deviceType === 'mini' ||
|
|
25323
25198
|
deviceType === 'classicpure') {
|
|
25324
|
-
return ['firmware-
|
|
25199
|
+
return ['firmware-v7'];
|
|
25325
25200
|
}
|
|
25326
25201
|
if (deviceType === 'touch') {
|
|
25327
25202
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
25328
25203
|
if (semver__default["default"].gt(currentVersion, '4.0.0')) {
|
|
25329
|
-
return ['firmware-
|
|
25204
|
+
return ['firmware-v7', 'firmware'];
|
|
25330
25205
|
}
|
|
25331
25206
|
if (semver__default["default"].gte(currentVersion, '4.0.0')) {
|
|
25332
25207
|
return ['firmware-v2', 'firmware'];
|
|
25333
25208
|
}
|
|
25334
25209
|
if (!currentVersion || semver__default["default"].lt(currentVersion, '3.0.0')) {
|
|
25335
|
-
return ['firmware-
|
|
25210
|
+
return ['firmware-v7', 'firmware-v2', 'firmware'];
|
|
25336
25211
|
}
|
|
25337
25212
|
return ['firmware'];
|
|
25338
25213
|
}
|
|
25339
25214
|
if (deviceType === 'pro') {
|
|
25340
|
-
return ['firmware-
|
|
25215
|
+
return ['firmware-v7'];
|
|
25341
25216
|
}
|
|
25342
25217
|
return ['firmware'];
|
|
25343
25218
|
};
|
|
@@ -32232,50 +32107,7 @@ const evmSignTxEip1559 = ({ typedCall, addressN, tx, supportTrezor, }) => __awai
|
|
|
32232
32107
|
}
|
|
32233
32108
|
return processTxRequest({ typedCall, request: response.message, data: rest, supportTrezor });
|
|
32234
32109
|
});
|
|
32235
|
-
const
|
|
32236
|
-
const { to, value, gasLimit, nonce, data, chainId, maxFeePerGas, maxPriorityFeePerGas, accessList, authorizationList, } = tx;
|
|
32237
|
-
const length = data == null ? 0 : data.length / 2;
|
|
32238
|
-
const [first, rest] = cutString(data, 1024 * 2);
|
|
32239
|
-
const message = {
|
|
32240
|
-
address_n: addressN,
|
|
32241
|
-
nonce: stripHexStartZeroes(nonce),
|
|
32242
|
-
max_gas_fee: stripHexStartZeroes(maxFeePerGas),
|
|
32243
|
-
max_priority_fee: stripHexStartZeroes(maxPriorityFeePerGas),
|
|
32244
|
-
gas_limit: stripHexStartZeroes(gasLimit),
|
|
32245
|
-
to,
|
|
32246
|
-
value: stripHexStartZeroes(value),
|
|
32247
|
-
data_length: length,
|
|
32248
|
-
data_initial_chunk: first,
|
|
32249
|
-
chain_id: chainId,
|
|
32250
|
-
access_list: (accessList || []).map(a => ({
|
|
32251
|
-
address: a.address,
|
|
32252
|
-
storage_keys: a.storageKeys,
|
|
32253
|
-
})),
|
|
32254
|
-
authorization_list: authorizationList.map(auth => ({
|
|
32255
|
-
address_n: auth.addressN || [],
|
|
32256
|
-
chain_id: auth.chainId,
|
|
32257
|
-
address: auth.address,
|
|
32258
|
-
nonce: stripHexStartZeroes(auth.nonce),
|
|
32259
|
-
signature: auth.signature ? {
|
|
32260
|
-
y_parity: auth.signature.yParity,
|
|
32261
|
-
r: auth.signature.r,
|
|
32262
|
-
s: auth.signature.s,
|
|
32263
|
-
} : undefined,
|
|
32264
|
-
})),
|
|
32265
|
-
};
|
|
32266
|
-
let response;
|
|
32267
|
-
if (supportTrezor) {
|
|
32268
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'EIP7702 not supported by Trezor');
|
|
32269
|
-
}
|
|
32270
|
-
else {
|
|
32271
|
-
response = yield typedCall('EthereumSignTxEIP7702OneKey', 'EthereumTxRequestOneKey', message);
|
|
32272
|
-
}
|
|
32273
|
-
return processTxRequest({ typedCall, request: response.message, data: rest, supportTrezor });
|
|
32274
|
-
});
|
|
32275
|
-
const signTransaction$1 = ({ typedCall, isEIP1559, isEIP7702, addressN, tx, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32276
|
-
if (isEIP7702) {
|
|
32277
|
-
return evmSignTxEip7702({ typedCall, addressN, tx: tx });
|
|
32278
|
-
}
|
|
32110
|
+
const signTransaction$1 = ({ typedCall, isEIP1559, addressN, tx, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32279
32111
|
return isEIP1559
|
|
32280
32112
|
? evmSignTxEip1559({ typedCall, addressN, tx: tx })
|
|
32281
32113
|
: evmSignTx({ typedCall, addressN, tx: tx });
|
|
@@ -32297,7 +32129,6 @@ class EVMSignTransaction extends BaseMethod {
|
|
|
32297
32129
|
super(...arguments);
|
|
32298
32130
|
this.addressN = [];
|
|
32299
32131
|
this.isEIP1559 = false;
|
|
32300
|
-
this.isEIP7702 = false;
|
|
32301
32132
|
}
|
|
32302
32133
|
init() {
|
|
32303
32134
|
this.checkDeviceId = true;
|
|
@@ -32310,7 +32141,6 @@ class EVMSignTransaction extends BaseMethod {
|
|
|
32310
32141
|
this.addressN = validatePath(path, 3);
|
|
32311
32142
|
const tx = transaction;
|
|
32312
32143
|
this.isEIP1559 = !!tx.maxFeePerGas && !!tx.maxPriorityFeePerGas;
|
|
32313
|
-
this.isEIP7702 = !!tx.authorizationList;
|
|
32314
32144
|
const schema = [
|
|
32315
32145
|
{ name: 'to', type: 'hexString', required: true },
|
|
32316
32146
|
{ name: 'value', type: 'hexString', required: true },
|
|
@@ -32319,12 +32149,7 @@ class EVMSignTransaction extends BaseMethod {
|
|
|
32319
32149
|
{ name: 'chainId', type: 'number', required: true },
|
|
32320
32150
|
{ name: 'data', type: 'hexString' },
|
|
32321
32151
|
];
|
|
32322
|
-
if (this.
|
|
32323
|
-
schema.push({ name: 'maxFeePerGas', type: 'hexString', required: true });
|
|
32324
|
-
schema.push({ name: 'maxPriorityFeePerGas', type: 'hexString', required: true });
|
|
32325
|
-
schema.push({ name: 'authorizationList', type: 'array', required: true });
|
|
32326
|
-
}
|
|
32327
|
-
else if (this.isEIP1559) {
|
|
32152
|
+
if (this.isEIP1559) {
|
|
32328
32153
|
schema.push({ name: 'maxFeePerGas', type: 'hexString', required: true });
|
|
32329
32154
|
schema.push({ name: 'maxPriorityFeePerGas', type: 'hexString', required: true });
|
|
32330
32155
|
}
|
|
@@ -32351,13 +32176,10 @@ class EVMSignTransaction extends BaseMethod {
|
|
|
32351
32176
|
}
|
|
32352
32177
|
run() {
|
|
32353
32178
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32354
|
-
const { addressN, isEIP1559,
|
|
32179
|
+
const { addressN, isEIP1559, formattedTx } = this;
|
|
32355
32180
|
if (formattedTx == null)
|
|
32356
32181
|
throw hdShared.ERRORS.TypedError('Runtime', 'formattedTx is not set');
|
|
32357
32182
|
if (TransportManager.getMessageVersion() === 'v1') {
|
|
32358
|
-
if (isEIP7702) {
|
|
32359
|
-
throw hdShared.ERRORS.TypedError('Runtime', 'EIP7702 not supported in legacy mode');
|
|
32360
|
-
}
|
|
32361
32183
|
return signTransaction({
|
|
32362
32184
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
32363
32185
|
addressN,
|
|
@@ -32370,7 +32192,6 @@ class EVMSignTransaction extends BaseMethod {
|
|
|
32370
32192
|
addressN,
|
|
32371
32193
|
tx: formattedTx,
|
|
32372
32194
|
isEIP1559,
|
|
32373
|
-
isEIP7702,
|
|
32374
32195
|
});
|
|
32375
32196
|
});
|
|
32376
32197
|
}
|
package/dist/inject.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject.d.ts","sourceRoot":"","sources":["../src/inject.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"inject.d.ts","sourceRoot":"","sources":["../src/inject.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAetC,QAAA,MAAM,eAAe,OAAQ,MAAM,WAAW,GAAG,EAAE,SAKlD,CAAC;AAEF,QAAA,MAAM,eAAe,OAAQ,MAAM,SAElC,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,CAAC;AAE5C,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,UAAU,CAAC;IACjB,YAAY,EAAE,YAAY,CAAC;IAC3B,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACtB,cAAc,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC1C,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5B,UAAU,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAClC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC1B,eAAe,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC7C;AAED,eAAO,MAAM,MAAM,gGAShB,SAAS,KAAG,OAiCd,CAAC;AAEF,eAAO,MAAM,aAAa,SAClB,OAAO,CAAC,MAAM,CAAC,KACpB,KACD,OAAO,EACL,IAAI,GACJ,KAAK,GACL,MAAM,GACN,oBAAoB,GACpB,MAAM,GACN,MAAM,GACN,SAAS,GACT,YAAY,GACZ,QAAQ,GACR,gBAAgB,GAChB,iBAAiB,CAiTnB,CAAC"}
|
|
@@ -32,34 +32,9 @@ export type EVMTransactionEIP1559 = {
|
|
|
32
32
|
maxPriorityFeePerGas: string;
|
|
33
33
|
accessList?: EVMAccessList[];
|
|
34
34
|
};
|
|
35
|
-
export type EVMAuthorizationSignature = {
|
|
36
|
-
yParity: number;
|
|
37
|
-
r: string;
|
|
38
|
-
s: string;
|
|
39
|
-
};
|
|
40
|
-
export type EVMAuthorization = {
|
|
41
|
-
addressN?: number[];
|
|
42
|
-
chainId: number;
|
|
43
|
-
address: string;
|
|
44
|
-
nonce: string;
|
|
45
|
-
signature?: EVMAuthorizationSignature;
|
|
46
|
-
};
|
|
47
|
-
export type EVMTransactionEIP7702 = {
|
|
48
|
-
to: string;
|
|
49
|
-
value: string;
|
|
50
|
-
gasLimit: string;
|
|
51
|
-
gasPrice?: typeof undefined;
|
|
52
|
-
nonce: string;
|
|
53
|
-
data?: string;
|
|
54
|
-
chainId: number;
|
|
55
|
-
maxFeePerGas: string;
|
|
56
|
-
maxPriorityFeePerGas: string;
|
|
57
|
-
accessList?: EVMAccessList[];
|
|
58
|
-
authorizationList: EVMAuthorization[];
|
|
59
|
-
};
|
|
60
35
|
export type EVMSignTransactionParams = {
|
|
61
36
|
path: string | number[];
|
|
62
|
-
transaction: EVMTransaction | EVMTransactionEIP1559
|
|
37
|
+
transaction: EVMTransaction | EVMTransactionEIP1559;
|
|
63
38
|
};
|
|
64
39
|
export declare function evmSignTransaction(connectId: string, deviceId: string, params: CommonParams & EVMSignTransactionParams): Response<EVMSignedTx>;
|
|
65
40
|
//# sourceMappingURL=evmSignTransaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evmSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/types/api/evmSignTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,MAAM,WAAW,GAAG;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,SAAS,CAAC;IAChC,oBAAoB,CAAC,EAAE,OAAO,SAAS,CAAC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,SAAS,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"evmSignTransaction.d.ts","sourceRoot":"","sources":["../../../src/types/api/evmSignTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,MAAM,WAAW,GAAG;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,SAAS,CAAC;IAChC,oBAAoB,CAAC,EAAE,OAAO,SAAS,CAAC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,SAAS,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,WAAW,EAAE,cAAc,GAAG,qBAAqB,CAAC;CACrD,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GAAG,wBAAwB,GAC9C,QAAQ,CAAC,WAAW,CAAC,CAAC"}
|
package/dist/types/settings.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export type DeviceTypeMap = {
|
|
|
56
56
|
[k in IKnownDevice]: {
|
|
57
57
|
firmware: IFirmwareReleaseInfo[];
|
|
58
58
|
'firmware-v2'?: IFirmwareReleaseInfo[];
|
|
59
|
-
'firmware-
|
|
59
|
+
'firmware-v7'?: IFirmwareReleaseInfo[];
|
|
60
60
|
ble: IBLEFirmwareReleaseInfo[];
|
|
61
61
|
};
|
|
62
62
|
};
|
|
@@ -33,7 +33,7 @@ export declare const getFirmwareUpdateField: ({ features, updateType, targetVers
|
|
|
33
33
|
updateType: 'firmware' | 'ble';
|
|
34
34
|
targetVersion?: string | undefined;
|
|
35
35
|
}) => 'ble' | IFirmwareField;
|
|
36
|
-
export declare const getFirmwareUpdateFieldArray: (features: Features, updateType: 'firmware' | 'ble' | 'bootloader') => ('firmware' | 'ble' | 'firmware-v2' | 'firmware-
|
|
36
|
+
export declare const getFirmwareUpdateFieldArray: (features: Features, updateType: 'firmware' | 'ble' | 'bootloader') => ('firmware' | 'ble' | 'firmware-v2' | 'firmware-v7')[];
|
|
37
37
|
export declare function fixVersion(version: string): string;
|
|
38
38
|
export declare const fixFeaturesFirmwareVersion: (features: Features) => Features;
|
|
39
39
|
//# sourceMappingURL=deviceFeaturesUtils.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.1.9
|
|
3
|
+
"version": "1.1.9",
|
|
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.9
|
|
29
|
-
"@onekeyfe/hd-transport": "1.1.9
|
|
28
|
+
"@onekeyfe/hd-shared": "1.1.9",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.1.9",
|
|
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": "3a222a7fef017b55554a544dbdcbb1810c642d39"
|
|
50
50
|
}
|
|
@@ -3,7 +3,7 @@ import { UI_REQUEST } from '../../constants/ui-request';
|
|
|
3
3
|
import { validatePath } from '../helpers/pathUtils';
|
|
4
4
|
import { BaseMethod } from '../BaseMethod';
|
|
5
5
|
import { SchemaParam, validateParams } from '../helpers/paramsValidator';
|
|
6
|
-
import { EVMSignTransactionParams, EVMTransaction, EVMTransactionEIP1559
|
|
6
|
+
import { EVMSignTransactionParams, EVMTransaction, EVMTransactionEIP1559 } from '../../types';
|
|
7
7
|
import { formatAnyHex } from '../helpers/hexUtils';
|
|
8
8
|
import TransportManager from '../../data-manager/TransportManager';
|
|
9
9
|
import { signTransaction } from './latest/signTransaction';
|
|
@@ -14,9 +14,7 @@ export default class EVMSignTransaction extends BaseMethod {
|
|
|
14
14
|
|
|
15
15
|
isEIP1559 = false;
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
formattedTx: EVMTransaction | EVMTransactionEIP1559 | EVMTransactionEIP7702 | undefined;
|
|
17
|
+
formattedTx: EVMTransaction | EVMTransactionEIP1559 | undefined;
|
|
20
18
|
|
|
21
19
|
init() {
|
|
22
20
|
this.checkDeviceId = true;
|
|
@@ -32,7 +30,6 @@ export default class EVMSignTransaction extends BaseMethod {
|
|
|
32
30
|
const tx: EVMSignTransactionParams['transaction'] = transaction;
|
|
33
31
|
|
|
34
32
|
this.isEIP1559 = !!tx.maxFeePerGas && !!tx.maxPriorityFeePerGas;
|
|
35
|
-
this.isEIP7702 = !!(tx as EVMTransactionEIP7702).authorizationList;
|
|
36
33
|
|
|
37
34
|
// check if transaction is valid
|
|
38
35
|
const schema: SchemaParam[] = [
|
|
@@ -43,11 +40,7 @@ export default class EVMSignTransaction extends BaseMethod {
|
|
|
43
40
|
{ name: 'chainId', type: 'number', required: true },
|
|
44
41
|
{ name: 'data', type: 'hexString' },
|
|
45
42
|
];
|
|
46
|
-
if (this.
|
|
47
|
-
schema.push({ name: 'maxFeePerGas', type: 'hexString', required: true });
|
|
48
|
-
schema.push({ name: 'maxPriorityFeePerGas', type: 'hexString', required: true });
|
|
49
|
-
schema.push({ name: 'authorizationList', type: 'array', required: true });
|
|
50
|
-
} else if (this.isEIP1559) {
|
|
43
|
+
if (this.isEIP1559) {
|
|
51
44
|
schema.push({ name: 'maxFeePerGas', type: 'hexString', required: true });
|
|
52
45
|
schema.push({ name: 'maxPriorityFeePerGas', type: 'hexString', required: true });
|
|
53
46
|
} else {
|
|
@@ -60,16 +53,6 @@ export default class EVMSignTransaction extends BaseMethod {
|
|
|
60
53
|
}
|
|
61
54
|
|
|
62
55
|
getVersionRange() {
|
|
63
|
-
// if (this.isEIP7702) {
|
|
64
|
-
// return {
|
|
65
|
-
// model_mini: {
|
|
66
|
-
// min: '3.0.0', // EIP7702 requires newer firmware
|
|
67
|
-
// },
|
|
68
|
-
// model_touch:{
|
|
69
|
-
// min: '2.8.0'
|
|
70
|
-
// }
|
|
71
|
-
// };
|
|
72
|
-
// }
|
|
73
56
|
if (this.isEIP1559) {
|
|
74
57
|
return {
|
|
75
58
|
model_mini: {
|
|
@@ -85,14 +68,11 @@ export default class EVMSignTransaction extends BaseMethod {
|
|
|
85
68
|
}
|
|
86
69
|
|
|
87
70
|
async run() {
|
|
88
|
-
const { addressN, isEIP1559,
|
|
71
|
+
const { addressN, isEIP1559, formattedTx } = this;
|
|
89
72
|
|
|
90
73
|
if (formattedTx == null) throw ERRORS.TypedError('Runtime', 'formattedTx is not set');
|
|
91
74
|
|
|
92
75
|
if (TransportManager.getMessageVersion() === 'v1') {
|
|
93
|
-
if (isEIP7702) {
|
|
94
|
-
throw ERRORS.TypedError('Runtime', 'EIP7702 not supported in legacy mode');
|
|
95
|
-
}
|
|
96
76
|
return signTransactionLegacyV1({
|
|
97
77
|
typedCall: this.device.commands.typedCall.bind(this.device.commands),
|
|
98
78
|
addressN,
|
|
@@ -106,7 +86,6 @@ export default class EVMSignTransaction extends BaseMethod {
|
|
|
106
86
|
addressN,
|
|
107
87
|
tx: formattedTx,
|
|
108
88
|
isEIP1559,
|
|
109
|
-
isEIP7702,
|
|
110
89
|
});
|
|
111
90
|
}
|
|
112
91
|
}
|