Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/tari-project/tari-dan
Browse files Browse the repository at this point in the history
…into rocksdb
  • Loading branch information
mrnaveira committed Jan 16, 2025
2 parents e8c3469 + 9500de9 commit 6bc77cf
Show file tree
Hide file tree
Showing 143 changed files with 2,847 additions and 1,650 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ concurrency:

env:
nightly_toolchain: nightly-2023-06-12
stable_toolchain: 1.82
stable_toolchain: 1.84
CARGO_HTTP_MULTIPLEXING: false
CARGO_TERM_COLOR: always
TARI_TARGET_NETWORK: localnet
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ chacha20poly1305 = "0.10.1"
chrono = "0.4.24"
config = "0.14.0"
convert_case = "0.6.0"
cucumber = "0.21.0"
cucumber = "0.21.1"
d3ne = { git = "https://github.com/stringhandler/d3ne-rs.git", tag = "v0.8.0-pre.3" }
dashmap = "5.5.0"
diesel = { version = "2.2.6", default-features = false }
Expand Down
24 changes: 18 additions & 6 deletions applications/tari_dan_app_utilities/src/base_layer_scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ impl<TAddr: NodeAddressable + 'static, TStore: StateStore> BaseLayerScanner<TAdd
);
continue;
}
trace!(target: LOG_TARGET, "New validator node registration scanned: {reg:?}");
info!(target: LOG_TARGET, "🖥️ New validator node registration: {}", reg.public_key());
},
// TODO: remove completely SideChainFeature::CodeTemplateRegistration at some point
SideChainFeatureData::CodeTemplateRegistration(reg) => {
Expand Down Expand Up @@ -422,10 +422,7 @@ impl<TAddr: NodeAddressable + 'static, TStore: StateStore> BaseLayerScanner<TAdd
"⛓️ last_scanned_validator_node_mr = {} current = {}", self.last_scanned_validator_node_mr.display(), current_validator_node_mr
);
// if the validator node MR has changed, we need to update the active validator node set
if self
.last_scanned_validator_node_mr
.map_or(true, |last| last != current_validator_node_mr)
{
if self.last_scanned_validator_node_mr != Some(current_validator_node_mr) {
let constants = self.base_node_client.get_consensus_constants(block_info.height).await?;
let scanned_epoch = constants.height_to_epoch(block_info.height);
self.update_validators(scanned_epoch).await?;
Expand Down Expand Up @@ -459,7 +456,22 @@ impl<TAddr: NodeAddressable + 'static, TStore: StateStore> BaseLayerScanner<TAdd
}
}

self.epoch_manager.notify_scanning_complete().await?;
let latest = self.base_node_client.get_tip_info().await?;
if latest
.height_of_longest_chain
.saturating_sub(self.consensus_constants.base_layer_confirmations) >
end_height
{
info!(
target: LOG_TARGET,
"Base layer blockchain has progressed since the last scan. Last scanned block height: {}. \
Latest block height: {}",
end_height,
latest.height_of_longest_chain
);
} else {
self.epoch_manager.notify_scanning_complete().await?;
}

