Skip to content

Commit

Permalink
Merge pull request #29 from Kodylow/impl-leave-federation
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodylow authored Jan 23, 2024
2 parents bc9b44e + f13fcf9 commit 1ece0f2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/client/pages/fedimints.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Federation } from '../src/api/types';
import { CellContext } from '@tanstack/react-table';
import { toast } from 'react-toastify';
import { Price } from '../src/components/price/Price';
import { gatewayApi } from '../src/api/GatewayApi';

const FedimintsView = () => {
const federations = useGatewayFederations();
Expand Down Expand Up @@ -76,7 +77,12 @@ const FedimintsView = () => {
if (props.row.original.balance_msat > 0) {
toast.error("Can't leave a federation you've got sats in!");
} else {
toast.warn('Not implemented yet!');
try {
gatewayApi.leaveFederation(props.row.original.federation_id);
toast.success('Left Federation');
} catch (e: any) {
toast.error(e.message);
}
}
}}
>
Expand Down
14 changes: 14 additions & 0 deletions src/client/src/api/GatewayApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ class GatewayApi {
}
};

leaveFederation = async (federationId: string): Promise<void> => {
try {
const res: Response = await this.post('leave-fed', {
federation_id: federationId,
});

if (!res.ok) {
throw responseToError(res);
}
} catch (error) {
return Promise.reject({ message: 'Error leaving federation', error });
}
};

requestWithdrawal = async (
federationId: string,
amountSat: number | 'all',
Expand Down

0 comments on commit 1ece0f2

Please sign in to comment.