Compare commits

..
Author SHA1 Message Date
John Huang 9ecb54ee0c lint 2024-02-08 10:40:41 -08:00
aleka 3a3f817501 wrap details item + fix cancel reason overflow/overlay (#284)
* wrap details item

* more details nits
2024-02-08 13:10:42 -05:00
7 changed files with 30 additions and 57 deletions
+5 -5
View File
@@ -32,20 +32,20 @@ if (
/* hardcoded injection depending on whether the app is available on App Store and/or Google Play */
if (SMARTBANNER_APPSTORE_URL) {
smartbanner = `\t<meta name="smartbanner:button-url-apple" content="${SMARTBANNER_APPSTORE_URL}">\n` + smartbanner;
smartbanner = `\t<meta name="smartbanner:button-url-apple" content="${SMARTBANNER_APPSTORE_URL}">\n${smartbanner}`;
}
if (SMARTBANNER_GOOGLEPLAY_URL) {
smartbanner = `\t<meta name="smartbanner:button-url-google" content="${SMARTBANNER_GOOGLEPLAY_URL}">\n` + smartbanner;
smartbanner = `\t<meta name="smartbanner:button-url-google" content="${SMARTBANNER_GOOGLEPLAY_URL}">\n${smartbanner}`;
}
if (SMARTBANNER_APPSTORE_URL) {
if (SMARTBANNER_GOOGLEPLAY_URL) {
smartbanner = `\t<meta name="smartbanner:enabled-platforms" content="android,ios">\n` + smartbanner;
smartbanner = `\t<meta name="smartbanner:enabled-platforms" content="android,ios">\n${smartbanner}`;
} else {
smartbanner = `\t<meta name="smartbanner:enabled-platforms" content="ios">\n` + smartbanner;
smartbanner = `\t<meta name="smartbanner:enabled-platforms" content="ios">\n${smartbanner}`;
}
} else {
if (SMARTBANNER_GOOGLEPLAY_URL) {
smartbanner = `\t<meta name="smartbanner:enabled-platforms" content="android">\n` + smartbanner;
smartbanner = `\t<meta name="smartbanner:enabled-platforms" content="android">\n${smartbanner}`;
}
}
+9 -5
View File
@@ -133,6 +133,7 @@ const detailsLayoutVariants = {
row: css`
${layoutMixins.row}
align-self: stretch;
white-space: nowrap;
`,
rowColumns: css`
@@ -159,12 +160,16 @@ const itemLayoutVariants: Record<string, FlattenInterpolation<ThemeProps<any>>>
${layoutMixins.spacedRow}
gap: 0.5rem;
align-items: start;
padding: 0.5rem 0;
min-height: var(--details-item-height);
> :last-child {
align-self: stretch;
> :first-child > abbr {
min-width: auto;
}
> :last-child {
${layoutMixins.row}
${layoutMixins.stickyRight}
@@ -217,8 +222,6 @@ Styled.Details = styled.dl<{
--details-grid-numColumns: 2;
${({ layout }) => layout && detailsLayoutVariants[layout]}
white-space: nowrap;
`;
Styled.Item = styled.div<{
@@ -231,7 +234,7 @@ Styled.Item = styled.div<{
${({ justifyItems }) =>
justifyItems === 'end' &&
css`
&:nth-child(even) {
> :nth-child(even) {
justify-items: end;
text-align: end;
}
@@ -243,6 +246,7 @@ Styled.Item = styled.div<{
{
column: css`
&:not(:hover) > :first-child {
white-space: nowrap;
overflow-x: hidden;
text-overflow: ellipsis;
}
+1 -1
View File
@@ -26,7 +26,7 @@ export const DetailsDialog = ({ slotIcon, title, items, slotFooter, setIsOpen }:
placement={isTablet ? DialogPlacement.Default : DialogPlacement.Sidebar}
>
<Styled.Content>
<Styled.Details withSeparators items={items} />
<Styled.Details withSeparators justifyItems="end" items={items} />
<Styled.Footer>{slotFooter}</Styled.Footer>
</Styled.Content>
-1
View File
@@ -40,7 +40,6 @@ export enum WalletErrorType {
// General
ChainMismatch,
UserCanceled,
SwitchChainMethodMissing,
// Non-Deterministic
NonDeterministicWallet,
+7 -10
View File
@@ -163,20 +163,17 @@ export const useWalletConnection = () => {
}
}
} catch (error) {
const { isErrorExpected } = parseWalletError({ error, stringGetter });
if (!isErrorExpected) {
throw Object.assign(
new Error([error.message, error.cause?.message].filter(Boolean).join('\n')),
{
walletConnectionType: walletConnection?.type,
}
);
}
throw Object.assign(
new Error([error.message, error.cause?.message].filter(Boolean).join('\n')),
{
walletConnectionType: walletConnection?.type,
}
);
}
return {
walletType,
walletConnectionType: walletConnection?.type,
walletConnectionType: walletConnection.type,
};
},
[isConnectedGraz, signerGraz, isConnectedWagmi, signerWagmi]
+1 -11
View File
@@ -92,10 +92,6 @@ export const getWalletErrorType = ({ error }: { error: Error }) => {
return WalletErrorType.ChainMismatch;
}
if (messageLower.includes('Missing or invalid. request() method: wallet_switchEthereumChain')) {
return WalletErrorType.SwitchChainMethodMissing;
}
// ImToken - User canceled
if (messageLower.includes('用户取消了操作')) {
return WalletErrorType.UserCanceled;
@@ -117,18 +113,13 @@ export const parseWalletError = ({
}) => {
const walletErrorType = getWalletErrorType({ error });
let message;
let isErrorExpected;
switch (walletErrorType) {
case WalletErrorType.ChainMismatch:
case WalletErrorType.UserCanceled:
case WalletErrorType.SwitchChainMethodMissing: {
isErrorExpected = true;
message = error.message;
case WalletErrorType.UserCanceled: {
break;
}
default: {
isErrorExpected = false;
message = stringGetter({
key: STRING_KEYS.SOMETHING_WENT_WRONG_WITH_MESSAGE,
params: {
@@ -141,6 +132,5 @@ export const parseWalletError = ({
return {
walletErrorType,
message,
isErrorExpected,
};
};
@@ -44,6 +44,7 @@ export const GenerateKeys = ({
onKeysDerived = () => {},
}: ElementProps) => {
const stringGetter = useStringGetter();
const { isMobile } = useBreakpoints();
const [shouldRememberMe, setShouldRememberMe] = useState(false);
@@ -65,30 +66,17 @@ export const GenerateKeys = ({
try {
await matchNetwork?.();
return true;
} catch (error) {
const { message, walletErrorType, isErrorExpected } = parseWalletError({
error,
stringGetter,
});
if (!isErrorExpected) {
log('GenerateKeys/switchNetwork', error, { walletErrorType });
}
const { message, walletErrorType } = parseWalletError({ error, stringGetter });
if (message) {
log('GenerateKeys/switchNetwork', error, { walletErrorType });
setError(message);
throw error;
}
return false;
}
};
const switchNetworkAndDeriveKeys = async () => {
const networkSwitched = await switchNetwork();
if (networkSwitched) await deriveKeys();
};
// 2. Derive keys from EVM account
const { getWalletFromEvmSignature } = useDydxClient();
const { getSubaccounts } = useAccounts();
@@ -166,16 +154,11 @@ export const GenerateKeys = ({
setStatus(EvmDerivedAccountStatus.Derived);
} catch (error) {
setStatus(EvmDerivedAccountStatus.NotDerived);
const { message, walletErrorType, isErrorExpected } = parseWalletError({
error,
stringGetter,
});
const { message, walletErrorType } = parseWalletError({ error, stringGetter });
if (message) {
setError(message);
if (!isErrorExpected) {
log('GenerateKeys/deriveKeys', error, { walletErrorType });
}
log('GenerateKeys/deriveKeys', error, { walletErrorType });
}
}
};
@@ -248,7 +231,7 @@ export const GenerateKeys = ({
{!isMatchingNetwork ? (
<Button
action={ButtonAction.Primary}
onClick={() => switchNetworkAndDeriveKeys().then(onKeysDerived)}
onClick={() => switchNetwork().then(deriveKeys).then(onKeysDerived)}
state={{ isLoading: isSwitchingNetwork }}
>
{stringGetter({ key: STRING_KEYS.SWITCH_NETWORK })}