Skip to content

Commit

Permalink
fix dependency issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ljankoschek committed Jun 28, 2024
1 parent 5c49217 commit 0bc8b3a
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 3 deletions.
3 changes: 2 additions & 1 deletion fe1-web/src/features/digital-cash/__tests__/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mockKeyPair, mockLaoId } from '__tests__/utils';
import { mockKeyPair, mockLao, mockLaoId } from '__tests__/utils';
import { Hash, PopToken, RollCallToken } from 'core/objects';
import { COINBASE_HASH, SCRIPT_TYPE } from 'resources/const';

Expand Down Expand Up @@ -26,6 +26,7 @@ export const mockDigitalCashContextValue = (isOrganizer: boolean) => ({
}),
useRollCallTokensByLaoId: () => [mockRollCallToken],
useRollCallTokenByRollCallId: () => mockRollCallToken,
useCurrentLao: () => mockLao,
} as DigitalCashReactContext,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import ModalHeader from 'core/components/ModalHeader';
import { generateUsernameFromBase64 } from 'core/functions/Mnemonic';
import { Hash, RollCallToken } from 'core/objects';
import { List, ModalStyles, Typography } from 'core/styles';
import { getCurrentLao } from 'features/lao/functions';
import { COINBASE_HASH } from 'resources/const';
import STRINGS from 'resources/strings';

Expand All @@ -26,6 +25,8 @@ const TransactionHistory = ({ laoId, rollCallTokens }: IPropTypes) => {
const [selectedTransaction, setSelectedTransaction] = useState<Transaction | null>(null);
const [showModal, setShowModal] = useState<boolean>(false);

const currentLao = DigitalCashHooks.useCurrentLao();

// If we want to show all transactions, just use DigitalCashHooks.useTransactions(laoId)
const transactions: Transaction[] = DigitalCashHooks.useTransactionsByRollCallTokens(
laoId,
Expand Down Expand Up @@ -137,7 +138,7 @@ const TransactionHistory = ({ laoId, rollCallTokens }: IPropTypes) => {
<ListItem.Title
style={[Typography.base, Typography.code]}
numberOfLines={1}>
{input.script.publicKey.valueOf() === getCurrentLao().organizer.valueOf()
{input.script.publicKey.valueOf() === currentLao.organizer.valueOf()
? input.script.publicKey.valueOf() +
STRINGS.digital_cash_wallet_transaction_history_organizer
: generateUsernameFromBase64(input.script.publicKey.valueOf())}
Expand Down
5 changes: 5 additions & 0 deletions fe1-web/src/features/digital-cash/hooks/DigitalCashHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ export namespace DigitalCashHooks {
export const useRollCallsByLaoId = (laoId: Hash) =>
useDigitalCashContext().useRollCallsByLaoId(laoId);

/**
* Gets the current lao , throws an error if there is none
*/
export const useCurrentLao = () => useDigitalCashContext().useCurrentLao();

/**
* Gets the list of all transactions that happened in this LAO
* To use only in a React component
Expand Down
1 change: 1 addition & 0 deletions fe1-web/src/features/digital-cash/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export function compose(
useRollCallById: configuration.useRollCallById,
useCurrentLaoId: configuration.useCurrentLaoId,
useConnectedToLao: configuration.useConnectedToLao,
useCurrentLao: configuration.useCurrentLao,
useIsLaoOrganizer: configuration.useIsLaoOrganizer,
useRollCallTokensByLaoId: configuration.useRollCallTokensByLaoId,
useRollCallTokenByRollCallId: configuration.useRollCallTokenByRollCallId,
Expand Down
7 changes: 7 additions & 0 deletions fe1-web/src/features/digital-cash/interface/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ export interface DigitalCashCompositionConfiguration {
* @returns the RollCallToken or undefined if not found in the roll call
*/
useRollCallTokenByRollCallId: (laoId: Hash, rollCallId?: Hash) => RollCallToken | undefined;

/**
* Gets the current lao
* @returns The current lao
*/
useCurrentLao: () => DigitalCashFeature.Lao;
}

/**
Expand All @@ -102,6 +108,7 @@ export type DigitalCashReactContext = Pick<
| 'useCurrentLaoId'
| 'useIsLaoOrganizer'
| 'useConnectedToLao'
| 'useCurrentLao'

/* roll call */
| 'useRollCallById'
Expand Down
1 change: 1 addition & 0 deletions fe1-web/src/features/digital-cash/interface/Feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Hash, PopToken, PublicKey } from 'core/objects';
export namespace DigitalCashFeature {
export interface Lao {
id: Hash;
organizer: PublicKey;
}

export interface LaoScreen extends NavigationDrawerScreen {
Expand Down
1 change: 1 addition & 0 deletions fe1-web/src/features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export function configureFeatures() {
useConnectedToLao: laoConfiguration.hooks.useConnectedToLao,
useIsLaoOrganizer: laoConfiguration.hooks.useIsLaoOrganizer,
getLaoOrganizer: laoConfiguration.functions.getLaoOrganizer,
useCurrentLao: laoConfiguration.hooks.useCurrentLao,
useRollCallById: rollCallConfiguration.hooks.useRollCallById,
useRollCallsByLaoId: rollCallConfiguration.hooks.useRollCallsByLaoId,
useRollCallTokensByLaoId: rollCallConfiguration.hooks.useRollCallTokensByLaoId,
Expand Down

0 comments on commit 0bc8b3a

Please sign in to comment.