Skip to content

Commit

Permalink
Merge pull request #17 from inblockio/final_fixes
Browse files Browse the repository at this point in the history
Final fixes
  • Loading branch information
Arthur-Kamau authored Dec 18, 2024
2 parents 83368fc + 83b16fb commit ffc6682
Show file tree
Hide file tree
Showing 13 changed files with 269 additions and 41 deletions.
4 changes: 3 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ CHAIN=sepolia
API_DOMAIN=40YcwfNEsn
VITE_API_ENDPOINT=http://localhost:3600
BACKEND_VERSION=1.2.0
FRONTEND_VERSION=1.2.0
FRONTEND_VERSION=1.2.0
AQUIFIER_VERSION=1.2.0
PROTOCOL_VERSION=1.2.0
8 changes: 7 additions & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ BACKEND_URL=
# without port and without protocol
FRONTEND_URL=

SSL_EMAIL=
SSL_EMAIL=

# verion details current default is 1.2
BACKEND_VERSION=1.2.0
FRONTEND_VERSION=1.2.0
AQUIFIER_VERSION=1.2.0
PROTOCOL_VERSION=1.2.0
18 changes: 15 additions & 3 deletions src/controllers/versions_controller.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

use std::env;

use axum::{
Expand All @@ -16,6 +15,8 @@ use serde_json::json;
pub async fn version_details() -> Json<serde_json::Value> {
let mut frontend = env::var("FRONTEND_VERSION").unwrap_or_default();
let mut backend = env::var("BACKEND_VERSION").unwrap_or_default();
let mut aquifier = env::var("AQUIFIER_VERSION").unwrap_or_default();
let mut protocol = env::var("PROTOCOL_VERSION").unwrap_or_default();

if frontend.is_empty() {
frontend = "1.2.0".to_string()
Expand All @@ -24,6 +25,17 @@ pub async fn version_details() -> Json<serde_json::Value> {
if backend.is_empty() {
backend = "1.2.0".to_string()
}
if aquifier.is_empty() {
aquifier = "1.2.0".to_string()
}
if protocol.is_empty() {
protocol = "1.2.0".to_string()
}

Json(json!({ "backend": backend, "frontend" : frontend }))
}
Json(json!({
"backend" : backend,
"frontend" : frontend,
"aquifier" : aquifier,
"protocol" : protocol,
}))
}
26 changes: 15 additions & 11 deletions web/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/images/ico.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Aquafier</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/images/ico.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Aquafier</title>
<meta name="data-accounting-mediawiki" content="Do Name resolution">
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

</html>
1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
},
"devDependencies": {
"@eslint/js": "^9.13.0",
"@types/chrome": "^0.0.287",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@vitejs/plugin-react": "^4.3.3",
Expand Down
13 changes: 8 additions & 5 deletions web/src/components/dropzone_file_actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ export const ImportAquaChainFromChain = ({ fileInfo, isVerificationSuccessful }:

const res: ApiFileInfo = response.data
console.log(res)

const newFiles: ApiFileInfo[] = [];
setFiles(newFiles)

Expand All @@ -401,7 +401,7 @@ export const ImportAquaChainFromChain = ({ fileInfo, isVerificationSuccessful }:
newFiles.push(file)
}
}

navigate("/")
}
} catch (e: any) {
Expand Down Expand Up @@ -527,7 +527,7 @@ export const ImportAquaChainFromChain = ({ fileInfo, isVerificationSuccessful }:
</TimelineConnector>
<TimelineContent>
<TimelineTitle textStyle="sm">Chains are Different</TimelineTitle>
<TimelineDescription>Chains have divergencies</TimelineDescription>
{/* <TimelineDescription>Chains have divergencies</TimelineDescription> */}
<List.Root>
{
comparisonResult?.divergences.map((diff, i: number) => (
Expand Down Expand Up @@ -561,8 +561,11 @@ export const ImportAquaChainFromChain = ({ fileInfo, isVerificationSuccessful }:
<LuCheck />
</TimelineConnector>
<TimelineContent>
<TimelineTitle textStyle="sm">Actions</TimelineTitle>
<TimelineDescription>Merge Chains</TimelineDescription>
<TimelineTitle textStyle="sm">Action</TimelineTitle>
<TimelineDescription>Merge Chain</TimelineDescription>
<Alert title="Action Not reversible!" status={'warning'}>
This action will delete some revision(s) in your local Aqua Chain
</Alert>
<Group>
<Button size={'xs'} borderRadius={'md'} onClick={handleMergeRevisions} loading={uploading}>Merge Revisions</Button>
</Group>
Expand Down
138 changes: 134 additions & 4 deletions web/src/components/ui/navigation/CustomDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from "../drawer"
import { Button } from "../button"
import { LuCheck, LuChevronDown, LuChevronUp, LuExternalLink, LuEye, LuX } from "react-icons/lu"
import { Box, Card, Collapsible, For, Group, Icon, Link, Spacer, Span, Text, VStack } from "@chakra-ui/react"
import { Box, Card, Collapsible, For, Group, Icon, IconButton, Link, Spacer, Span, Text, VStack } from "@chakra-ui/react"
import { TimelineConnector, TimelineContent, TimelineDescription, TimelineItem, TimelineRoot, TimelineTitle } from "../timeline"
import { PageData, Revision } from "../../../models/PageData"
import { formatCryptoAddress, getLastRevisionVerificationHash, timeToHumanFriendly } from "../../../utils/functions"
Expand All @@ -39,12 +39,12 @@ interface IItemDetail {
const ItemDetail = ({ label, value, displayValue, showCopyIcon }: IItemDetail) => {

return (
<Group>
<Group textAlign={'start'} w={'100%'}>
<Text>{label}</Text>
<Group>
<Text fontFamily={"monospace"} textWrap={'wrap'} wordBreak={'break-word'}>{displayValue}</Text>
<ClipboardRoot value={value} hidden={!showCopyIcon}>
<ClipboardIconButton size={'xs'} />
<ClipboardIconButton size={'2xs'} />
</ClipboardRoot>
</Group>
</Group>
Expand Down Expand Up @@ -274,6 +274,123 @@ const RevisionDisplay = ({ revision, verificationResult }: IRevisionDisplay) =>
</div>
)
}
interface IRevisionDetailsSummary {
fileInfo: ApiFileInfo
}

export const RevisionDetailsSummary = ({ fileInfo }: IRevisionDetailsSummary) => {


const pageData: PageData = JSON.parse(fileInfo.page_data);
const revisionHashes = Object.keys(pageData.pages[0].revisions)

//
const revisionsWithSignatures: Array<Revision> = [];
const revisionsWithWitness: Array<Revision> = [];

for (let i = 0; i < revisionHashes.length; i++) {
const currentRevision: string = revisionHashes[i];
const revision: Revision = pageData.pages[0].revisions[currentRevision];

if (revision.signature) {
revisionsWithSignatures.push(revision)
}

if (revision.witness) {
revisionsWithWitness.push(revision)
}
}


return (<VStack textAlign="start">
<Text>Revisions count : {revisionHashes.length}</Text>

<Box w={'100%'} bg={'gray.100'} _dark={{
bg: "blackAlpha.900"
}} borderRadius={'lg'} p={{ base: '4', md: 'lg' }}>
<Text mb={'2'} fontWeight={600} fontSize={'lg'}>Signatures ({revisionsWithSignatures.length})</Text>
<For
each={revisionsWithSignatures}
>
{(revision, index) => (
<Group key={`hash_${index}`} pb={'2'} mb={'4'} borderBottom={'1px solid'} borderColor={'gray.200'} _dark={{
borderColor: "gray.50"
}}>
<IconButton size={'xs'}>
{index + 1}
</IconButton>
<Box>
{/* <Text>{index}. {revision.signature?.signature} </Text> */}
<ItemDetail label="Signature Hash:"
displayValue={formatCryptoAddress(revision.signature?.signature_hash, 4, 6)}
value={revision.signature?.signature_hash ?? ""} showCopyIcon={true}
/>
<ItemDetail label="Wallet Address:"
// displayValue={formatCryptoAddress(revision.signature.wallet_address, 4, 6)}
displayValue={revision.signature?.wallet_address ?? ""}
value={revision.signature?.wallet_address ?? ""} showCopyIcon={true}
/>
<ItemDetail label="Timestamp:"
// displayValue={formatCryptoAddress(revision.signature.wallet_address, 4, 6)}
displayValue={timeToHumanFriendly(revision.metadata.time_stamp, true)}
value={revision.signature?.wallet_address ?? ""} showCopyIcon={false}
/>
</Box>
</Group>
)}
</For>
</Box>

<Box w={'100%'} bg={'gray.100'} _dark={{
bg: "blackAlpha.900"
}} borderRadius={'lg'} p={{ base: '4', md: 'lg' }}>
<Text mb={'2'} fontWeight={600} fontSize={'lg'}>Witnesses ({revisionsWithWitness.length})</Text>
<For
each={revisionsWithWitness}
>
{(revision, index) => (
<Group key={`witness_${index}`} pb={'2'} mb={'4'} borderBottom={'1px solid'} borderColor={'gray.200'} _dark={{
borderColor: "gray.50"
}}>
<IconButton size={'xs'}>
{index + 1}
</IconButton>
{/* <Text>{index}. {revision.signature?.signature} </Text> */}
<Box>
<ItemDetail label="Network:"
displayValue={formatCryptoAddress(revision.witness?.witness_network ?? "", 4, 6)}
value={revision.witness?.witness_network ?? " "} showCopyIcon={false}
/>
<br />
<ItemDetail label="Timestamp:"
displayValue={timeToHumanFriendly(revision.metadata.time_stamp, true)}
value={revision.signature?.wallet_address ?? ""} showCopyIcon={false}
/>
<br />
<ItemDetail label="Witness Hash:"
displayValue={formatCryptoAddress(revision.witness?.witness_hash ?? "", 4, 6)}
value={revision.witness?.witness_hash ?? ""} showCopyIcon={true}
/>
<br />
<Group>
<ItemDetail label="Transaction Hash:"
displayValue={formatCryptoAddress(revision.witness?.witness_event_transaction_hash.startsWith('0x') ? revision.witness?.witness_event_transaction_hash ?? "" : `0x${revision.witness?.witness_event_transaction_hash ?? ""}`, 4, 6)}
value={`0x${revision.witness?.witness_event_transaction_hash ?? ""}`} showCopyIcon={true}
/>
<Link outline={'none'} href={`${WITNESS_NETWORK_MAP[revision.witness?.witness_network ?? ""]}/${revision.witness?.witness_event_transaction_hash}`} target="_blank">
<Icon size={'sm'} color={'blue.500'}>
<LuExternalLink />
</Icon>
</Link>
</Group>
</Box>
</Group>
)}
</For>
</Box>
</VStack>
)
}

interface IPageDataDetails {
fileInfo: ApiFileInfo
Expand Down Expand Up @@ -345,6 +462,17 @@ export const ChainDetailsBtn = ({ fileInfo }: IPageDataDetails) => {
console.log("ChainDetailsBtn == > " + JSON.stringify(fileInfo))
}, [fileInfo])

useEffect(() => {
if (isOpen) {
const modalElement = document.getElementById('aqua-chain-details-modal');
const customEvent = new CustomEvent('REPLACE_ADDRESSES', {
detail: {
element: modalElement,
},
});
window.dispatchEvent(customEvent);
}
}, [isOpen])

return (
<>
Expand All @@ -353,7 +481,7 @@ export const ChainDetailsBtn = ({ fileInfo }: IPageDataDetails) => {
Details
</Button>

<DrawerRoot open={isOpen} size={{ base: 'full', md: 'lg' }} onOpenChange={(e) => setIsOpen(e.open)}>
<DrawerRoot open={isOpen} size={{ base: 'full', md: 'lg' }} id="aqua-chain-details-modal" onOpenChange={(e) => setIsOpen(e.open)}>
<DrawerBackdrop />
{/* <DrawerTrigger asChild>
<Button size={'xs'} colorPalette={'green'} variant={'subtle'} w={'80px'}>
Expand All @@ -377,6 +505,8 @@ export const ChainDetailsBtn = ({ fileInfo }: IPageDataDetails) => {
<Card.Body>
<VStack gap={'4'}>
<Alert status={isVerificationSuccessful ? 'success' : 'error'} title={isVerificationSuccessful ? "This chain is valid" : "This chain is invalid"} />

<RevisionDetailsSummary fileInfo={fileInfo} />
<Box w={'100%'}>
<Collapsible.Root open={showMoreDetails}>
<Collapsible.Trigger w="100%" py={'md'} onClick={() => setShowMoreDetails(open => !open)} cursor={'pointer'}>
Expand Down
30 changes: 19 additions & 11 deletions web/src/components/ui/navigation/VersionAndDisclaimer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useState } from "react";
import { Button } from "../button";
import { DialogBody, DialogCloseTrigger, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "../dialog";
import { Center, Dialog, Spacer, Text, VStack } from "@chakra-ui/react";
import { Center, Dialog, Link, Spacer, Text, VStack } from "@chakra-ui/react";
import { LuMessageCircleWarning } from "react-icons/lu";
import { useStore } from 'zustand'
import appStore from '../../../store'
Expand All @@ -18,9 +18,11 @@ export default function VersionAndDisclaimer() {
const [isOpen, setIsOpen] = useState(false);
const [versionDetails, setVersionDetails] = useState<VersionDetails>({
backend: "1.2.X",
frontend: "1.2.X"
frontend: "1.2.X",
aquifier: "1.2.X",
protocol: "1.2.X"
});




Expand All @@ -38,7 +40,7 @@ export default function VersionAndDisclaimer() {
if (response.status === 200) {
setVersionDetails(res)
}
} catch (e: unknown) {
} catch (e: unknown) {
console.log("Error fetching version ", e)
toaster.create({
description: "Error fetching version details",
Expand All @@ -48,11 +50,10 @@ export default function VersionAndDisclaimer() {
}

useEffect(() => {
if(!backend_url.includes("0.0.0.0")){
if (!backend_url.includes("0.0.0.0")) {
fetchVersionDetails()
}

},[backend_url])
}, [backend_url])

return (
<Dialog.Root placement={"center"} size={"sm"} open={isOpen} onOpenChange={(details) => setIsOpen(details.open)}>
Expand Down Expand Up @@ -82,14 +83,21 @@ export default function VersionAndDisclaimer() {
<Center>
Product Verion Details
</Center>
<Text fontFamily={"monospace"}>Container Api Version : {versionDetails.backend} </Text>
<Text fontFamily={"monospace"}>Container Web Version : {versionDetails.frontend} </Text>
<Text fontFamily={"monospace"}>aquafier Version : {versionDetails.aquifier} </Text>
<Text fontFamily={"monospace"}>protocol Version : {versionDetails.protocol} </Text>
<Spacer height={30} />

<Alert status="info" title="" variant="solid" >
<Alert status="error" title="" variant="solid" >
This is prototype software,use it with caution.
</Alert>
<Button borderRadius={"md"} onClick={() => {

<Text>
This software is developed by <Link href="https://inblock.io/" target="_blank" style={{"color":"blue"}}>inblock.io</Link> assets GmbH <br/> </Text>
<Text>
The source code can be found: <Link href="https://github.com/inblockio" target="_blank" style={{"color":"blue"}}>Inblock</Link>

</Text>
<Button borderRadius={"md"} onClick={() => {
setIsOpen(!isOpen);
}}>
close
Expand Down
Loading

0 comments on commit ffc6682

Please sign in to comment.