Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync from main to dev #67

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: ci
on:
pull_request:
branches:
- '**'
- "**"

jobs:
lint_test:
uses: babylonlabs-io/.github/.github/workflows/[email protected]
with:
run-build: true
run-unit-tests: true
run-unit-tests: true
8 changes: 4 additions & 4 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ name: docker_publish
on:
push:
branches:
- 'main'
- 'dev'
- "main"
- "dev"
tags:
- '*'
- "*"

jobs:
lint_test:
uses: babylonlabs-io/.github/.github/workflows/[email protected]
with:
run-build: true
run-unit-tests: true

docker_build:
needs: [lint_test]
runs-on: ubuntu-22.04
Expand Down
22 changes: 15 additions & 7 deletions src/app/components/Delegations/Delegation.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEffect, useState } from "react";
import { AiOutlineInfoCircle } from "react-icons/ai";
import { FaBitcoin } from "react-icons/fa";
import { IoIosWarning } from "react-icons/io";
import { Tooltip } from "react-tooltip";

Expand Down Expand Up @@ -122,12 +123,17 @@ export const Delegation: React.FC<DelegationProps> = ({
<p>overflow</p>
</div>
)}
<div className="grid grid-flow-col grid-cols-2 grid-rows-2 items-center gap-2 lg:grid-flow-row lg:grid-cols-5 lg:grid-rows-1">
<p>
{maxDecimals(satoshiToBtc(stakingValueSat), 8)} {coinName}
<div className="grid grid-flow-col grid-cols-2 grid-rows-3 items-center gap-2 lg:grid-flow-row lg:grid-cols-5 lg:grid-rows-1">
<div className="flex gap-1 items-center order-1">
<FaBitcoin className="text-primary" />
<p>
{maxDecimals(satoshiToBtc(stakingValueSat), 8)} {coinName}
</p>
</div>
<p className="order-3 lg:order-2">
{durationTillNow(startTimestamp, currentTime)}
</p>
<p>{durationTillNow(startTimestamp, currentTime)}</p>
<div className="hidden justify-center lg:flex">
<div className="justify-center lg:flex order-2 lg:order-3">
<a
href={`${mempoolApiUrl}/tx/${stakingTxHash}`}
target="_blank"
Expand All @@ -137,11 +143,13 @@ export const Delegation: React.FC<DelegationProps> = ({
{trim(stakingTxHash)}
</a>
</div>
{/* Future data placeholder */}
<div className="order-5 lg:hidden" />
{/*
we need to center the text without the tooltip
add its size 12px and gap 4px, 16/2 = 8px
*/}
<div className="relative flex justify-end lg:left-[8px] lg:justify-center">
<div className="relative flex justify-end lg:left-[8px] lg:justify-center order-4">
<div className="flex items-center gap-1">
<p>{renderState()}</p>
<span
Expand All @@ -155,7 +163,7 @@ export const Delegation: React.FC<DelegationProps> = ({
<Tooltip id={`tooltip-${stakingTxHash}`} className="tooltip-wrap" />
</div>
</div>
{generateActionButton()}
<div className="order-6">{generateActionButton()}</div>
</div>
</div>
);
Expand Down
18 changes: 11 additions & 7 deletions src/app/components/Modals/ErrorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface ErrorModalProps {
errorMessage: string;
errorState?: ErrorState;
errorTime: Date;
noCancel?: boolean;
}

export const ErrorModal: React.FC<ErrorModalProps> = ({
Expand All @@ -20,7 +21,8 @@ export const ErrorModal: React.FC<ErrorModalProps> = ({
onRetry,
errorMessage,
errorState,
errorTime,
noCancel,
// errorTime, // This prop is not used in the component
}) => {
const { error, retryErrorAction } = useError();

Expand Down Expand Up @@ -93,12 +95,14 @@ export const ErrorModal: React.FC<ErrorModalProps> = ({
<p className="text-center">{getErrorMessage()}</p>
</div>
<div className="mt-4 flex justify-around gap-4">
<button
className="btn btn-outline flex-1 rounded-lg px-2"
onClick={() => onClose()}
>
Cancel
</button>
{!noCancel && ( // Only show the cancel button if noCancel is false or undefined
<button
className="btn btn-outline flex-1 rounded-lg px-2"
onClick={() => onClose()}
>
Cancel
</button>
)}
{onRetry && (
<button
className="btn-primary btn flex-1 rounded-lg px-2 text-white"
Expand Down
11 changes: 10 additions & 1 deletion src/app/components/Staking/Staking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,16 @@ export const Staking: React.FC<StakingProps> = ({
errorState: ErrorState.STAKING,
errorTime: new Date(),
},
retryAction: handleSign,
noCancel: true,
retryAction: () => {
// in case of error, we need to partly reset the state
setStakingAmountSat(0);
setSelectedFeeRate(0);
setPreviewModalOpen(false);
setResetFormInputs(!resetFormInputs);
// and refetch the UTXOs
queryClient.invalidateQueries({ queryKey: [UTXO_KEY, address] });
},
});
}
};
Expand Down
18 changes: 13 additions & 5 deletions src/app/context/Error/ErrorContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ interface ErrorContextType {
retryErrorAction?: () => void;
showError: (showErrorParams: ShowErrorParams) => void;
hideError: () => void;
noCancel?: boolean;
}

export const ErrorProvider: React.FC<ErrorProviderProps> = ({ children }) => {
const [isErrorOpen, setIsErrorOpen] = useState(false);
const [isNoCancel, setIsNoCancel] = useState(false);
const [error, setError] = useState<ErrorType>({
message: "",
errorTime: new Date(),
Expand All @@ -33,11 +35,15 @@ export const ErrorProvider: React.FC<ErrorProviderProps> = ({ children }) => {
(() => void) | undefined
>();

const showError = useCallback(({ error, retryAction }: ShowErrorParams) => {
setError(error);
setIsErrorOpen(true);
setRetryErrorAction(() => retryAction);
}, []);
const showError = useCallback(
({ error, retryAction, noCancel }: ShowErrorParams) => {
setError(error);
setIsErrorOpen(true);
setIsNoCancel(noCancel ?? false);
setRetryErrorAction(() => retryAction);
},
[],
);

const hideError = useCallback(() => {
setIsErrorOpen(false);
Expand All @@ -48,6 +54,7 @@ export const ErrorProvider: React.FC<ErrorProviderProps> = ({ children }) => {
errorState: undefined,
});
setRetryErrorAction(undefined);
setIsNoCancel(false);
}, 300);
}, []);

Expand All @@ -57,6 +64,7 @@ export const ErrorProvider: React.FC<ErrorProviderProps> = ({ children }) => {
showError,
hideError,
retryErrorAction,
noCancel: isNoCancel,
};

return (
Expand Down
11 changes: 9 additions & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ const Home: React.FC<HomeProps> = () => {
const [publicKeyNoCoord, setPublicKeyNoCoord] = useState("");

const [address, setAddress] = useState("");
const { error, isErrorOpen, showError, hideError, retryErrorAction } =
useError();
const {
error,
isErrorOpen,
showError,
hideError,
retryErrorAction,
noCancel,
} = useError();
const { isTermsOpen, closeTerms } = useTerms();

const {
Expand Down Expand Up @@ -470,6 +476,7 @@ const Home: React.FC<HomeProps> = () => {
errorTime={error.errorTime}
onClose={hideError}
onRetry={retryErrorAction}
noCancel={noCancel}
/>
<TermsModal open={isTermsOpen} onClose={closeTerms} />
</main>
Expand Down
1 change: 1 addition & 0 deletions src/app/types/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ export interface ErrorHandlerParam {
export interface ShowErrorParams {
error: ErrorType;
retryAction?: () => void;
noCancel?: boolean;
}
Loading