Skip to content

Commit

Permalink
Merge pull request #573 from Peersyst/hotfixes/ui
Browse files Browse the repository at this point in the history
Hotfixes/UI
  • Loading branch information
AgustinMJ authored May 22, 2024
2 parents 5f2d323 + eeb82f6 commit 950d5d7
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 32 deletions.
6 changes: 5 additions & 1 deletion src/config/ConfigProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ export interface ConfigProviderProps {
const ConfigProvider = ({ children }: ConfigProviderProps): JSX.Element => {
const translate = useTranslate("error");
const { locale = "en" } = useRecoilValue(settingsState);
return <GenesysConfigProvider config={{ ...config, translate, locale }}>{children}</GenesysConfigProvider>;
return (
<GenesysConfigProvider config={{ ...config, translate, locale }} storeTheme>
{children}
</GenesysConfigProvider>
);
};

export default ConfigProvider;
4 changes: 3 additions & 1 deletion src/locale/locales/el/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@
"transaction_request_already_signed": "Το αίτημα συναλλαγής έχει ήδη υπογραφεί",
"transaction_request_already_declined": "Το αίτημα συναλλαγής έχει ήδη απορριφθεί",
"invalid_transaction": "Μη έγκυρη συναλλαγή",
"invalid_domain": "Μη έγκυρο domain"
"invalid_domain": "Μη έγκυρο domain",
"minimun_amount_61_ckb": "Η ελάχιστη τιμή μεταφοράς (κυττάρου) είναι 61 CKB",
"insufficient_capacity_for_change_cell": "Ανεπαρκής χωρητικότητα για το κύτταρο αλλαγής"
}
4 changes: 3 additions & 1 deletion src/locale/locales/en/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@
"transaction_request_already_signed": "Transaction request already signed",
"transaction_request_already_declined": "Transaction request already declined",
"invalid_transaction": "Invalid transaction",
"invalid_domain": "Invalid domain"
"invalid_domain": "Invalid domain",
"minimun_amount_61_ckb": "Minimum transfer (cell) value is 61 CKB",
"insufficient_capacity_for_change_cell": "Insufficient capacity for change cell"
}
4 changes: 3 additions & 1 deletion src/locale/locales/es/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@
"transaction_request_already_signed": "Petición de transacción ya firmada",
"transaction_request_already_declined": "Petición de transacción ya rechazada",
"invalid_transaction": "Transacción inválida",
"invalid_domain": "Dominio inválido"
"invalid_domain": "Dominio inválido",
"minimun_amount_61_ckb": "El valor mínimo de transferencia (célula) es 61 CKB",
"insufficient_capacity_for_change_cell": "Capacidad insuficiente para la célula de cambio"
}
4 changes: 3 additions & 1 deletion src/locale/locales/fr/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@
"transaction_request_already_signed": "Demande de transaction déjà signée",
"transaction_request_already_declined": "Demande de transaction déjà refusée",
"invalid_transaction": "Transaction invalide",
"invalid_domain": "Domaine invalide"
"invalid_domain": "Domaine invalide",
"minimun_amount_61_ckb": "La valeur minimale de transfert (cellule) est de 61 CKB",
"insufficient_capacity_for_change_cell": "Capacité insuffisante pour la cellule de changement"
}
4 changes: 3 additions & 1 deletion src/locale/locales/pt/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@
"transaction_request_already_signed": "Pedido de transação já assinado",
"transaction_request_already_declined": "Pedido de transação já recusado",
"invalid_transaction": "Transação inválida",
"invalid_domain": "Dominio inválido"
"invalid_domain": "Dominio inválido",
"minimun_amount_61_ckb": "O valor mínimo de transferência (célula) é 61 CKB",
"insufficient_capacity_for_change_cell": "Capacidade insuficiente para a célula de troca"
}
4 changes: 3 additions & 1 deletion src/locale/locales/zh/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@
"transaction_request_already_signed": "交易请求已签署",
"transaction_request_already_declined": "交易请求已被拒绝",
"invalid_transaction": "无效交易",
"invalid_domain": "无效域名"
"invalid_domain": "无效域名",
"minimun_amount_61_ckb": "最小转账(单元)金额为 61 CKB",
"insufficient_capacity_for_change_cell": "找零单元容量不足"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const EmptyListComponent = ({ title, text }: EmptyListComponentProps): JSX.Eleme
const translate = useTranslate("error");
return (
<Col alignItems="center" style={{ paddingTop: "10%", paddingHorizontal: "5%" }}>
<Advise gap={0} title={title || translate("nothing_to_show")} text={text} />
<Advise gap={8} title={title || translate("nothing_to_show")} text={text} />
</Col>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const Gradient = styled(LinearGradient)(() => ({
}));

export const LoadingModalButton = styled(Button, { variant: "secondary" })(({ theme, safeAreaInsets, dimensions }) => ({
color: theme.palette.white,
color: theme.palette.primary,
position: "absolute",
width: dimensions.width - 40,
marginLeft: 20,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
import { useTheme } from "@peersyst/react-native-components";
import LabeledIconButton from "../LabeledIconButton/LabeledIconButton";
import { ActionIconButtonProps } from "./ActionIconButton.types";

export default function ActionIconButton({ isActive, action, ...rest }: ActionIconButtonProps): JSX.Element {
const {
palette: { gray, overlay },
} = useTheme();
return (
<LabeledIconButton
labelColor={isActive ? gray[0] : overlay[100]["48%"]}
variant={isActive ? "secondary" : "outlined"}
onPress={action}
{...rest}
/>
);
return <LabeledIconButton variant={isActive ? "secondary" : "outlined"} onPress={action} {...rest} />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import IconButton from "../IconButton/IconButton";
import { TouchableWithoutFeedback, View } from "react-native";
import { LabeledIconButtonProps } from "./LabeledIconButton.types";

export default function LabeledIconButton({ label, labelColor, onPress, ...iconButtonProps }: LabeledIconButtonProps): JSX.Element {
export default function LabeledIconButton({ label, onPress, ...iconButtonProps }: LabeledIconButtonProps): JSX.Element {
return (
<TouchableWithoutFeedback onPress={onPress}>
<Col alignItems="center">
<Col alignItems="center" gap={3}>
<View style={{ marginHorizontal: "auto" }}>
<IconButton onPress={onPress} {...iconButtonProps} />
</View>
<Typography variant="body4Regular" color={labelColor} adjustsFontSizeToFit>
<Typography variant="body4Regular" adjustsFontSizeToFit>
{label}
</Typography>
</Col>
Expand Down
4 changes: 2 additions & 2 deletions src/module/sdk/core/assets/ckb.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class CKBService {

async transfer(from: string, to: string, amount: bigint, privateKey: string, feeRate: FeeRate = FeeRate.NORMAL): Promise<string> {
if (amount < this.transferCellSize) {
throw new Error("Minimum transfer (cell) value is 61 CKB");
throw new Error("minimun_amount_61_ckb");
}

let txSkeleton = TransactionSkeleton({ cellProvider: this.connection.getEmptyCellProvider() });
Expand All @@ -48,7 +48,7 @@ export class CKBService {
amount = cells.filter((cell) => !cell.cellOutput.type).reduce((ant, act) => ant + BigInt(act.cellOutput.capacity), BigInt(0));
}
if (amount < this.transferCellSize) {
throw new Error("Minimum transfer (cell) value is 61 CKB");
throw new Error("minimun_amount_61_ckb");
}

let txSkeleton = TransactionSkeleton({ cellProvider: this.connection.getEmptyCellProvider() });
Expand Down
2 changes: 1 addition & 1 deletion src/module/sdk/core/transaction.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ export class TransactionService {
throw new Error("Insufficient capacity");
}
if (changeAmount > 0 && changeCapacity < helpers.minimalCellCapacityCompatible(changeCell).toBigInt()) {
throw new Error("Insufficient capacity for change cell");
throw new Error("insufficient_capacity_for_change_cell");
}

if (changeCapacity > BigInt(0)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const DeleteData = () => {
const { setState: setWalletState, reset: resetWalletState } = useWalletState();
const queryClient = useQueryClient();
const { showModal } = useModal();
const { showCancelableDialog } = useCancelableDialog();
const { showCancelableDialog, hideDialog } = useCancelableDialog();

const handleDelete = () => {
showModal(ConfirmPinModal, {
Expand All @@ -25,6 +25,7 @@ const DeleteData = () => {
await SettingsStorage.clear();
await queryClient.invalidateQueries();
resetWalletState();
hideDialog();
},
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import useCancelableDialog from "module/common/hook/useCancelableDialog";

const DeleteOneWallet = () => {
const translate = useTranslate();
const { showCancelableDialog } = useCancelableDialog();
const { showCancelableDialog, hideDialog } = useCancelableDialog();
const { showModal } = useModal();
const {
reset,
Expand Down Expand Up @@ -66,6 +66,7 @@ const DeleteOneWallet = () => {
serviceInstancesMap.delete(serviceInstancesSize);
removeWalletQueries(lastServiceInstanceIndex);
}
hideDialog();
},
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/module/wallet/screen/EnterWalletMnemonicScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface EnterWalletMnemonicScreenProps {

const EnterWalletMnemonicScreen = ({ onSubmit, submitText }: EnterWalletMnemonicScreenProps): JSX.Element => {
const translateError = useTranslate("error");
const { setMnemonic } = useCreateWallet();
const { state, setMnemonic } = useCreateWallet();
const [submitted, setSubmitted] = useState(false);
const { showToast } = useToast();

Expand Down Expand Up @@ -47,7 +47,7 @@ const EnterWalletMnemonicScreen = ({ onSubmit, submitText }: EnterWalletMnemonic
<Form onSubmit={handleSubmit}>
<Col gap={24} style={{ marginTop: 5 }}>
<MnemonicInput />
<Button type="submit" fullWidth>
<Button type="submit" fullWidth disabled={!!state.mnemonic}>
{submitText}
</Button>
</Col>
Expand Down
10 changes: 9 additions & 1 deletion src/query/handleErrorMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ export type UseHandleErrorMessage = (error: ApiError | any) => HandleApiErrorMes
export function handleErrorMessage(error: ApiError | any, translate: typeof i18n.t): HandleApiErrorMessageResult {
const code = error.body?.statusCode || error.status;
const message = error.body?.message || error.statusText;
if (!code || code === 500) return { message: translate("somethingWentWrong", { ns: "error" }), type: "error" };

if (error && !code && !message) {
return {
message: translate(error instanceof Error ? [error.message as any, "somethingWnetWrong"] : "somethingWentWrong", {
ns: "error",
}),
type: "error",
};
} else if (!code || code === 500) return { message: translate("somethingWentWrong", { ns: "error" }), type: "error" };
else if (code === 401) return { message: translate("sessionExpired", { ns: "error" }), type: "warning" };
else return { message: translate(message in en.error ? error.body.message : "somethingWentWrong", { ns: "error" }), type: "error" };
}

0 comments on commit 950d5d7

Please sign in to comment.