From abcf5738a313859657d26c84d7bcd48eb6b36ebb Mon Sep 17 00:00:00 2001 From: Lim Jet <57783762+daoauth@users.noreply.github.com> Date: Tue, 16 Jul 2024 17:46:55 +0900 Subject: [PATCH] update functions and front --- functions/src/index.ts | 15 +++---- functions/src/types.ts | 3 +- public/logo/aptos.svg | 1 + public/logo/sui.svg | 1 + src/App.tsx | 2 +- src/component/Provenance.tsx | 84 ++++++++++++++++++++++++++++++++++++ src/component/Sui.tsx | 40 ++--------------- 7 files changed, 97 insertions(+), 49 deletions(-) create mode 100644 public/logo/aptos.svg create mode 100644 public/logo/sui.svg create mode 100644 src/component/Provenance.tsx diff --git a/functions/src/index.ts b/functions/src/index.ts index 20f9196..cc8c6ee 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -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; } @@ -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, @@ -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); diff --git a/functions/src/types.ts b/functions/src/types.ts index dd9b6eb..e6e360a 100644 --- a/functions/src/types.ts +++ b/functions/src/types.ts @@ -1,5 +1,4 @@ interface Provenance { - name: string; // packageName summary: string; // build summary commit: string; // source commit workflow: string; // build workflow @@ -7,9 +6,9 @@ interface Provenance { } export interface DocData { - chain: 'aptos' | 'sui'; network: string; project: string; + name: string; // packageName provenance: Provenance; serializedSignedTx?: string; } diff --git a/public/logo/aptos.svg b/public/logo/aptos.svg new file mode 100644 index 0000000..a2b8347 --- /dev/null +++ b/public/logo/aptos.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/logo/sui.svg b/public/logo/sui.svg new file mode 100644 index 0000000..2d62da6 --- /dev/null +++ b/public/logo/sui.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index a62d5bf..4bc031c 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -15,7 +15,7 @@ function App() { return ( <> {!state && } - {!!state && state.chain === 'sui' && ( + {!!state && state.network.split(':')[0] === 'sui' && ( { + const [state] = useRecoilState(docDataState); + console.log(state); + return ( + <> + {state && ( + + + + + + + + {state.network} + + + {state.name} + + + + + + + + + + Built and signed on Github Actions + + + + Build Summary + + + {state.provenance.summary} + + + + + Source Commit + + + {state.provenance.commit} + + + + + Build Workflow + + + {state.provenance.workflow} + + + + + Public Ledger + + + {state.provenance.ledger} + + + + + + + + + + )} + + ); +}; diff --git a/src/component/Sui.tsx b/src/component/Sui.tsx index 3904996..c721ede 100644 --- a/src/component/Sui.tsx +++ b/src/component/Sui.tsx @@ -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 = () => { @@ -22,42 +23,7 @@ export const Sui = () => { justify="center" height="100vh" > - {state && currentAccount && ( - - - - Built and signed on Github Actions - - - - Build Summary - - {state.provenance.summary} - - - - Source Commit - - {state.provenance.commit} - - - - Build Workflow - - {state.provenance.workflow} - - - - Public Ledger - - {state.provenance.ledger} - - - - - - - )} + {state && currentAccount && } {!currentAccount && } );