Skip to content

Commit

Permalink
update functions and front
Browse files Browse the repository at this point in the history
  • Loading branch information
daoauth committed Jul 16, 2024
1 parent 798fad5 commit abcf573
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 49 deletions.
15 changes: 6 additions & 9 deletions functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ export const create = onRequest(async (req, res) => {
return;
}

const { chain, network, project, provenance } = req.body as DocData;
const { network, project, provenance } = req.body as DocData;

if (!chain || !network || !project || !provenance) {
if (!network || !project || !provenance) {
res
.status(400)
.send(
'Invalid input, missing "chain", "network", "project" or "provenance"',
);
.send('Invalid input, missing "network", "project" or "provenance"');
return;
}

Expand All @@ -41,7 +39,6 @@ export const create = onRequest(async (req, res) => {
const firestore = admin.firestore();
const docRef = firestore.collection('unsigned').doc(uid);
await docRef.set({
chain,
network,
project,
provenance,
Expand Down Expand Up @@ -112,13 +109,13 @@ const _load = async (
return;
}

const { chain, network, project, provenance, serializedSignedTx } =
const { network, project, provenance, serializedSignedTx } =
doc.data() as DocData;
if (collection === 'signed') {
await docRef.delete();
res.status(200).json({ chain, network, serializedSignedTx });
res.status(200).json({ network, serializedSignedTx });
} else {
res.status(200).json({ chain, network, project, provenance });
res.status(200).json({ network, project, provenance });
}
} catch (error) {
console.error(`Error reading and deleting data from ${collection}:`, error);
Expand Down
3 changes: 1 addition & 2 deletions functions/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
interface Provenance {
name: string; // packageName
summary: string; // build summary
commit: string; // source commit
workflow: string; // build workflow
ledger: string; // public ledger
}

export interface DocData {
chain: 'aptos' | 'sui';
network: string;
project: string;
name: string; // packageName
provenance: Provenance;
serializedSignedTx?: string;
}
1 change: 1 addition & 0 deletions public/logo/aptos.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/logo/sui.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function App() {
return (
<>
{!state && <Loading />}
{!!state && state.chain === 'sui' && (
{!!state && state.network.split(':')[0] === 'sui' && (
<QueryClientProvider client={queryClient}>
<SuiClientProvider
defaultNetwork="mainnet"
Expand Down
84 changes: 84 additions & 0 deletions src/component/Provenance.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { Avatar, Box, Button, Card, Flex, Link, Text } from '@radix-ui/themes';
import { useRecoilState } from 'recoil';

import { docDataState } from '../recoil';

export const Provenance = () => {
const [state] = useRecoilState(docDataState);
console.log(state);
return (
<>
{state && (
<Flex direction="column" gap="2">
<Box maxWidth="240px">
<Card>
<Flex gap="3" align="center">
<Avatar
size="3"
src={`/logo/${state.network.split(':')[0]}.svg`}
fallback="T"
/>
<Box>
<Text as="div" size="2" weight="bold">
{state.network}
</Text>
<Text as="div" size="2" color="gray">
{state.name}
</Text>
</Box>
</Flex>
</Card>
</Box>
<Box>
<Card>
<Flex gap="3" align="start" direction="column">
<Text as="div" size="3" weight="bold">
Built and signed on Github Actions
</Text>
<Flex direction="column" gap="1" maxWidth="420px">
<Flex direction="column">
<Text size="2">Build Summary</Text>
<Link size="1" color="gray" href={state.provenance.summary}>
<Flex>
<Text truncate>{state.provenance.summary}</Text>
</Flex>
</Link>
</Flex>
<Flex direction="column">
<Text size="2">Source Commit</Text>
<Link size="1" color="gray" href={state.provenance.commit}>
<Flex>
<Text truncate>{state.provenance.commit}</Text>
</Flex>
</Link>
</Flex>
<Flex direction="column">
<Text size="2">Build Workflow</Text>
<Link
size="1"
color="gray"
href={state.provenance.workflow}
>
<Flex>
<Text truncate>{state.provenance.workflow}</Text>
</Flex>
</Link>
</Flex>
<Flex direction="column">
<Text size="2">Public Ledger</Text>
<Link size="1" color="gray" href={state.provenance.ledger}>
<Flex>
<Text truncate>{state.provenance.ledger}</Text>
</Flex>
</Link>
</Flex>
</Flex>
<Button>Sign</Button>
</Flex>
</Card>
</Box>
</Flex>
)}
</>
);
};
40 changes: 3 additions & 37 deletions src/component/Sui.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { useEffect } from 'react';

import { ConnectButton, useCurrentAccount } from '@mysten/dapp-kit';
import { Button, Card, Flex, Link, Text } from '@radix-ui/themes';
import { Flex } from '@radix-ui/themes';
import { useRecoilState } from 'recoil';

import { Provenance } from './Provenance';
import { docDataState } from '../recoil';

export const Sui = () => {
Expand All @@ -22,42 +23,7 @@ export const Sui = () => {
justify="center"
height="100vh"
>
{state && currentAccount && (
<Card>
<Flex gap="3" align="start" direction="column">
<Text as="div" size="4" weight="bold">
Built and signed on Github Actions
</Text>
<Flex direction="column">
<Flex gap="2">
<Text size="2">Build Summary</Text>
<Link color="gray" size="2" href={state.provenance.summary}>
{state.provenance.summary}
</Link>
</Flex>
<Flex gap="2">
<Text size="2">Source Commit</Text>
<Link color="gray" size="2" href={state.provenance.commit}>
{state.provenance.commit}
</Link>
</Flex>
<Flex gap="2">
<Text size="2">Build Workflow</Text>
<Link color="gray" size="2" href={state.provenance.workflow}>
{state.provenance.workflow}
</Link>
</Flex>
<Flex gap="2">
<Text size="2">Public Ledger</Text>
<Link color="gray" size="2" href={state.provenance.ledger}>
{state.provenance.ledger}
</Link>
</Flex>
</Flex>
<Button>Sign</Button>
</Flex>
</Card>
)}
{state && currentAccount && <Provenance />}
{!currentAccount && <ConnectButton />}
</Flex>
);
Expand Down

0 comments on commit abcf573

Please sign in to comment.