kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
experiment: check mint quote state
rodzic
7048ba5caa
commit
ecde1b9ebc
|
@ -34,7 +34,15 @@ function useCashu() {
|
|||
},
|
||||
});
|
||||
|
||||
const { mutate: getQuoteState } = useMutation({
|
||||
mutationFn: (quote_id: string) => api.get(`/api/v1/ditto/cashu/quote/${quote_id}`),
|
||||
onSuccess: () => {
|
||||
queryClient.refetchQueries({ queryKey: ['cashu', 'nutzap', 'info'] });
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
getQuoteState,
|
||||
createQuote,
|
||||
createWallet,
|
||||
createNutzapInfo,
|
||||
|
|
|
@ -21,11 +21,12 @@ const messages = defineMessages({
|
|||
mint_placeholder: { id: 'cashu.wallet.mint_placeholder', defaultMessage: 'https://<mint-url>' },
|
||||
submit_success: { id: 'generic.saved', defaultMessage: 'Saved!' },
|
||||
create_cashu_quote: { id: 'cashu.quote', defaultMessage: 'Create Cashu Quote' },
|
||||
get_cashu_quote_state: { id: 'cashu.quote.state', defaultMessage: 'Create Cashu Quote' },
|
||||
});
|
||||
|
||||
const Cashu = () => {
|
||||
const intl = useIntl();
|
||||
const { createWallet, createNutzapInfo, swapCashuToWallet, createQuote } = useCashu();
|
||||
const { createWallet, createNutzapInfo, swapCashuToWallet, createQuote, getQuoteState } = useCashu();
|
||||
|
||||
const [mints, setMints] = useState<string[]>([]);
|
||||
|
||||
|
@ -135,6 +136,27 @@ const Cashu = () => {
|
|||
});
|
||||
};
|
||||
|
||||
const handleGetMintQuoteState: React.FormEventHandler = async (event) => {
|
||||
event.preventDefault();
|
||||
getQuoteState(mints[0], {
|
||||
onSuccess: async () => {
|
||||
toast.success(messages.submit_success);
|
||||
},
|
||||
onError: async (err) => {
|
||||
if (err instanceof HTTPError) {
|
||||
try {
|
||||
const { error } = await err.response.json();
|
||||
if (typeof error === 'string') {
|
||||
toast.error(error);
|
||||
return;
|
||||
}
|
||||
} catch { /* empty */ }
|
||||
}
|
||||
toast.error(err.message);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Column label={intl.formatMessage(messages.title)}>
|
||||
<Form onSubmit={handleCreateWalletSubmit}>
|
||||
|
@ -230,6 +252,30 @@ const Cashu = () => {
|
|||
</FormActions>
|
||||
</Stack>
|
||||
</Form>
|
||||
|
||||
<Form onSubmit={handleGetMintQuoteState}>
|
||||
<Stack space={4}>
|
||||
|
||||
<Streamfield
|
||||
label={intl.formatMessage(messages.get_cashu_quote_state)}
|
||||
component={CashuInput}
|
||||
values={mints}
|
||||
onChange={handleStreamItemChange()}
|
||||
onAddItem={handleAddMint}
|
||||
onRemoveItem={deleteStreamItem()}
|
||||
/>
|
||||
|
||||
<FormActions>
|
||||
<Button to='/settings' theme='tertiary'>
|
||||
<FormattedMessage id='common.cancel' defaultMessage='Cancel' />
|
||||
</Button>
|
||||
|
||||
<Button theme='primary' type='submit'>
|
||||
<FormattedMessage id='edit_profile.save' defaultMessage='Save' />
|
||||
</Button>
|
||||
</FormActions>
|
||||
</Stack>
|
||||
</Form>
|
||||
</Column>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1163,6 +1163,7 @@
|
|||
"cashu.nutzap.info": "Your nutzap info",
|
||||
"cashu.nutzap.swap": "Swap your Cashu",
|
||||
"cashu.quote": "Create Cashu Quote",
|
||||
"cashu.quote.state": "Get Cashu Quote State",
|
||||
"cashu.wallet.mints": "Your mints",
|
||||
"cashu.wallet.mint_placeholder": "https://<mint-url>",
|
||||
"nostr_extension.found": "<link>Sign in</link> with browser extension.",
|
||||
|
|
Ładowanie…
Reference in New Issue