Skip to content

Commit

Permalink
fix: Fix wording of allow warning message
Browse files Browse the repository at this point in the history
Hide transfer box if in allow mode
  • Loading branch information
beguene authored and aulneau committed Aug 27, 2021
1 parent 98fcd25 commit 44934c1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,16 @@ export const PostConditionModeWarning = () => {
</Box>
<Box>
<Text textStyle="body.small.medium" fontWeight={500}>
Calling this function is not secure.
This transaction is not secure
</Text>
<Text
textStyle="body.small"
color={color('text-caption')}
lineHeight="22px"
mt="extra-tight"
>
This function is set to <strong>ALLOW</strong> mode. Any post conditions defined will
have no effect.
<br />
<Box as="span" fontWeight={500} color={color('feedback-error')}>
Proceed with caution.
</Box>
If you confirm, you allow it to transfer any of your tokens. Only confirm if you trust
and have verified the contract.
</Text>
</Box>
</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import { stacksValue } from '@common/stacks-utils';
import { FiLock as IconLock } from 'react-icons/fi';
import { Body } from '@components/typography';
import { truncateMiddle } from '@stacks/ui-utils';

import { useTransactionRequest } from '@common/hooks/use-transaction-request';
import { TransactionEventCard } from '../event-card';
import { PostConditionComponent } from './single';
import { useAtomValue } from 'jotai/utils';
import { postConditionsState } from '@store/transactions/post-conditions';

import { usePostConditionModeState } from '@store/transactions/post-conditions.hooks';
import { PostConditionMode } from '@stacks/transactions';
import { IS_TEST_ENV } from '@common/constants';

function StxPostcondition() {
const pendingTransaction = useTransactionRequest();
if (!pendingTransaction || pendingTransaction.txType !== TransactionTypes.STXTransfer)
Expand Down Expand Up @@ -67,6 +70,7 @@ const PostConditionsList = () => {

export const PostConditionsSuspense: React.FC = () => {
const postConditions = useAtomValue(postConditionsState);
const mode = usePostConditionModeState();
const pendingTransaction = useTransactionRequest();
const hasPostConditions = useMemo(
() => postConditions && postConditions?.length > 0,
Expand All @@ -76,6 +80,7 @@ export const PostConditionsSuspense: React.FC = () => {
pendingTransaction?.txType === TransactionTypes.STXTransfer && !hasPostConditions;

if (!postConditions || !pendingTransaction) return <></>;
if (!IS_TEST_ENV && mode === PostConditionMode.Allow) return null;

return (
<Flex
Expand Down
2 changes: 1 addition & 1 deletion src/store/transactions/fungible-token-transfer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe(makeFungibleTokenTransferState.debugLabel || 'makeFungibleTokenTransfer
}
);
expect(result.current).toEqual(undefined);
await waitForNextUpdate();
await waitForNextUpdate({ timeout: 2000 });
expect(result.current?.stxAddress).toEqual('ST2PHCPANVT8DVPSY5W2ZZ81M285Q5Z8Y6DQMZE7Z');
expect(result.current?.assetName).toEqual('hey-token');
});
Expand Down

1 comment on commit 44934c1

@vercel
Copy link

@vercel vercel bot commented on 44934c1 Aug 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.