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

Feat UI/unconfirmed transactions #31

Open
wants to merge 70 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
843b957
ui: basic transaction layout/style
AnthonyMarin Sep 2, 2024
8e0f310
ui: basic ui/style (unconf tx)
AnthonyMarin Sep 2, 2024
abcd7fd
refac: reorganize struc
AnthonyMarin Sep 2, 2024
11f94ad
ui: basic button/modal setup
AnthonyMarin Sep 2, 2024
56b1cc5
integrate modal
AnthonyMarin Sep 2, 2024
7dfe12a
update styling
AnthonyMarin Sep 2, 2024
0ec6138
Merge branch 'main' into feat-ui/unconfirmed-transactions
AnthonyMarin Sep 2, 2024
84a2aab
fix: window can now be closed
AnthonyMarin Sep 2, 2024
da27478
basic layout for replace tx panel
AnthonyMarin Sep 2, 2024
864919e
refac: move result screen files to own folder
AnthonyMarin Sep 2, 2024
21feb99
refac: tiered fees component
AnthonyMarin Sep 2, 2024
99a99c6
refactor: interactive styling
AnthonyMarin Sep 3, 2024
969147f
fix: styling
AnthonyMarin Sep 3, 2024
2f01e31
added placeholder functions
AnthonyMarin Sep 3, 2024
8592508
Adding replacement transactions
Maphikza Sep 3, 2024
1d0de00
Merge pull request #24 from Maphikza/feat-ui/unconfirmed-transactions
AnthonyMarin Sep 3, 2024
da7d945
add scroll to panel content
AnthonyMarin Sep 3, 2024
1e6f9b9
fix text alignment
AnthonyMarin Sep 3, 2024
c11e207
made usable on mobile
AnthonyMarin Sep 3, 2024
783587a
adding the ability to dynamically show what the transaction fee is go…
Maphikza Sep 4, 2024
18e95af
adding balance checking to transactions before processing them
Maphikza Sep 4, 2024
4d6db3c
Adding balance checking to replacement transactions so that we can pr…
Maphikza Sep 4, 2024
3271257
Removing redundant code from replace transactions code file
Maphikza Sep 4, 2024
08ef8ae
changing to use https for transaction size calculation
Maphikza Sep 4, 2024
69a1228
Merge pull request #25 from Maphikza/feat-ui/unconfirmed-transactions
AnthonyMarin Sep 6, 2024
108ca5c
fix address overflow
AnthonyMarin Sep 9, 2024
09e09b9
fix mobile replace button
AnthonyMarin Sep 9, 2024
b8d12bd
Working transaction broadcasting
Maphikza Sep 9, 2024
3958e7a
Fixing signing window loading at login page.
Maphikza Sep 9, 2024
aae0f2f
Adding jwt to manage session length for transaction context
Maphikza Sep 9, 2024
00c3971
Adding jwt hook code and removing redundant code
Maphikza Sep 9, 2024
a0b2f71
Login process working with new wallet
Maphikza Sep 10, 2024
e958833
Adding token auth for relay endpoints, updating doLogout to logout of…
Maphikza Sep 11, 2024
b668afb
Fixing endpoint bugs as a result of jwt.
Maphikza Sep 11, 2024
938db2e
Handling null on kind trend data hook.
Maphikza Sep 11, 2024
f029722
Demo mode is going to be problematic so I have switched it to off.
Maphikza Sep 11, 2024
fc6a7b3
Adding Auth hook
Maphikza Sep 11, 2024
106c2c2
Adding token to settings hook
Maphikza Sep 12, 2024
f7da691
Adding reroute to login to doLogout
Maphikza Sep 12, 2024
b73d177
Updating transaction display and transactions chart.
Maphikza Sep 13, 2024
9756c43
Merge branch 'pr/26' into feat-ui/unconfirmed-transactions
AnthonyMarin Sep 15, 2024
0a96662
added copy transaction button
AnthonyMarin Sep 15, 2024
3200c14
added message component
AnthonyMarin Sep 15, 2024
599c55a
fix: change total cost to state
AnthonyMarin Sep 16, 2024
ffa0c3a
FIX: activity infinitley reloading
AnthonyMarin Sep 16, 2024
0f91542
fix: stop fee recommendation from being fetched every fee tier change
AnthonyMarin Sep 16, 2024
a0fc7bc
refac: replace transactions
AnthonyMarin Sep 16, 2024
9a1ca0e
style fixes
AnthonyMarin Sep 16, 2024
526c11b
added checkbox for enabling rbf
AnthonyMarin Sep 16, 2024
76e0f8a
added enable rbf to request
AnthonyMarin Sep 16, 2024
c7f7408
fixed copied message
AnthonyMarin Sep 18, 2024
8c67b91
fix style: tx row items
AnthonyMarin Sep 18, 2024
a2959e9
refac: copy to clipboard
AnthonyMarin Sep 18, 2024
559282f
fix: header
AnthonyMarin Sep 18, 2024
2bc3d48
various fixes
AnthonyMarin Sep 18, 2024
941194a
made tiered fees a row on tablet
AnthonyMarin Sep 19, 2024
7b092a2
added address checking
AnthonyMarin Sep 19, 2024
40da2cc
restoring updated calc checking
AnthonyMarin Sep 19, 2024
109f67b
fixed calculation spam
AnthonyMarin Sep 19, 2024
0cf9867
clean up
AnthonyMarin Sep 19, 2024
50a3bde
style: standardize fee tiers
AnthonyMarin Sep 19, 2024
5f32e60
Updating relay settings type and supporting code for file storage
Maphikza Oct 12, 2024
cf154d4
Updating tiered fees to dynamically adjust recommended fee rates for …
Maphikza Oct 15, 2024
b0103af
Updating configs so that we can use config to get wallet base url fro…
Maphikza Oct 15, 2024
024a9a3
Merge pull request #30 from Maphikza/feat-ui/unconfirmed-transactions
Maphikza Oct 15, 2024
bf7e8d8
Enabling App buckets as the infrastructure is already set.
Maphikza Oct 16, 2024
6be3f5d
Merge pull request #32 from Maphikza/feat-ui/unconfirmed-transactions
Maphikza Oct 16, 2024
2cd17e0
Merge branch 'main' into feat-ui/unconfirmed-transactions
AnthonyMarin Oct 28, 2024
4bed218
Merge branch 'main' into feat-ui/unconfirmed-transactions
AnthonyMarin Nov 23, 2024
d0a1d87
fix remaining issues from squashing
AnthonyMarin Nov 23, 2024
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
6 changes: 3 additions & 3 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
REACT_APP_BASE_URL=http://localhost:9002
# REACT_APP_BASE_URL=https://11561ba2d27f.ngrok.app
REACT_APP_WALLET_BASE_URL=http://localhost:9003 # New wallet base URL
REACT_APP_ASSETS_BUCKET=http://localhost
REACT_APP_DEMO_MODE=true
REACT_APP_DEMO_MODE=false

