Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Dec 18, 2024
1 parent 710c698 commit 8a43b0c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/app/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ const debug = {
bypassInscriptionChecks() {
store.dispatch(settingsSlice.actions.dangerouslyChosenToBypassAllInscriptionChecks());
},
resetInscriptionState() {
store.dispatch(settingsSlice.actions.resetInscriptionState());
},
};

export function setDebugOnGlobal() {
Expand Down
15 changes: 10 additions & 5 deletions src/app/features/collectibles/components/bitcoin/inscription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ function openInscriptionUrl(num: number) {
export function Inscription({ inscription }: InscriptionProps) {
const navigate = useNavigate();
const location = useLocation();
const { hasBeenDiscarded, discardInscription, recoverInscription } = useDiscardedInscriptions();
const { hasBeenDiscarded, discardInscription, recoverInscription, discardedInscriptions } =

Check failure on line 33 in src/app/features/collectibles/components/bitcoin/inscription.tsx

View workflow job for this annotation

GitHub Actions / typecheck

'discardedInscriptions' is declared but its value is never read.
useDiscardedInscriptions();

// console.log(inscription);
// console.log(discardedInscriptions);

const openSendInscriptionModal = useCallback(() => {
navigate(RouteUrls.SendOrdinalInscription, {
Expand Down Expand Up @@ -114,15 +118,16 @@ export function Inscription({ inscription }: InscriptionProps) {
<Box position="relative">
{content}
<HighSatValueUtxoWarning inscription={inscription} />
IsDiscarded: {String(hasBeenDiscarded(inscription.id))}
IsDiscarded: {String(hasBeenDiscarded(inscription.txid, inscription.output))}
<br />
value: {inscription.value}
<br />
<button
onClick={() => {
hasBeenDiscarded(inscription.id)
? recoverInscription(inscription.id)
: discardInscription(inscription.id);
// change api to use txid and output obj
hasBeenDiscarded(inscription.txid, inscription.output)
? recoverInscription(inscription.txid, inscription.output)
: discardInscription(inscription.txid, inscription.output);
}}
>
toggle safe to spend
Expand Down
11 changes: 10 additions & 1 deletion src/app/pages/home/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ import { whenPageMode } from '@app/common/utils';
import { ActivityList } from '@app/features/activity-list/activity-list';
import { FeedbackButton } from '@app/features/feedback-button/feedback-button';
import { Assets } from '@app/pages/home/components/assets';
import { useCurrentNativeSegwitUtxos } from '@app/query/bitcoin/address/utxos-by-address.hooks';
import { homePageModalRoutes } from '@app/routes/app-routes';
import { ModalBackgroundWrapper } from '@app/routes/components/modal-background-wrapper';
import { useCurrentAccountIndex } from '@app/store/accounts/account';
import { useCurrentAccountNativeSegwitAddressIndexZero } from '@app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks';
import { useCurrentStacksAccount } from '@app/store/accounts/blockchain/stacks/stacks-account.hooks';
import { useTogglePrivateMode } from '@app/store/settings/settings.actions';
import { useIsPrivateMode } from '@app/store/settings/settings.selectors';
import { useDiscardedInscriptions, useIsPrivateMode } from '@app/store/settings/settings.selectors';
import { AccountCard } from '@app/ui/components/account/account.card';

import { AccountActions } from './components/account-actions';
Expand All @@ -41,6 +42,14 @@ export function Home() {
address: account?.address || '',
index: currentAccountIndex || 0,
});
const { hasBeenDiscarded, discardInscription, recoverInscription, discardedInscriptions } =

Check failure on line 45 in src/app/pages/home/home.tsx

View workflow job for this annotation

GitHub Actions / typecheck

'hasBeenDiscarded' is declared but its value is never read.

Check failure on line 45 in src/app/pages/home/home.tsx

View workflow job for this annotation

GitHub Actions / typecheck

'discardInscription' is declared but its value is never read.

Check failure on line 45 in src/app/pages/home/home.tsx

View workflow job for this annotation

GitHub Actions / typecheck

'recoverInscription' is declared but its value is never read.
useDiscardedInscriptions();

console.log(discardedInscriptions);

Check failure on line 48 in src/app/pages/home/home.tsx

View workflow job for this annotation

GitHub Actions / lint-eslint

Unexpected console statement

const { data: utxos } = useCurrentNativeSegwitUtxos();

console.log(utxos);

Check failure on line 52 in src/app/pages/home/home.tsx

View workflow job for this annotation

GitHub Actions / lint-eslint

Unexpected console statement

const btcAddress = useCurrentAccountNativeSegwitAddressIndexZero();
const { totalUsdBalance, isPending, isLoadingAdditionalData } = useTotalBalance({
Expand Down
15 changes: 9 additions & 6 deletions src/app/store/settings/settings.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useDispatch, useSelector } from 'react-redux';

import { createSelector } from '@reduxjs/toolkit';

import { useCurrentNativeSegwitUtxos } from '@app/query/bitcoin/address/utxos-by-address.hooks';

Check failure on line 6 in src/app/store/settings/settings.selectors.ts

View workflow job for this annotation

GitHub Actions / typecheck

'useCurrentNativeSegwitUtxos' is declared but its value is never read.
import { RootState } from '@app/store';

import { settingsSlice } from './settings.slice';
Expand Down Expand Up @@ -51,14 +52,16 @@ export function useDiscardedInscriptions() {
return useMemo(
() => ({
discardedInscriptions,
hasBeenDiscarded(inscriptionId: string) {
return discardedInscriptions.includes(inscriptionId);
hasBeenDiscarded(txid: string, vout: string) {
return discardedInscriptions.includes([txid, vout].join(':'));
},
discardInscription(inscriptionId: string) {
dispatch(settingsSlice.actions.discardInscription(inscriptionId));
discardInscription(txid: string, vout: string) {
console.log('discarding inscription', [txid, vout].join(':'));

Check failure on line 59 in src/app/store/settings/settings.selectors.ts

View workflow job for this annotation

GitHub Actions / lint-eslint

Unexpected console statement
dispatch(settingsSlice.actions.discardInscription([txid, vout].join(':')));
},
recoverInscription(inscriptionId: string) {
dispatch(settingsSlice.actions.recoverInscription(inscriptionId));
recoverInscription(txid: string, vout: string) {
console.log('recovering inscription', [txid, vout].join(':'));

Check failure on line 63 in src/app/store/settings/settings.selectors.ts

View workflow job for this annotation

GitHub Actions / lint-eslint

Unexpected console statement
dispatch(settingsSlice.actions.recoverInscription([txid, vout].join(':')));
},
}),
[discardedInscriptions, dispatch]
Expand Down
4 changes: 4 additions & 0 deletions src/app/store/settings/settings.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ export const settingsSlice = createSlice({
state.discardedInscriptions.push(action.payload);
},
recoverInscription(state, action: PayloadAction<string>) {
console.log('recovering inscription', action.payload);

Check failure on line 44 in src/app/store/settings/settings.slice.ts

View workflow job for this annotation

GitHub Actions / lint-eslint

Unexpected console statement
state.discardedInscriptions = state.discardedInscriptions.filter(
inscriptionId => inscriptionId !== action.payload
);
},
resetInscriptionState(state) {
state.discardedInscriptions = [];
},
},
});

0 comments on commit 8a43b0c

Please sign in to comment.