Skip to content

Commit 05dc8f9

Browse files
authored
Sys5 bridge (#50)
* feat: hiding sys5 changes behind feature toggle * fix: filter deploy to stage for main only * fix: filter deploy to stage for main only * feat: add constants api * fix: sys5 changes on testnet * fix: remove unused import * fix: renable steps on nevm to sys * fix: add updated syscoinjs lib for mint sysx fix * chore: update syscoinjs lib to latest * fix: update switch wallet capabilities
1 parent 810e64e commit 05dc8f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+728
-339
lines changed

.github/workflows/ghcr.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- "main"
77
- "support-pali-v1-backward-compatibility"
8+
- "sys5-bridge"
89

910
jobs:
1011
docker:
@@ -59,6 +60,7 @@ jobs:
5960

6061
deploy-staging:
6162
needs: docker
63+
if: github.ref_name == 'main'
6264
environment:
6365
name: staging
6466
permissions:

api/services/admin-transfer/constants.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { BlockbookAPIURL } from "@contexts/Transfer/constants";
21
import { utils as syscoinUtils } from "syscoinjs-lib";
32

43
export const CONFIRM_UTXO_TRANSACTION = "Confirm UTXO Transaction";
@@ -11,7 +10,7 @@ export const verifyTxTokenTransfer = async (
1110
tokenType: string
1211
) => {
1312
const rawTransaction = await syscoinUtils.fetchBackendRawTx(
14-
BlockbookAPIURL,
13+
process.env.UTXO_RPC_URL!,
1514
txId
1615
);
1716

api/services/admin-transfer/handle-freeze-burn.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const handleFreezeBurn = async (
4444
const receipt = await validateTransactionReceipt(
4545
web3,
4646
txHash,
47-
ERC20_MANAGER_CONTRACT_ADDRESS
47+
ERC20_MANAGER_CONTRACT_ADDRESS!
4848
);
4949

5050
if (clearAll) {

api/services/admin-transfer/handle-submit-proofs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const handleSubmitProofs = async (
4444
const receipt = await validateTransactionReceipt(
4545
web3,
4646
txHash,
47-
RELAY_CONTRACT_ADDRESS
47+
RELAY_CONTRACT_ADDRESS!
4848
);
4949
if (clearAll) {
5050
transfer.logs = transfer.logs.filter(

components/Bridge/NEVMStepWrapepr.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import {
2-
MAINNET_CHAIN_ID,
3-
useNEVM,
4-
} from "@contexts/ConnectedWallet/NEVMProvider";
1+
import { useNEVM } from "@contexts/ConnectedWallet/NEVMProvider";
52
import { usePaliWalletV2 } from "@contexts/PaliWallet/usePaliWallet";
3+
import { useConstants } from "@contexts/useConstants";
64
import { Button } from "@mui/material";
75
import { isValidEthereumAddress } from "@pollum-io/sysweb3-utils";
86

@@ -14,6 +12,8 @@ const NEVMStepWrapper: React.FC<Props> = ({ children }) => {
1412
const { version, isBitcoinBased, switchTo, isEVMInjected, connectWallet } =
1513
usePaliWalletV2();
1614

15+
const { constants } = useConstants();
16+
1717
const { connect, account, chainId, switchToMainnet } = useNEVM();
1818

1919
if (version === "v2" && isBitcoinBased && isEVMInjected) {
@@ -38,7 +38,7 @@ const NEVMStepWrapper: React.FC<Props> = ({ children }) => {
3838
);
3939
}
4040

41-
if (chainId !== MAINNET_CHAIN_ID) {
41+
if (chainId !== constants?.chain_id) {
4242
return (
4343
<Button variant="contained" onClick={switchToMainnet}>
4444
Switch to NEVM Network

components/Bridge/Stepper.tsx

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,27 @@ import {
66
SYS_TO_ETH_TRANSFER_STATUS,
77
} from "@contexts/Transfer/types";
88

9-
const NEVMToSYSStepper: React.FC<{ activeStep: number }> = ({ activeStep }) => (
10-
<Stepper activeStep={activeStep}>
11-
<Step key="connect-and-validate">
12-
<StepLabel>Connect and Validated</StepLabel>
13-
</Step>
14-
<Step key="freeze-and-burn">
15-
<StepLabel>Freeze and Burn SYS</StepLabel>
16-
</Step>
17-
<Step key="mint-sysx">
18-
<StepLabel>Mint SYSX</StepLabel>
19-
</Step>
20-
<Step key="burn-sysx">
21-
<StepLabel>Burn SYSX</StepLabel>
22-
</Step>
23-
<Step key="Completed">
24-
<StepLabel>Completed</StepLabel>
25-
</Step>
26-
</Stepper>
27-
);
9+
const NEVMToSYSStepper: React.FC<{ activeStep: number }> = ({ activeStep }) => {
10+
return (
11+
<Stepper activeStep={activeStep}>
12+
<Step key="connect-and-validate">
13+
<StepLabel>Connect and Validated</StepLabel>
14+
</Step>
15+
<Step key="freeze-and-burn">
16+
<StepLabel>Freeze and Burn SYS</StepLabel>
17+
</Step>
18+
<Step key="mint-sysx">
19+
<StepLabel>Mint SYSX</StepLabel>
20+
</Step>
21+
<Step key="burn-sysx">
22+
<StepLabel>Burn SYSX</StepLabel>
23+
</Step>
24+
<Step key="Completed">
25+
<StepLabel>Completed</StepLabel>
26+
</Step>
27+
</Stepper>
28+
);
29+
};
2830

2931
const SYSToNEVMStepper: React.FC<{ activeStep: number }> = ({ activeStep }) => {
3032
const { transfer } = useTransfer();

components/Bridge/Steps/CompleteNevmToSys.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import { ITransfer } from "@contexts/Transfer/types";
2+
import { useConstants } from "@contexts/useConstants";
23
import { Alert, Box, Typography, Link } from "@mui/material";
34

45
import React from "react";
56

6-
const SYSCOIN_TX_BLOCKCHAIN_URL = "https://blockbook.syscoin.org/tx/";
7-
const NEVM_TX_BLOCKCHAIN_URL = "https://explorer.syscoin.org/tx/";
8-
97
type Props = {
108
transfer: ITransfer;
119
};
1210

1311
const BridgeCompleteNevmToSys: React.FC<Props> = ({ transfer }) => {
1412
const { logs } = transfer;
13+
const { constants } = useConstants();
14+
const SYSCOIN_TX_BLOCKCHAIN_URL = `${constants?.explorer.utxo}/tx/`;
15+
const NEVM_TX_BLOCKCHAIN_URL = `${constants?.explorer.nevm}/tx/`;
16+
1517
const mintSysTx = logs.find(
1618
(log) => log.status === "mint-sysx" && log.payload.data.tx !== undefined
1719
);

components/Bridge/Steps/CompleteSysToNevm.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import { ITransfer } from "@contexts/Transfer/types";
2+
import { useConstants } from "@contexts/useConstants";
23
import { Alert, Box, Typography, Link } from "@mui/material";
34

45
import React from "react";
56

6-
const SYSCOIN_TX_BLOCKCHAIN_URL = "https://blockbook.syscoin.org/tx/";
7-
const NEVM_TX_BLOCKCHAIN_URL = "https://explorer.syscoin.org/tx/";
8-
97
type Props = {
108
transfer: ITransfer;
119
};
1210

1311
const BridgeCompleteSysToNevm: React.FC<Props> = ({ transfer }) => {
12+
const { constants } = useConstants();
13+
const SYSCOIN_TX_BLOCKCHAIN_URL = `${constants?.explorer.utxo}/tx/`;
14+
const NEVM_TX_BLOCKCHAIN_URL = `${constants?.explorer.nevm}/tx/`;
1415
const { logs } = transfer;
1516
const burnSysTx =
1617
transfer.useSysx || transfer.utxoAssetType === "sysx"

components/Bridge/Steps/ConfirmNEVMTransaction.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { useTransfer } from "../context/TransferContext";
33
import { Alert, CircularProgress, Link } from "@mui/material";
44
import { useNevmTransaction } from "../hooks/useNevmTransaction";
55
import { useEffect } from "react";
6-
import { NEVM_TX_BLOCKCHAIN_URL } from "@constants";
76
import NEVMStepWrapper from "../NEVMStepWrapepr";
7+
import { useConstants } from "@contexts/useConstants";
88

99
type Props = {
1010
successStatus: TransferStatus;
@@ -19,15 +19,18 @@ const BridgeConfirmNEVMTransaction: React.FC<Props> = ({
1919
invalidStateMessage,
2020
loadingMessage,
2121
}) => {
22+
const { constants } = useConstants();
2223
const { transfer, saveTransfer } = useTransfer();
2324

2425
const sourceLog: ITransferLog | undefined = transfer?.logs?.find(
25-
(log) => log.status === sourceStatus && Boolean(log?.payload?.data.hash)
26+
(log) => log.status === sourceStatus && Boolean(log?.payload?.data?.hash)
2627
);
2728

2829
const sourceTxHash = sourceLog?.payload.data.hash;
2930

30-
const { data, isFetched } = useNevmTransaction(sourceTxHash, { refetch: true });
31+
const { data, isFetched } = useNevmTransaction(sourceTxHash, {
32+
refetch: true,
33+
});
3134

3235
useEffect(() => {
3336
if (!isFetched || !data) {
@@ -63,7 +66,10 @@ const BridgeConfirmNEVMTransaction: React.FC<Props> = ({
6366
{loadingMessage}
6467
<CircularProgress size={"1rem"} />
6568
<br />
66-
<Link href={`${NEVM_TX_BLOCKCHAIN_URL}${sourceTxHash}`} target="_blank">
69+
<Link
70+
href={`${constants?.explorer.nevm}/tx/${sourceTxHash}`}
71+
target="_blank"
72+
>
6773
View on Explorer
6874
</Link>
6975
</Alert>

components/Bridge/Steps/ConfirmUTXOTransaction.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { useTransfer } from "../context/TransferContext";
33
import { useUtxoTransaction } from "components/Bridge/hooks/useUtxoTransaction";
44
import { ITransferLog, TransferStatus } from "@contexts/Transfer/types";
55
import React, { useEffect } from "react";
6-
import { SYSCOIN_TX_BLOCKCHAIN_URL } from "@constants";
76
import UTXOStepWrapper from "../UTXOStepWrapper";
7+
import { useConstants } from "@contexts/useConstants";
88

99
type Props = {
1010
invalidStateMessage: string;
@@ -22,6 +22,7 @@ const BridgeStepConfirmUTXOTransaction: React.FC<Props> = ({
2222
confirmations,
2323
}) => {
2424
const { transfer, saveTransfer } = useTransfer();
25+
const { constants } = useConstants();
2526

2627
const utxoStepLog = transfer.logs.find(
2728
(log) => log.status === sourceStatus && Boolean(log.payload?.data?.tx)
@@ -70,7 +71,7 @@ const BridgeStepConfirmUTXOTransaction: React.FC<Props> = ({
7071
{loadingMessage} &nbsp;
7172
<CircularProgress size={"1rem"} />
7273
<br />
73-
<Link href={`${SYSCOIN_TX_BLOCKCHAIN_URL}${txId}`} target="_blank">
74+
<Link href={`${constants?.explorer.utxo}/tx/${txId}`} target="_blank">
7475
View on Explorer
7576
</Link>
7677
</Alert>

0 commit comments

Comments
 (0)