# more info https://create-react-app.dev/docs/advanced-configuration
# More info https://create-react-app.dev/docs/advanced-configuration
ESLINT_NO_DEV_ERRORS=true
TSC_COMPILE_ON_ERROR=true
67 changes: 41 additions & 26 deletions src/api/activity.api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { ActivityStatusType } from '@app/interfaces/interfaces';
import { readToken } from '@app/services/localStorage.service';
import config from '@app/config/config';
import { message } from 'antd';

export interface WalletTransaction {
id: number;
Expand All @@ -11,33 +13,46 @@ export interface WalletTransaction {
value: string;
}

export const getUserActivities = (): Promise<WalletTransaction[]> => {
return fetch(`${config.baseURL}/transactions/latest`)
.then((response) => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then((data) => {
if (Array.isArray(data) && data.length === 0) {
// Handle the case where the response is an empty array
return [];
}
// Assuming your backend response matches the WalletTransaction interface
// eslint-disable-next-line
return data.map((item: any) => ({
id: item.ID,
witness_tx_id: item.WitnessTxId,
date: new Date(item.Date).getTime(),
output: item.Output,
value: item.Value,
}));
})
.catch((error) => {
console.error('Error fetching user activities:', error);
export const getUserActivities = (handleLogout: () => void): Promise<WalletTransaction[]> => {
const token = readToken(); // Read the JWT token from local storage

if (!token) {
handleLogout(); // Call handleLogout if no token
return Promise.reject('No token found');
}

return fetch(`${config.baseURL}/api/transactions/latest`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
},
})
.then((response) => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then((data) => {
if (Array.isArray(data) && data.length === 0) {
// Handle the case where the response is an empty array
return [];
});
}
// Assuming your backend response matches the WalletTransaction interface
// eslint-disable-next-line
return data.map((item: any) => ({
id: item.ID,
witness_tx_id: item.WitnessTxId,
date: new Date(item.Date).getTime(),
output: item.Output,
value: item.Value,
}));
})
.catch((error) => {
console.error('Error fetching user activities:', error);
return [];
});
};

export interface Activity {
Expand Down
2 changes: 1 addition & 1 deletion src/api/earnings.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const getTotalEarning = (id: number, currency: CurrencyTypeEnum): Promise

export const getBitcoinRatesForLast30Days = (): Promise<Earning[]> => {
console.log('Fetching bitcoin rate data.');
return fetch('http://localhost:5000/bitcoin-rates/last-30-days')
return fetch('http://localhost:5000/api/bitcoin-rates/last-30-days')
.then((response) => response.json())
.then((data) => {
console.log('Received data:', data); // Add log statement to see the data
Expand Down
33 changes: 20 additions & 13 deletions src/components/auth/LoginForm/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export const LoginForm: React.FC = () => {
const dispatch = useDispatch();

const [form] = Form.useForm();
const [event, setEvent] = useState<any>(null);

useEffect(() => {
const fetchPublicKey = async () => {
Expand All @@ -60,37 +59,44 @@ export const LoginForm: React.FC = () => {
console.error('Failed to get public key:', error);
}
};

fetchPublicKey();

const isFirstLoad = localStorage.getItem('isFirstLoad');
if (!isFirstLoad) {
window.location.reload();
localStorage.setItem('isFirstLoad', 'true');
}

const intervalId = setInterval(() => {
if (window.nostr) {
fetchPublicKey();
clearInterval(intervalId);
}
}, 1000); // Retry every 1 second

return () => clearInterval(intervalId); // Clear the interval on component unmount
}, [form]);


const [event, setEvent] = useState<any>(null);

const handleSubmit = async (values: LoginFormData) => {
try {
if (!window.nostr) {
notificationController.error({ message: 'Nostr extension is not available' });
return;
}

const { success, event } = await login(values);
if (success && event) {
setEvent(event);
// Automatically proceed to verification
const signedEvent = await window.nostr.signEvent(event);
console.log('Signed event:', signedEvent);

const response = await verifyChallenge({
challenge: signedEvent.content,
signature: signedEvent.sig,
messageHash: signedEvent.id,
event: signedEvent,
});

if (response.success) {
if (response.token && response.user) {
persistToken(response.token);
dispatch(setUser(response.user));
// Set the token in the API instance
notificationController.success({
message: 'Login successful',
description: 'You have successfully logged in!',
Expand All @@ -105,6 +111,7 @@ export const LoginForm: React.FC = () => {
notificationController.error({ message: error.message });
}
};


return (
<Auth.FormWrapper>
Expand Down
24 changes: 24 additions & 0 deletions src/components/common/CopyToClipboard/CopyToClipboard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, { useState } from 'react';
import { CopyOutlined } from '@ant-design/icons';
import CopyToClipboard from 'react-copy-to-clipboard';
import { Button, message } from 'antd';
interface CopyToClipboardProps {
textToCopy: string;
}

const ClipboardCopy: React.FC<CopyToClipboardProps> = ({ textToCopy }) => {
const copied = () => {
message.success('Copied to clipboard');
};
const onCopy = () => {
//display Copied to clipboard
copied();
};
return (
<CopyToClipboard text={textToCopy}>
<Button onClick={onCopy} icon={<CopyOutlined />} size="small" />
</CopyToClipboard>
);
};

export default ClipboardCopy;
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const Header = styled(BaseLayout.Header)<Header>`
line-height: 1.5;
z-index: 105;

@media only screen and ${media.xs} {
@media only screen and ${media.xxs} {
${(props) =>
props.$isSiderOpened &&
css`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,6 @@ export const TextRow = styled.div`
gap: 1rem;
`;

export const SubCard = styled(BaseCard)<{ $isMobile?: boolean }>`
width: 30%;
${(props) =>
props.$isMobile &&
css`
width: 100%;
`}
background-color: var(--additional-background-color);
cursor: pointer;
box-shadow: 0px 0px 10px 0px var(--shadow-color);
.ant-card-body {
padding: 1rem 2rem;
}
`;
export const SendBody = styled(BaseRow)`
padding-bottom: 1rem;
`;
Expand All @@ -45,28 +31,16 @@ export const FormHeader = styled.span`
padding-bottom: 1rem;
`;

export const SubCardHeader = styled.span`
font-size: 1.5rem;
`;

export const InputHeader = styled.span`
font-size: 1.5rem;
`;

export const SubCardAmount = styled.span`
font-size: 1.5rem;
`;
export const SubCardContent = styled.div`
font-size: 1.3rem;
height: 100%;
export const RBFWrapper = styled.div`
display: flex;
justify-content: space-around;
flex-direction: column;
flex-direction: row;
gap: 1rem;
align-items: center;
text-align: center;
gap: 3rem;
padding-top: 1rem;
padding-bottom: 1rem;
justify-content: center;
`;

export const InputWrapper = styled.div`
Expand All @@ -75,38 +49,21 @@ export const InputWrapper = styled.div`
flex-direction: column;
gap: 0.5rem;
`;
export const TiersRow = styled.div`

export const InputHeaderWrapper = styled.div`
display: flex;
flex-direction: row;
gap: 1rem;
justify-content: space-around;
`;

export const TiersCol = styled.div`
export const TiersContainer = styled.div`
display: flex;
flex-direction: column;
gap: 1rem;
justify-content: space-around;
`;
export const SendFormButton = styled(BaseButton)`
width: 100%;
`;
export const TiersContainer = styled.div`
display: flex;
flex-direction: column;
gap: 1rem;
transition: all 0.5s ease;
padding: 1rem;
.tier-hover:hover {
background-color: var(--primary-color);
}
.selected {
border: 1px solid var(--primary-color);
}
.invalidAmount {
border: 1px solid var(--error-color);
}
`;

export const BalanceInfo = styled.small`
color: var(--subtext-color);
`;
Expand All @@ -118,26 +75,24 @@ export const Recipient = styled.span`
export const ErrorText = styled.small`
color: var(--error-color);
display: flex;
op
flex-direction: row;
align-items: center;
`;
export const AddressText = styled.span`
text-decoration: underline;
color: var(--text-main-color);
`;

export const RateValueWrapper = styled.div`
export const TiersRow = styled.div`
display: flex;
flex-direction: column;
flex-direction: row;
gap: 1rem;
justify-content: space-around;
`;
export const RateValue = styled.span`
color: green;
`;
export const RBFWrapper = styled.div`

export const TiersCol = styled.div`
display: flex;
flex-direction: row;
flex-direction: column;
gap: 1rem;
align-items: center;
justify-content: center;
justify-content: space-around;
`;
Loading
Loading