Skip to content

Commit

Permalink
Merge pull request #37 from syscoin/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
osiastedian authored Dec 13, 2023
2 parents 0e9e4cd + 644f4d6 commit 712d4b0
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
push:
branches:
- main
- admin-panel
- develop

env:
AWS_REGION: us-east-1 # set this to your preferred AWS region, e.g. us-west-1
Expand Down
6 changes: 3 additions & 3 deletions components/Admin/Transfer/AddLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type SupportedOperations = AddLogRequestPayload["operation"];

type Props = {
transfer: ITransfer;
onSelect: (item: SupportedOperations) => void;
onSelect: (item?: SupportedOperations) => void;
};

const AddLogMenu: React.FC<Props> = ({ onSelect }) => {
Expand All @@ -16,7 +16,7 @@ const AddLogMenu: React.FC<Props> = ({ onSelect }) => {
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
setAnchorEl(event.currentTarget);
};
const handleClose = (operation: SupportedOperations) => {
const handleClose = (operation?: SupportedOperations) => {
onSelect(operation);
setAnchorEl(null);
};
Expand All @@ -27,7 +27,7 @@ const AddLogMenu: React.FC<Props> = ({ onSelect }) => {
id="add-log-menu"
anchorEl={anchorEl}
open={open}
onClose={handleClose}
onClose={() => handleClose()}
MenuListProps={{
"aria-labelledby": "basic-button",
}}
Expand Down
2 changes: 1 addition & 1 deletion components/Bridge/WalletSwitchV2/UTXOConnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { MIN_AMOUNT } from "@constants";
import { SYSX_ASSET_GUID } from "@contexts/Transfer/constants";
import { useEffect } from "react";

type AssetType = "sys" | "sysx" | "none";
export type AssetType = "sys" | "sysx" | "none";

type UTXOConnectProps = {
transfer: ITransfer;
Expand Down
10 changes: 8 additions & 2 deletions components/Bridge/v3/Steps/ConnectValidate.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import NEVMConnect from "components/Bridge/WalletSwitchV2/NEVMConnect";
import UTXOConnect from "components/Bridge/WalletSwitchV2/UTXOConnect";
import UTXOConnect, { AssetType } from "components/Bridge/WalletSwitchV2/UTXOConnect";
import { useRouter } from "next/router";
import {
FormProvider,
Expand All @@ -25,12 +25,18 @@ import BridgeV3Loading from "../Loading";
import { ConnectValidateAgreeToTermsCheckbox } from "./ConnectValidate/AgreeToTermsCheckbox";
import { ConnectValidateAmountField } from "./ConnectValidate/AmountField";
import { ConnectValidateStartTransferButton } from "./ConnectValidate/StartTransferButton";
import { useCallback } from "react";

const UTXOWrapped: React.FC<{ transfer: ITransfer }> = ({ transfer }) => {
const { setValue, watch } = useFormContext();

const utxoAssetType = watch("utxoAssetType");

const setSelectedAsset = useCallback(
(asset: AssetType) => setValue("utxoAssetType", asset),
[setValue]
);

return (
<UTXOConnect
transfer={transfer}
Expand All @@ -39,7 +45,7 @@ const UTXOWrapped: React.FC<{ transfer: ITransfer }> = ({ transfer }) => {
setValue("utxoXpub", xpub);
}}
selectedAsset={utxoAssetType}
setSelectedAsset={(asset) => setValue("utxoAssetType", asset)}
setSelectedAsset={setSelectedAsset}
/>
);
};
Expand Down
40 changes: 7 additions & 33 deletions pages/api/transfer/index.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,14 @@
import { NextApiHandler } from "next";
import firebase from "firebase-setup";
import {
QueryConstraint,
collection,
getDocs,
orderBy,
query,
where,
or,
QueryFilterConstraint,
} from "firebase/firestore";
import { signInWithEmailAndPassword } from "firebase/auth";
import { where, QueryFilterConstraint } from "firebase/firestore";
import { TransferService } from "api/services/transfer";
import dbConnect from "lib/mongodb";
import { ITransfer } from "@contexts/Transfer/types";

const transferService = new TransferService();

const getAll: NextApiHandler = async (req, res) => {
const { nevm, utxo, version } = req.query;

if (process.env.NODE_ENV !== "development" && firebase.auth) {
await signInWithEmailAndPassword(
firebase.auth,
process.env.FIREBASE_AUTH_EMAIL!,
process.env.FIREBASE_AUTH_PASSWORD!
);
}
const queryConstraints: QueryFilterConstraint[] = [];

if (nevm) {
Expand All @@ -41,25 +24,16 @@ const getAll: NextApiHandler = async (req, res) => {
return res.status(400).json({ message: "Some parameters are missing" });
}

const transferQuery = query(
collection(firebase.firestore, "transfers"),
or(...queryConstraints),
orderBy("createdAt", "desc")
);

const { docs } = await getDocs(transferQuery);
let transfers = docs.map((doc) => doc.data());
await dbConnect();
let dbTransfer = await transferService.getAll({

const dbTransfer = await transferService.getAll({
nevmAddress: nevm as string,
utxoAddress: utxo as string,
utxoXpub: utxo as string,
version: version as ITransfer["version"],
});
transfers = [...transfers, ...dbTransfer];
if (version) {
transfers = transfers.filter((transfer) => transfer.version === version);
}
return res.status(200).json(Object.values(transfers));

return res.status(200).json(Object.values(dbTransfer));
};

const handler: NextApiHandler = (req, res) => {
Expand Down
2 changes: 1 addition & 1 deletion utils/balance-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const useUtxoBalance = (
const balanceInText = await fetch(url)
.then((res) => res.json())
.then((res: BalanceResp) => {
if (assetGuid && address) {
if (assetGuid && address && res.tokensAsset) {
const total = res.tokensAsset.reduce((acc, asset) => {
if (asset.assetGuid === assetGuid) {
return acc + parseInt(asset.balance);
Expand Down

1 comment on commit 712d4b0

@vercel
Copy link

@vercel vercel bot commented on 712d4b0 Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

syscoin-bridge – ./

syscoin-bridge-git-main-syslabs.vercel.app
syscoin-bridge-syslabs.vercel.app
syscoin-bridge-fawn.vercel.app

Please sign in to comment.