Skip to content

Commit

Permalink
Merge pull request #39 from DAOBuidler/fix/function_data_is_undefined
Browse files Browse the repository at this point in the history
fix: constList.params[0].data is undefined
  • Loading branch information
creeep123 authored Sep 2, 2022
2 parents 74373d3 + 6a77dc3 commit 272fb60
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/content-scripts-proxy-ethereum/ProxyEthereum.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,31 @@ export default class ProxyEthereum {

isNotableAction(constList) {
// 检查是否为关注的交易
const notableActionList = ['approve', 'setApprovalForAll', 'transfer', 'safeTransferFrom', 'safeTransferFrom1'];
if (typeof constList.method !== 'undefined') {
if (constList.method === 'eth_sendTransaction') {
const functionName = dictionary[constList.params[0].data.substring(0, 10)];
if (notableActionList.includes(functionName)) {
return { result: true, action: functionName };
try {
const notableActionList = ['approve', 'setApprovalForAll', 'transfer', 'safeTransferFrom', 'safeTransferFrom1'];
if (typeof constList.method !== 'undefined') {
if (constList.method === 'eth_sendTransaction') {
let functionName;

// 当 params 长度为 0 或 params[0].data 为 undefined 时
if (constList.params.length === 0) {
functionName = 'transfer';
} else if (constList.params[0].data === undefined) {
functionName = 'transfer';
} else {
functionName = dictionary[constList.params[0].data.substring(0, 10)];
}

if (notableActionList.includes(functionName)) {
return { result: true, action: functionName };
}
}
}
return { result: false };

} catch (error) {
return { result: false };
}
return { result: false };
}

getDrawerType(domainVerificationData) {
Expand Down

0 comments on commit 272fb60

Please sign in to comment.