Ok(())
}
Expand Down
6 changes: 3 additions & 3 deletions applications/tari_dan_wallet_daemon/src/handlers/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ pub async fn handle_reveal_funds(
let account_substate = sdk.substate_api().get_substate(&account.address)?;
// Add all versioned account child addresses as inputs
let child_addresses = sdk.substate_api().load_dependent_substates(&[&account.address])?;
let mut inputs = vec![account_substate.address];
let mut inputs = vec![account_substate.substate_id];
inputs.extend(child_addresses);

let inputs = inputs
Expand Down Expand Up @@ -817,7 +817,7 @@ fn get_or_create_account<T: WalletStore>(
.key_manager_api()
.derive_key(key_manager::TRANSACTION_BRANCH, key_index)?;
let account_substate = sdk.substate_api().get_substate(&account.address)?;
inputs.push(account_substate.address.into());
inputs.push(account_substate.substate_id.into());

(account.address, account_secret_key, None)
},
Expand Down Expand Up @@ -863,7 +863,7 @@ pub async fn handle_transfer(
.accounts_api()
.get_vault_by_resource(&account.address, &req.resource_address)?;
let src_vault_substate = sdk.substate_api().get_substate(&src_vault.address)?;
inputs.push(src_vault_substate.address);
inputs.push(src_vault_substate.substate_id);

// add the input for the resource address to be transfered
let resource_substate = sdk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub async fn handle_create_transfer_proof(
.substate_api()
.scan_for_substate(
&req.resource_address.into(),
known_resource_substate_address.map(|s| s.address.version),
known_resource_substate_address.map(|s| s.substate_id.version),
)
.await?;
let resource_view_key = resource
Expand Down
6 changes: 3 additions & 3 deletions applications/tari_dan_wallet_daemon/src/handlers/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

use std::fmt::Display;

use tari_dan_common_types::optional::Optional;
use tari_dan_common_types::{optional::Optional, VersionedSubstateId};
use tari_dan_wallet_sdk::{
apis::accounts::{AccountsApi, AccountsApiError},
models::{Account, VersionedSubstateId},
models::Account,
DanWalletSdk,
};
use tari_dan_wallet_storage_sqlite::SqliteWalletStore;
Expand Down Expand Up @@ -95,7 +95,7 @@ pub fn get_account_with_inputs(

// add the input for the source account component substate
let account_substate = sdk.substate_api().get_substate(&account.address)?;
inputs.push(account_substate.address);
inputs.push(account_substate.substate_id);

// Add all versioned account child addresses as inputs
let child_addresses = sdk.substate_api().load_dependent_substates(&[&account.address])?;
Expand Down
6 changes: 3 additions & 3 deletions applications/tari_dan_wallet_daemon/src/handlers/substates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ pub async fn handle_get(

let substate = sdk
.get_network_interface()
.query_substate(&record.address.substate_id, Some(record.address.version), false)
.query_substate(&record.substate_id.substate_id, Some(record.substate_id.version), false)
.await?;

Ok(SubstatesGetResponse {
record: WalletSubstateRecord {
substate_id: record.address.substate_id,
substate_id: record.substate_id.substate_id,
parent_id: record.parent_address,
module_name: record.module_name,
version: record.address.version,
version: record.substate_id.version,
template_address: record.template_address,
},
value: substate.substate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,16 @@ where
created_by_tx,
} = substate_api
.scan_for_substate(
&account_substate.address.substate_id,
Some(account_substate.address.version),
&account_substate.substate_id.substate_id,
Some(account_substate.substate_id.version),
)
.await?;

substate_api.save_root(created_by_tx, versioned_account_address.clone())?;

let vaults_value = IndexedWellKnownTypes::from_value(account_value.component().unwrap().state())?;
let known_child_vaults = substate_api
.load_dependent_substates(&[&account_substate.address.substate_id])?
.load_dependent_substates(&[&account_substate.substate_id.substate_id])?
.into_iter()
.filter(|s| s.substate_id.is_vault())
.map(|s| (s.substate_id, s.version))
Expand Down Expand Up @@ -330,6 +330,7 @@ where

let non_fungible = NonFungibleToken {
is_burned: maybe_nft_contents.is_none(),
resource_address: *vault.resource_address(),
vault_id,
nft_id: id.clone(),
data: maybe_nft_contents
Expand Down Expand Up @@ -480,7 +481,7 @@ where
let version = substate_api
.get_substate(&resx_addr)
.optional()?
.map(|s| s.address.version)
.map(|s| s.substate_id.version)
.unwrap_or(0);
let ValidatorScanResult { substate: resource, .. } =
substate_api.scan_for_substate(&resx_addr, Some(version)).await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,21 @@
import Loading from "./Loading";
import Error from "./Error";

interface IFetchStatusCheck {
interface FetchStatusCheckProps {
errorMessage: string;
isError: boolean;
isLoading: boolean;
children: React.ReactNode;
}

function FetchStatusCheck({ isLoading, isError, errorMessage }: IFetchStatusCheck) {
function FetchStatusCheck({ isLoading, isError, errorMessage, children }: FetchStatusCheckProps) {
if (isLoading) {
return <Loading />;
}
if (isError) {
return <Error message={errorMessage} />;
}
return null;
return <>{children}</>;
}

export default FetchStatusCheck;
31 changes: 16 additions & 15 deletions applications/tari_dan_wallet_web_ui/src/Components/NFTList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,20 @@ import FetchStatusCheck from "./FetchStatusCheck";
import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from "@mui/material";
import type { apiError } from "../api/helpers/types";
import { DataTableCell } from "./StyledComponents";
import { toHexString } from "../utils/helpers";
import { renderJson, shortenString, shortenSubstateId, toHexString } from "../utils/helpers";
import { IoCheckmarkOutline, IoCloseOutline } from "react-icons/io5";
import type { NonFungibleId, NonFungibleToken, ListAccountNftResponse } from "@tari-project/typescript-bindings";
import { convertCborValue } from "../utils/cbor";

function NftsList({ nft }: { nft: NonFungibleToken }) {
function NftListItem({ nft }: { nft: NonFungibleToken }) {
return (
<TableRow>
<DataTableCell>{displayNftId(nft.nft_id)}</DataTableCell>
<DataTableCell>{nft.vault_id}</DataTableCell>
<DataTableCell>{JSON.stringify(convertCborValue(nft.data))}</DataTableCell>
<DataTableCell>{JSON.stringify(convertCborValue(nft.mutable_data))}</DataTableCell>
<DataTableCell>{shortenSubstateId(nft.vault_id)}</DataTableCell>
<DataTableCell>
<DataTableCell>{renderJson(convertCborValue(nft.data))}</DataTableCell>
</DataTableCell>
<DataTableCell>{renderJson(convertCborValue(nft.mutable_data))}</DataTableCell>
<DataTableCell>
{nft.is_burned ? (
<IoCheckmarkOutline style={{ height: 22, width: 22 }} color="#DB7E7E" />
Expand All @@ -50,15 +52,14 @@ function NftsList({ nft }: { nft: NonFungibleToken }) {

function displayNftId(nftId: NonFungibleId) {
if ("U256" in nftId) {
return `U256:${toHexString(nftId.U256)}`;
return `U256:${shortenString(toHexString(nftId.U256))}`;
}
if ("Uint64" in nftId) {
return `Uint64:${nftId.Uint64}`;
}
if ("Uint32" in nftId) {
return `Uint32:${nftId.Uint32}`;
}

if ("String" in nftId) {
return `String:${nftId.String}`;
}
Expand All @@ -75,13 +76,7 @@ export interface NftListProps {

export default function NFTList(props: NftListProps) {
const { nftsListIsError, nftsListIsFetching, nftsListError, nftsListData } = props;
if (nftsListIsError || nftsListIsFetching) {
<FetchStatusCheck
isError={nftsListIsError}
errorMessage={nftsListError?.message || "Error fetching data"}
isLoading={nftsListIsFetching}
/>;
}

return (
<TableContainer>
<Table>
Expand All @@ -95,7 +90,13 @@ export default function NFTList(props: NftListProps) {
</TableRow>
</TableHead>
<TableBody>
{nftsListData?.nfts.map((nft: NonFungibleToken, index: number) => <NftsList key={index} nft={nft} />)}
<FetchStatusCheck
isError={nftsListIsError}
errorMessage={nftsListError?.message || "Error fetching data"}
isLoading={nftsListIsFetching}
>
{nftsListData?.nfts.map((nft: NonFungibleToken, index: number) => <NftListItem key={index} nft={nft} />)}
</FetchStatusCheck>
</TableBody>
</Table>
</TableContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ function AccountDetailsLayout() {
</Grid>
<Grid item xs={12} md={12} lg={12}>
<StyledPaper>
<FetchStatusCheck
isError={accountsIsError}
errorMessage={accountsError?.message || "Error fetching data"}
isLoading={accountsIsLoading}
/>
<TableContainer>
<Table>
<TableHead>
Expand All @@ -97,19 +92,25 @@ function AccountDetailsLayout() {
</TableRow>
</TableHead>
<TableBody>
{accountsData && (
<TableRow>
<DataTableCell>{accountsData.account.name}</DataTableCell>
<DataTableCell>
{shortenString(substateIdToString(accountsData.account.address))}
<CopyToClipboard copy={substateIdToString(accountsData.account.address)} />
</DataTableCell>
<DataTableCell>
{shortenString(accountsData.public_key)}
<CopyToClipboard copy={accountsData.public_key} />
</DataTableCell>
</TableRow>
)}
<FetchStatusCheck
isError={accountsIsError}
errorMessage={accountsError?.message || "Error fetching data"}
isLoading={accountsIsLoading}
>
{accountsData && (
<TableRow>
<DataTableCell>{accountsData.account.name}</DataTableCell>
<DataTableCell>
{shortenString(substateIdToString(accountsData.account.address))}
<CopyToClipboard copy={substateIdToString(accountsData.account.address)} />
</DataTableCell>
<DataTableCell>
{shortenString(accountsData.public_key)}
<CopyToClipboard copy={accountsData.public_key} />
</DataTableCell>
</TableRow>
)}
</FetchStatusCheck>
</TableBody>
</Table>
</TableContainer>
Expand All @@ -122,20 +123,21 @@ function AccountDetailsLayout() {
isError={balancesIsError}
errorMessage={balancesError?.message || "Error fetching data"}
isLoading={balancesIsLoading}
/>
<TableContainer>
<Table>
<TableHead>
<TableRow>
<TableCell>Resource</TableCell>
<TableCell>Resource Type</TableCell>
<TableCell>Revealed Balance</TableCell>
<TableCell>Confidential Balance</TableCell>
</TableRow>
</TableHead>
<TableBody>{balancesData?.balances.map((balance: BalanceEntry) => BalanceRow(balance))}</TableBody>
</Table>
</TableContainer>
>
<TableContainer>
<Table>
<TableHead>
<TableRow>
<TableCell>Resource</TableCell>
<TableCell>Resource Type</TableCell>
<TableCell>Revealed Balance</TableCell>
<TableCell>Confidential Balance</TableCell>
</TableRow>
</TableHead>
<TableBody>{balancesData?.balances.map((balance: BalanceEntry) => BalanceRow(balance))}</TableBody>
</Table>
</TableContainer>
</FetchStatusCheck>
</StyledPaper>
</Grid>
<Grid item xs={12} md={12} lg={12}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@ function AccountBalance({ accountName }: { accountName: string }) {
});

return (
<>
<FetchStatusCheck
isError={balancesIsError}
errorMessage={balancesError?.message || "Error fetching data"}
isLoading={false}
/>
<FetchStatusCheck
isError={balancesIsError}
errorMessage={balancesError?.message || "Error fetching data"}
isLoading={false}
>
<Fade in={!balancesIsFetching && !balancesIsError} timeout={100}>
<Box>
<Box>
Expand Down Expand Up @@ -97,7 +96,7 @@ function AccountBalance({ accountName }: { accountName: string }) {
</Box>
</Box>
</Fade>
</>
</FetchStatusCheck>
);
}

Expand Down
Loading

0 comments on commit 6bc77cf

Please sign in to comment.