diff --git a/applications/tari_walletd/web_ui/src/contexts/ErrorNotificationContext.tsx b/applications/tari_walletd/web_ui/src/contexts/ErrorNotificationContext.tsx index e7e8a699b5..79e5d39f0f 100644 --- a/applications/tari_walletd/web_ui/src/contexts/ErrorNotificationContext.tsx +++ b/applications/tari_walletd/web_ui/src/contexts/ErrorNotificationContext.tsx @@ -88,6 +88,7 @@ export const ErrorNotificationProvider: React.FC<{ children: React.ReactNode }> { const selected = dataAccountsList?.accounts.find( - (acc: any) => substateIdToString(acc.account.address) === e.target.value, + (acc: any) => substateIdToString(acc.account.component_address) === e.target.value, ); setAccount(selected); }; @@ -272,23 +273,32 @@ function FlowEditor() { return ( - - Flow Editor - - - -
- -
-
+ + + Flow Editor + + + +
+ +
+
+
- Account used to pay fees + Account + Select the account used to pay fees {account ? ( @@ -341,12 +356,10 @@ function FlowEditor() { - - Transaction Fee - setFee(Number(e.target.value))} inputProps={{ min: 0 }} @@ -369,38 +382,38 @@ function FlowEditor() { /> - - Template ID - setTemplateId(e.target.value)} placeholder="Enter template id" fullWidth /> - Builtin Templates - t.address === templateId)?.address || ""} + onChange={(e) => setTemplateId(e.target.value)} + > + + None - ))} - + {KNOWN_TEMPLATES.map((template) => ( + + {template.name} {shortenString(template.address)} + + ))} + + Select a builtin template + - - - - Key - Value - Actions - - - - {Object.entries(variables).map(([k, v]) => ( - - {k} - {v} - - - + {Object.keys(variables).length > 0 && ( +
+ + + Key + Value + Actions - ))} - -
+ + + {Object.entries(variables).map(([k, v]) => ( + + {k} + {v} + + + + + ))} + + + )}
); } diff --git a/applications/tari_walletd/web_ui/src/routes/Templates/Templates.tsx b/applications/tari_walletd/web_ui/src/routes/Templates/Templates.tsx index 5d40ab9c3e..34a2285d3d 100644 --- a/applications/tari_walletd/web_ui/src/routes/Templates/Templates.tsx +++ b/applications/tari_walletd/web_ui/src/routes/Templates/Templates.tsx @@ -4,8 +4,23 @@ import { useListTemplatesAuthored } from "@api/hooks/useTemplatesAuthored"; import { useEffect, useState } from "react"; import { useAccountsList } from "@api/hooks/useAccounts"; -import InputLabel from "@mui/material/InputLabel"; -import Select, { SelectChangeEvent } from "@mui/material/Select/Select"; +import PageHeading from "@components/PageHeading"; +import { + InputLabel, + Select, + SelectChangeEvent, + MenuItem, + FormControl, + Table, + TableHead, + TableRow, + TableCell, + TableBody, + TableContainer, + Collapse, + TablePagination, + Stack, +} from "@mui/material"; import { AccountInfo, ArgDef, @@ -15,24 +30,16 @@ import { substateIdToString, Type as FuncType, } from "@tari-project/typescript-bindings"; -import MenuItem from "@mui/material/MenuItem"; -import FormControl from "@mui/material/FormControl"; -import Table from "@mui/material/Table"; -import TableHead from "@mui/material/TableHead"; -import TableRow from "@mui/material/TableRow"; -import TableCell from "@mui/material/TableCell"; -import TableBody from "@mui/material/TableBody"; -import TableContainer from "@mui/material/TableContainer"; import CopyAddress from "@components/CopyAddress"; -import { AccordionIconButton, DataTableCell } from "@components/StyledComponents"; +import { AccordionIconButton, DataTableCell, StyledPaper } from "@components/StyledComponents"; import Grid from "@mui/material/Grid"; import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp"; import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown"; -import { Collapse, TablePagination } from "@mui/material"; import { useTheme } from "@mui/material/styles"; import { SlCheck, SlClose } from "react-icons/sl"; import { handleChangePage, handleChangeRowsPerPage } from "@utils/helpers"; import useAccountStore from "@store/accountStore"; +import FetchStatusCheck from "@components/FetchStatusCheck"; function getTypeAsString(funcType: FuncType): string { if (typeof funcType === "string") { @@ -67,7 +74,12 @@ function Templates() { const [rowsPerPage, setRowsPerPage] = useState(10); const theme = useTheme(); const address = decodeOotleAddress(account?.address || accountStore.address); - const { data: templatesResponse } = useListTemplatesAuthored({ + const { + data: templatesResponse, + isLoading, + isError, + error, + } = useListTemplatesAuthored({ author_public_key: address.accountPublicKey, page: page, page_size: rowsPerPage, @@ -96,166 +108,172 @@ function Templates() { } }, [templatesResponse]); - if (isAccountsLoading) { - return
Loading...
; - } - return ( - - {

Templates

} - - {account ? ( - - Account - - - ) : null} - - {account ? ( - - - - - - Address - Name - Tari Version - - - - - {templatesResponse?.templates.map((template: AuthoredTemplate, index: number) => { - return ( - <> - - - - - {template.name} - {template.tari_version} - - { - if (open) { - const newOpen = open.map((value, idx) => (idx === index ? !value : value)); - setOpen(newOpen); - } - }} - > - {open[index] ? : } - - + + + {account ? ( + + Account + + + ) : null} + + {account ? ( + +
+ + + Address + Name + Tari Version + - {open[index] ? ( - - - -

Functions

- {template.functions ? ( - -
- - - Name - Mutable - Arguments - Output - - - - {template.functions.map((funcDef: FunctionDef, index: number) => { - return ( - - {funcDef.name} - - {funcDef.is_mut ? ( - - ) : ( - - )} - - - {funcDef.arguments.length > 0 ? ( - -
- - - Name - Type - - - - {funcDef.arguments.map((arg: ArgDef, index: number) => { - return ( - - {arg.name} - {getTypeAsString(arg.arg_type)} - - ); - })} - -
-
- ) : ( - - )} - - {getTypeAsString(funcDef.output)} - - ); - })} - - - - ) : null} - - - - ) : null} - - ); - })} - - - - - handleChangePage(event, newPage, setPage)} - onRowsPerPageChange={(event) => handleChangeRowsPerPage(event, setRowsPerPage, setPage)} - /> - -
- ) : null} -
+ + + {templatesResponse?.templates.map((template: AuthoredTemplate, index: number) => { + return ( + <> + + + + + {template.name} + {template.tari_version} + + { + if (open) { + const newOpen = open.map((value, idx) => (idx === index ? !value : value)); + setOpen(newOpen); + } + }} + > + {open[index] ? : } + + + + {open[index] ? ( + + + +

Functions

+ {template.functions ? ( + + + + + Name + Mutable + Arguments + Output + + + + {template.functions.map((funcDef: FunctionDef, index: number) => { + return ( + + {funcDef.name} + + {funcDef.is_mut ? ( + + ) : ( + + )} + + + {funcDef.arguments.length > 0 ? ( + +
+ + + Name + Type + + + + {funcDef.arguments.map((arg: ArgDef, index: number) => { + return ( + + {arg.name} + {getTypeAsString(arg.arg_type)} + + ); + })} + +
+
+ ) : ( + + )} + + {getTypeAsString(funcDef.output)} +
+ ); + })} +
+ + + ) : null} + + + + ) : null} + + ); + })} + + + + ) : null} + handleChangePage(event, newPage, setPage)} + onRowsPerPageChange={(event) => handleChangeRowsPerPage(event, setRowsPerPage, setPage)} + /> + + + +
+ ); }