Skip to content

Commit

Permalink
fix: allow no chainId for permit (#2195)
Browse files Browse the repository at this point in the history
  • Loading branch information
vvvvvv1vvvvvv authored Apr 12, 2024
1 parent 1cb57e1 commit 416f4ae
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ const GlobalStyle = createGlobalStyle`

interface Props {
address: string;
chain: Chain;
onWhitelist: boolean;
onBlacklist: boolean;
onChange({
Expand All @@ -82,7 +81,6 @@ interface Props {

const UserListDrawer = ({
address,
chain,
onWhitelist,
onBlacklist,
onChange,
Expand Down Expand Up @@ -147,7 +145,7 @@ export default ({
onChange,
}: {
address: string;
chain: Chain;
chain?: Chain;
onWhitelist: boolean;
onBlacklist: boolean;
onChange({
Expand All @@ -162,7 +160,6 @@ export default ({
content: (
<UserListDrawer
address={address}
chain={chain}
onWhitelist={onWhitelist}
onBlacklist={onBlacklist}
onChange={(res) => {
Expand All @@ -174,7 +171,7 @@ export default ({
height: 240,
closable: true,
title: i18n.t('page.signTx.myMarkWithContract', {
chainName: chain.name,
chainName: chain?.name,
}),
className: 'user-list-drawer',
onClose: () => destroy(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ const AddressMark = ({
onWhitelist: boolean;
onBlacklist: boolean;
address: string;
chain: Chain;
chain?: Chain;
isContract?: boolean;
onChange(): void;
}) => {
const chainId = chain.serverId;
const chainId = chain?.serverId;
const wallet = useWallet();
const dispatch = useRabbyDispatch();
const { t } = useTranslation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { isSameAddress } from '@/ui/utils';

interface SpenderData {
spender: string;
chain: Chain;
chain?: Chain;
protocol: {
name: string;
logo_url: string;
Expand Down Expand Up @@ -41,12 +41,12 @@ export const SpenderPopup: React.FC<Props> = ({ data }) => {
isInBlackList: contractBlacklist.some(
({ address, chainId }) =>
isSameAddress(address, data.spender) &&
chainId === data.chain.serverId
chainId === data.chain?.serverId
),
isInWhiteList: contractWhitelist.some(
({ address, chainId }) =>
isSameAddress(address, data.spender) &&
chainId === data.chain.serverId
chainId === data.chain?.serverId
),
};
}, [data.spender, data.chain, contractBlacklist, contractWhitelist]);
Expand Down Expand Up @@ -111,7 +111,7 @@ export const SpenderPopup: React.FC<Props> = ({ data }) => {
{data.rank
? t('page.signTx.contractPopularity', [
data.rank,
data.chain.name,
data.chain?.name,
])
: '-'}
</Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Permit = ({
}: {
data: TypedDataActionData['permit'];
requireData: ApproveTokenRequireData;
chain: Chain;
chain?: Chain;
engineResults: Result[];
}) => {
const actionData = data!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ const Actions = ({
<>
{(data?.actionType || data?.actionType === null) && (
<div className="container">
{data.permit && chain && (
{data.permit && (
<Permit
data={data.permit}
requireData={requireData as ApproveTokenRequireData}
Expand Down

0 comments on commit 416f4ae

Please sign in to comment.