Skip to content

Commit

Permalink
code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
zerts committed Jun 19, 2024
1 parent 0f81d15 commit d7e0325
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/shared/analytics/analytics.background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ function trackAppEvents({ account }: { account: Account }) {
emitter.on('preferencesChange', (state, prevState) => {
if (state.enableHoldToSignButton !== prevState.enableHoldToSignButton) {
const params = createBaseParams({
request_name: 'change_permissions',
request_name: 'hold_to_sign_prerefence',
active: Boolean(state.enableHoldToSignButton),
});
const mixpanelParams = omit(params, ['request_name']);
Expand Down
2 changes: 1 addition & 1 deletion src/shared/analytics/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type MetabaseEvent =
| 'loader_screen_view'
| 'eip_6963_support'
| 'add_wallet'
| 'change_permissions';
| 'hold_to_sign_prerefence';

type BaseParams<E = MetabaseEvent> = { request_name: E };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ export const SignTransactionButton = React.forwardRef(
buttonTitle,
onClick,
buttonKind = 'primary',
holdToSign,
holdToSignAllowed,
...buttonProps
}: React.ButtonHTMLAttributes<HTMLButtonElement> & {
wallet: ExternallyOwnedAccount;
buttonTitle?: React.ReactNode;
buttonKind?: ButtonKind;
holdToSign: boolean;
holdToSignAllowed: boolean;
},
ref: React.Ref<SendTxBtnHandle>
) {
Expand Down Expand Up @@ -79,6 +79,8 @@ export const SignTransactionButton = React.forwardRef(
},
});

const holdToSign = holdToSignAllowed && preferences?.enableHoldToSignButton;

const { mutateAsync: sendTransaction, ...sendTxMutation } = useMutation({
mutationFn: async (params: SendTxParams) => {
const result = await sendTransactionInner(params);
Expand Down Expand Up @@ -112,7 +114,7 @@ export const SignTransactionButton = React.forwardRef(
return null;
}

return holdToSign && preferences.enableHoldToSignButton ? (
return holdToSign ? (
<HoldableButton
text={`Hold to ${title}`}
successText={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ function CancelTxContent({
wallet={wallet}
ref={signTxBtnRef}
onClick={() => sendTransaction()}
holdToSign={true}
holdToSignAllowed={true}
/>
</div>
</VStack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export function SpeedUp({
wallet={wallet}
ref={signTxBtnRef}
onClick={() => sendTransaction()}
holdToSign={true}
holdToSignAllowed={true}
/>
</div>
</VStack>
Expand Down
2 changes: 1 addition & 1 deletion src/ui/pages/SendForm/SendForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ export function SendForm() {
form={formId}
wallet={wallet}
disabled={isLoading}
holdToSign={false}
holdToSignAllowed={false}
/>
) : null}
</VStack>
Expand Down
2 changes: 1 addition & 1 deletion src/ui/pages/SendTransaction/SendTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ function SendTransactionContent({
buttonTitle={
interpretationHasCriticalWarning ? 'Proceed Anyway' : undefined
}
holdToSign={true}
holdToSignAllowed={true}
/>
</div>
</VStack>
Expand Down
4 changes: 2 additions & 2 deletions src/ui/pages/SwapForm/SwapForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ export function SwapForm() {
approveMutation.isLoading ||
approveTxStatus === 'pending'
}
holdToSign={false}
holdToSignAllowed={false}
>
Approve {spendPosition?.asset.symbol ?? null}
</SignTransactionButton>
Expand Down Expand Up @@ -783,7 +783,7 @@ export function SwapForm() {
quotesData.isLoading ||
Boolean((quote && !swapTransaction) || quotesData.error)
}
holdToSign={false}
holdToSignAllowed={false}
>
<span
style={{
Expand Down
4 changes: 2 additions & 2 deletions src/ui/ui-kit/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type Kind =
| 'text-primary';
export type Size = 60 | 56 | 48 | 44 | 40 | 36 | 32 | 28;

export const borderRaduis: Record<Size, number> = {
export const borderRadius: Record<Size, number> = {
'28': 8,
'32': 8,
'36': 12,
Expand Down Expand Up @@ -77,7 +77,7 @@ const ButtonElement = <As extends ElementType = 'button'>(
{
border: 'none',
textDecoration: 'none',
borderRadius: borderRaduis[size],
borderRadius: borderRadius[size],
height: size,
color: undefined,
},
Expand Down
4 changes: 2 additions & 2 deletions src/ui/ui-kit/Button/HoldableButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import React from 'react';
import cn from 'classnames';
import { UIText } from '../UIText';
import { borderRaduis, kinds, type Kind, type Size } from './Button';
import { borderRadius, kinds, type Kind, type Size } from './Button';
import * as buttonStyles from './styles.module.css';
import * as styles from './holdableStyles.module.css';

Expand Down Expand Up @@ -164,7 +164,7 @@ const ButtonElement = <As extends ElementType = 'button'>(
{
border: 'none',
textDecoration: 'none',
borderRadius: borderRaduis[size],
borderRadius: borderRadius[size],
height: size,
color: undefined,
['--button-background-hover' as string]:
Expand Down

0 comments on commit d7e0325

Please sign in to comment.