Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(consensus): various consensus fixes from tariswap testing #1062

Merged
merged 8 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:

- name: prettier
run: |
npx prettier --check "./applications/{tari_validator_node_web_ui,tari_indexer_web_ui,tari_dan_wallet_web_ui}/src/*.{ts,tsx,css,json}"
npx prettier --check "./applications/{tari_validator_node_web_ui,tari_indexer_web_ui,tari_dan_wallet_web_ui}/src/*.{ts,tsx,json}"

clippy:
name: clippy
Expand Down
6 changes: 3 additions & 3 deletions .prettierrc → .prettierrc.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
export default {
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
Expand All @@ -9,5 +9,5 @@
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "always",
"endOfLine": "lf"
}
"endOfLine": "lf",
};
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions applications/tari_dan_wallet_daemon/src/handlers/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,17 @@ pub async fn handle_claim_validator_fees(

let finalized = wait_for_result(&mut events, tx_id).await?;

if let Some(reject) = finalized.finalize.result.reject() {
if let Some(reject) = finalized.finalize.reject() {
return Err(anyhow::anyhow!("Fee transaction rejected: {}", reject));
}
if let Some(reason) = finalized.finalize.reject() {
if let Some(reason) = finalized.finalize.full_reject() {
return Err(anyhow::anyhow!(
"Fee transaction succeeded (fees charged) however the transaction failed: {}",
reason
"Fee transaction succeeded (fees charged) however the transaction failed: {reason}",
));
}
info!(
target: LOG_TARGET,
"✅ Transfer transaction {} finalized. Fee: {}",
"✅ Claim fee transaction {} finalized. Fee: {}",
finalized.transaction_id,
finalized.final_fee
);
Expand Down
3 changes: 3 additions & 0 deletions applications/tari_dan_wallet_web_ui/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import base from "../../.prettierrc.mjs";

export default base;
22 changes: 19 additions & 3 deletions applications/tari_dan_wallet_web_ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions applications/tari_dan_wallet_web_ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
"@mui/x-data-grid": "^6.0.2",
"@tanstack/react-query": "^4.33.0",
"@tanstack/react-query-devtools": "^4.33.0",
"@tariproject/typescript-bindings": "file:../../bindings",
"@tariproject/wallet_daemon_client": "file:../../clients/javascript/wallet_daemon_client",
"file-saver": "^2.0.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.9.0",
"react-router-dom": "^6.9.0",
"@tariproject/typescript-bindings": "file:../../bindings",
"@tariproject/wallet_daemon_client": "file:../../clients/javascript/wallet_daemon_client",
"use-react-router-breadcrumbs": "^4.0.1",
"zustand": "^4.4.1",
"zustand-persist": "^0.1.6"
Expand All @@ -32,6 +32,7 @@
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@vitejs/plugin-react-swc": "^3.0.0",
"prettier": "^3.3.2",
"typescript": "^4.9.3",
"vite": "^4.5.3"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import MuiAccordionDetails from "@mui/material/AccordionDetails";
export const Accordion = styled((props: AccordionProps) => (
<MuiAccordion disableGutters elevation={0} square {...props} />
))(({ theme }) => ({
border: `2px solid ${theme.palette.background.paper}`,
"border": `2px solid ${theme.palette.background.paper}`,
"&:not(:last-child)": {
borderBottom: 0,
},
Expand All @@ -41,8 +41,8 @@ export const Accordion = styled((props: AccordionProps) => (
export const AccordionSummary = styled((props: AccordionSummaryProps) => (
<MuiAccordionSummary expandIcon={<KeyboardArrowRightRoundedIcon />} {...props} />
))(({ theme }) => ({
backgroundColor: theme.palette.divider,
flexDirection: "row-reverse",
"backgroundColor": theme.palette.divider,
"flexDirection": "row-reverse",
"& .MuiAccordionSummary-expandIconWrapper.Mui-expanded": {
transform: "rotate(90deg)",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ export default function Permissions(props: {
optionalPermissions: TariPermission[];
setOptionalPermissions: any;
}) {
const {
requiredPermissions,
optionalPermissions,
setOptionalPermissions,
} = props;
const { requiredPermissions, optionalPermissions, setOptionalPermissions } = props;
const [permissions, setPermissions] = useState(
optionalPermissions.map((permission, index) => {
return { id: index, name: permission.toString(), checked: true };
Expand Down Expand Up @@ -71,7 +67,7 @@ export default function Permissions(props: {
<FormControl component="fieldset" variant="standard" style={{ width: "100%" }}>
<Divider />
<FormGroup>
{requiredPermissions.map((permission, i) =>
{requiredPermissions.map((permission, i) => (
<React.Fragment key={i}>
<FormControlLabel
control={<Switch checked={true} disabled={true} />}
Expand All @@ -81,11 +77,11 @@ export default function Permissions(props: {
className="permissions-switch"
/>
<Divider />
</React.Fragment>,
)}
</React.Fragment>
))}
</FormGroup>
<FormGroup>
{permissions.map(({ checked, name, id }, i) =>
{permissions.map(({ checked, name, id }, i) => (
<React.Fragment key={i}>
<FormControlLabel
control={<Switch checked={checked} onChange={() => handleChange(id)} name={name} value={name} />}
Expand All @@ -95,8 +91,8 @@ export default function Permissions(props: {
className="permissions-switch"
/>
<Divider />
</React.Fragment>,
)}
</React.Fragment>
))}
</FormGroup>
<FormHelperText style={{ marginBottom: "20px", marginTop: "20px" }}>
You may be sharing sensitive information with this site. Approve or deny access above.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ function displayNftId(nftId: NonFungibleId) {
return `String:${nftId.String}`;
}


return JSON.stringify(nftId);
}

Expand All @@ -76,12 +75,7 @@ export interface NftListProps {
}

export default function NFTList(props: NftListProps) {
const {
nftsListIsError,
nftsListIsFetching,
nftsListError,
nftsListData,
} = props;
const { nftsListIsError, nftsListIsFetching, nftsListError, nftsListData } = props;
if (nftsListIsError || nftsListIsFetching) {
<FetchStatusCheck
isError={nftsListIsError}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import IconButton from "@mui/material/IconButton";
import Typography from "@mui/material/Typography";

export const AccordionIconButton = styled(IconButton)(({ theme }) => ({
backgroundColor: theme.palette.divider,
color: theme.palette.primary.main,
"backgroundColor": theme.palette.divider,
"color": theme.palette.primary.main,
"&:hover": {
backgroundColor: theme.palette.primary.main,
color: "#fff",
Expand Down
20 changes: 9 additions & 11 deletions applications/tari_dan_wallet_web_ui/src/api/hooks/useAccounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,15 @@ export const useAccountsTransfer = (
};

export const useAccountsCreateFreeTestCoins = () => {
const createFreeTestCoins = async (
{
accountName,
amount,
fee,
}: {
accountName: string | null;
amount: number;
fee: number | null;
}) => {
const createFreeTestCoins = async ({
accountName,
amount,
fee,
}: {
accountName: string | null;
amount: number;
fee: number | null;
}) => {
const result = await accountsCreateFreeTestCoins({
account: (accountName && { Name: accountName }) || null,
amount,
Expand Down Expand Up @@ -168,7 +167,6 @@ export const useAccountsList = (offset: number, limit: number) => {
});
};


export const useAccountsGetBalances = (accountName: string, refresh: boolean = false) => {
return useQuery({
queryKey: ["accounts_balances"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,8 @@ interface BalanceRowProps {
}

function BalanceRow(props: BalanceRowProps) {
const {
token_symbol,
resource_address,
resource_type,
balance,
confidential_balance,
vault_address,
onSendClicked,
} = props;
const { token_symbol, resource_address, resource_type, balance, confidential_balance, vault_address, onSendClicked } =
props;
const { showBalance } = useAccountStore();
return (
<TableRow key={token_symbol || resource_address}>
Expand All @@ -79,11 +72,7 @@ function BalanceRow(props: BalanceRowProps) {
<DataTableCell>{resource_type}</DataTableCell>
<DataTableCell>{showBalance ? balance : "*************"}</DataTableCell>
<DataTableCell>
<ConfidentialBalance
show={showBalance}
resourceType={resource_type}
balance={confidential_balance}
/>
<ConfidentialBalance show={showBalance} resourceType={resource_type} balance={confidential_balance} />
</DataTableCell>
<DataTableCell>
<Button variant="outlined" onClick={() => onSendClicked?.(resource_address, resource_type)}>
Expand All @@ -94,7 +83,7 @@ function BalanceRow(props: BalanceRowProps) {
);
}

function ConfidentialBalance(props: { show: boolean, balance: number, resourceType: string }) {
function ConfidentialBalance(props: { show: boolean; balance: number; resourceType: string }) {
switch (props.resourceType) {
case "Confidential":
return <>{props.show ? props.balance : "**************"}</>;
Expand Down Expand Up @@ -125,15 +114,15 @@ function TabPanel(props: TabPanelProps) {

function tabProps(index: number) {
return {
id: `asset-tab-${index}`,
"id": `asset-tab-${index}`,
"aria-controls": `asset-tabpanel-${index}`,
};
}

function Assets({ accountName }: { accountName: string }) {
const [resourceToSend, setResourceToSend] = useState<{
address: ResourceAddress,
resource_type: ResourceType
address: ResourceAddress;
resource_type: ResourceType;
} | null>(null);
const [value, setValue] = useState(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function SendMoney() {
export interface SendMoneyDialogProps {
open: boolean;
resource_address?: ResourceAddress;
resource_type?: ResourceType,
resource_type?: ResourceType;
onSendComplete?: () => void;
handleClose: () => void;
}
Expand Down Expand Up @@ -181,7 +181,10 @@ export function SendMoneyDialog(props: SendMoneyDialogProps) {
title: "Fee estimate failed",
error: true,
// TODO: fix this
message: JSON.stringify(unionGet(result.result.result, "Reject" as keyof TransactionResult) || unionGet(result.result.result, "AcceptFeeRejectRest" as keyof TransactionResult)?.[1]),
message: JSON.stringify(
unionGet(result.result.result, "Reject" as keyof TransactionResult) ||
unionGet(result.result.result, "AcceptFeeRejectRest" as keyof TransactionResult)?.[1],
),
});
return;
}
Expand Down Expand Up @@ -274,18 +277,10 @@ export function SendMoneyDialog(props: SendMoneyDialogProps) {
value={transferFormState.inputSelection}
onChange={setSelectFormValue}
>
<MenuItem value="PreferRevealed">
Spend revealed funds first, then confidential
</MenuItem>
<MenuItem value="PreferConfidential">
Spend confidential funds first, then revealed
</MenuItem>
<MenuItem value="ConfidentialOnly">
Only spend confidential funds
</MenuItem>
<MenuItem value="RevealedOnly">
Only spend revealed funds
</MenuItem>
<MenuItem value="PreferRevealed">Spend revealed funds first, then confidential</MenuItem>
<MenuItem value="PreferConfidential">Spend confidential funds first, then revealed</MenuItem>
<MenuItem value="ConfidentialOnly">Only spend confidential funds</MenuItem>
<MenuItem value="RevealedOnly">Only spend revealed funds</MenuItem>
</Select>
</>
)}
Expand Down Expand Up @@ -326,7 +321,6 @@ export function SendMoneyDialog(props: SendMoneyDialogProps) {
);
}


function unionGet<T extends object>(object: T, key: keyof T): T[keyof T] | null {
return key in object ? object[key] : null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function CustomTabPanel(props: TabPanelProps) {

function a11yProps(index: number) {
return {
id: `simple-tab-${index}`,
"id": `simple-tab-${index}`,
"aria-controls": `simple-tabpanel-${index}`,
};
}
Expand Down
Loading
Loading