Skip to content

Commit

Permalink
fix: receiver not display (#2409)
Browse files Browse the repository at this point in the history
  • Loading branch information
vvvvvv1vvvvvv authored Jul 18, 2024
1 parent 1ac32cb commit e7c7056
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions src/ui/views/Approval/components/Actions/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,67 @@ export const fetchActionRequiredData = async ({
);
result.hasInteraction = hasInteraction.has_interaction;
});
queue.add(async () => {
const addr = actionData.common?.receiver;

if (addr) {
result.receiverInWallet = await wallet.hasAddress(addr);
const receiverData: ReceiverData = {
address: addr,
chain: chain!,
eoa: null,
cex: null,
contract: null,
usd_value: 0,
hasTransfer: false,
isTokenContract: false,
name: null,
onTransferWhitelist: false,
};

const { has_transfer } = await apiProvider.hasTransfer(
chainId,
address,
addr
);
receiverData.hasTransfer = has_transfer;

const { desc } = await apiProvider.addrDesc(addr);
if (desc.cex?.id) {
receiverData.cex = {
id: desc.cex.id,
logo: desc.cex.logo_url,
name: desc.cex.name,
bornAt: desc.born_at,
isDeposit: desc.cex.is_deposit,
};
}
if (desc.contract && Object.keys(desc.contract).length > 0) {
receiverData.contract = desc.contract;
}
if (!receiverData.cex && !receiverData.contract) {
receiverData.eoa = {
id: addr,
bornAt: desc.born_at,
};
}
receiverData.usd_value = desc.usd_value;
if (result.contract) {
const { is_token } = await apiProvider.isTokenContract(chainId, addr);
receiverData.isTokenContract = is_token;
}
receiverData.name = desc.name;
if (ALIAS_ADDRESS[addr.toLowerCase()]) {
receiverData.name = ALIAS_ADDRESS[addr.toLowerCase()];
}

const whitelist = await wallet.getWhitelist();
receiverData.onTransferWhitelist = whitelist.includes(
addr.toLowerCase()
);
result.unexpectedAddr = receiverData;
}
});
await waitQueueFinished(queue);
return result;
}
Expand Down

0 comments on commit e7c7056

Please sign in to comment.