Skip to content

Commit

Permalink
feat: get registered nano contract from redux root state
Browse files Browse the repository at this point in the history
  • Loading branch information
alexruzenhack committed Mar 5, 2024
1 parent 29ecc10 commit f090d9e
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/components/NanoContract/NanoContractsList.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,25 @@ import HathorHeader from "../HathorHeader";
import { NoNanoContracts } from './NoNanoContracts.component';
import { RegisterNanoContract } from './RegisterNewNanoContractButton.component';
import { NanoContractsListItem } from './NanoContractsListItem.component';
import { useSelector } from 'react-redux';

const fixtureNanoContractData = [
{
address: 'HTeZeYTCv7cZ8u7pBGHkWsPwhZAuoq5j3V',
ncId: '00c30fc8a1b9a326a766ab0351faf3635297d316fd039a0eda01734d9de40185',
blueprintId: '0025dadebe337a79006f181c05e4799ce98639aedfbd26335806790bdea4b1d4',
blueprintName: 'Swap',
},
];

const fixtureEmptyList = [];
/**
* @param {Object} state Redux root state
* @returns {Object} Array of registered Nano Contract with basic information
*/
const getRegisteredNanoContracts = (state) => {
const registeredContracts = state.nanoContract.registeredContracts;
return Object.values(registeredContracts);
}

export const NanoContractsList = ({}) => {
const registeredNanoContracts = useSelector(getRegisteredNanoContracts);
const navigation = useNavigation();

const navigatesToNanoContractTransactions = () => {
navigation.navigate('NanoContractTransactions');
};
const isEmpty = () => fixtureNanoContractData.length === 0;
const isEmpty = () => registeredNanoContracts.length === 0;

return (
<Wrapper>
Expand All @@ -37,7 +38,7 @@ export const NanoContractsList = ({}) => {
{/* FlatList doesn't render when data is empty.
* That's why we don't need a conditional rendering here. */}
<FlatList
data={fixtureNanoContractData}
data={registeredNanoContracts}
renderItem={({item, index}) => (
<NanoContractsListItem
item={item}
Expand Down

0 comments on commit f090d9e

Please sign in to comment.