-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor(bridge): remove v2 code * refactor(bridge): remove v2 code
- Loading branch information
1 parent
88b913c
commit 61d3843
Showing
67 changed files
with
229 additions
and
1,176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,89 @@ | ||
import { Alert, Step, StepLabel, Stepper } from "@mui/material"; | ||
import { useTransfer } from "contexts/Transfer/useTransfer"; | ||
import { Step, StepLabel, Stepper } from "@mui/material"; | ||
import { nevmToSysSteps, sysToNevmSteps } from "./contants/steps"; | ||
import { useTransfer } from "./context/TransferContext"; | ||
import { | ||
ETH_TO_SYS_TRANSFER_STATUS, | ||
SYS_TO_ETH_TRANSFER_STATUS, | ||
} from "@contexts/Transfer/types"; | ||
|
||
const BridgeTransferStepper: React.FC = () => { | ||
const NEVMToSYSStepper: React.FC<{ activeStep: number }> = ({ activeStep }) => ( | ||
<Stepper activeStep={activeStep}> | ||
<Step key="connect-and-validate"> | ||
<StepLabel>Connect and Validated</StepLabel> | ||
</Step> | ||
<Step key="freeze-and-burn"> | ||
<StepLabel>Freeze and Burn SYS</StepLabel> | ||
</Step> | ||
<Step key="mint-sysx"> | ||
<StepLabel>Mint SYSX</StepLabel> | ||
</Step> | ||
<Step key="burn-sysx"> | ||
<StepLabel>Burn SYSX</StepLabel> | ||
</Step> | ||
<Step key="Completed"> | ||
<StepLabel>Completed</StepLabel> | ||
</Step> | ||
</Stepper> | ||
); | ||
|
||
const SYSToNEVMStepper: React.FC<{ activeStep: number }> = ({ activeStep }) => { | ||
const { transfer } = useTransfer(); | ||
const useSysx = transfer.useSysx || transfer.utxoAssetType === "sysx"; | ||
return ( | ||
<Stepper activeStep={activeStep}> | ||
<Step key="connect-and-validate"> | ||
<StepLabel>Connect and Validated</StepLabel> | ||
</Step> | ||
<Step key="burn-sys"> | ||
<StepLabel>Burn SYS {useSysx ? "(Skipped)" : ""}</StepLabel> | ||
</Step> | ||
<Step key="burn-sysx"> | ||
<StepLabel>Burn SYSX</StepLabel> | ||
</Step> | ||
<Step key="validate-proofs"> | ||
<StepLabel>Validate Proofs</StepLabel> | ||
</Step> | ||
<Step key="Completed"> | ||
<StepLabel>Completed</StepLabel> | ||
</Step> | ||
</Stepper> | ||
); | ||
}; | ||
|
||
const BridgeStepper: React.FC = () => { | ||
const { | ||
transfer: { status }, | ||
steps: mainSteps, | ||
transfer: { type, status }, | ||
} = useTransfer(); | ||
const initializeStep = { | ||
id: "initialize", | ||
label: "Initialize", | ||
}; | ||
const completeStep = { | ||
id: "completed", | ||
label: "Completed", | ||
}; | ||
let activeStep = 1; | ||
let modifiedStatus = status; | ||
|
||
if (mainSteps.length === 0) { | ||
return <Alert severity="error">Invalid Transfer type</Alert>; | ||
if (type === "nevm-to-sys") { | ||
if (modifiedStatus === ETH_TO_SYS_TRANSFER_STATUS.CONFIRM_FREEZE_BURN_SYS) { | ||
modifiedStatus = ETH_TO_SYS_TRANSFER_STATUS.FREEZE_BURN_SYS; | ||
} else if ( | ||
modifiedStatus === ETH_TO_SYS_TRANSFER_STATUS.CONFIRM_MINT_SYSX | ||
) { | ||
modifiedStatus = ETH_TO_SYS_TRANSFER_STATUS.MINT_SYSX; | ||
} else if (modifiedStatus === "confirm-burn-sysx") { | ||
modifiedStatus = ETH_TO_SYS_TRANSFER_STATUS.BURN_SYSX; | ||
} | ||
activeStep = nevmToSysSteps.findIndex((step) => step === modifiedStatus); | ||
return <NEVMToSYSStepper activeStep={activeStep} />; | ||
} | ||
|
||
const steps = [initializeStep, ...mainSteps, completeStep]; | ||
const activeStep = steps.findIndex((step) => step.id === status); | ||
if (modifiedStatus === "confirm-burn-sys") { | ||
modifiedStatus = SYS_TO_ETH_TRANSFER_STATUS.BURN_SYS; | ||
} else if (modifiedStatus === "confirm-burn-sysx") { | ||
modifiedStatus = SYS_TO_ETH_TRANSFER_STATUS.BURN_SYSX; | ||
} else if ( | ||
modifiedStatus === "finalizing" || | ||
modifiedStatus === "generate-proofs" | ||
) { | ||
modifiedStatus = SYS_TO_ETH_TRANSFER_STATUS.SUBMIT_PROOFS; | ||
} | ||
|
||
return ( | ||
<Stepper activeStep={activeStep || 0} alternativeLabel sx={{ mb: 2 }}> | ||
{steps.map((step) => ( | ||
<Step key={step.id}> | ||
<StepLabel>{step.label}</StepLabel> | ||
</Step> | ||
))} | ||
</Stepper> | ||
); | ||
activeStep = sysToNevmSteps.findIndex((step) => step === modifiedStatus); | ||
return <SYSToNEVMStepper activeStep={activeStep} />; | ||
}; | ||
|
||
export default BridgeTransferStepper; | ||
export default BridgeStepper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.