Skip to content
This repository was archived by the owner on Nov 23, 2023. It is now read-only.

Commit da7872c

Browse files
committed
fixup! feat: Support Ethereum EIP-712 Sign Typed Data
Remove intermediate variables (added for FlowType) and just destructure.
1 parent d9bbb80 commit da7872c

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/js/core/methods/EthereumSignTypedData.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ import { validatePath } from '../../utils/pathUtils';
66
import { getEthereumNetwork } from '../../data/CoinInfo';
77
import { toChecksumAddress, getNetworkLabel } from '../../utils/ethereumUtils';
88
import type { CoreMessage, EthereumNetworkInfo } from '../../types';
9-
import type {
10-
MessageResponse,
11-
EthereumTypedDataSignature,
12-
EthereumTypedDataStructAck,
13-
EthereumTypedDataValueRequest,
14-
} from '../../types/trezor/protobuf';
9+
import type { MessageResponse, EthereumTypedDataStructAck } from '../../types/trezor/protobuf';
1510
import { ERRORS } from '../../constants';
1611
import type { EthereumSignTypedData as EthereumSignTypedDataParams } from '../../types/networks/ethereum';
1712
import { getFieldType, parseArrayType, encodeData } from './helpers/ethereumSignTypedData';
@@ -104,8 +99,7 @@ export default class EthereumSignTypedData extends AbstractMethod {
10499
// sending the whole message to be signed
105100
while (response.type === 'EthereumTypedDataValueRequest') {
106101
// $FlowIssue disjoint union Refinements not working, TODO: check if new Flow versions fix this
107-
const valueRequestMessage: EthereumTypedDataValueRequest = response.message;
108-
const { member_path } = valueRequestMessage;
102+
const { member_path } = response.message;
109103

110104
let memberData;
111105
let memberTypeName;
@@ -160,10 +154,10 @@ export default class EthereumSignTypedData extends AbstractMethod {
160154
}
161155

162156
// $FlowIssue disjoint union Refinements not working, TODO: check if new Flow versions fix this
163-
const signatureMessage: EthereumTypedDataSignature = response.message;
157+
const { address, signature } = response.message;
164158
return {
165-
address: toChecksumAddress(signatureMessage.address, network),
166-
signature: `0x${signatureMessage.signature}`,
159+
address: toChecksumAddress(address, network),
160+
signature: `0x${signature}`,
167161
};
168162
}
169163
}

0 commit comments

Comments
 (0)