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 {
|
return {
|
||||||
|
getQuoteState,
|
||||||
createQuote,
|
createQuote,
|
||||||
createWallet,
|
createWallet,
|
||||||
createNutzapInfo,
|
createNutzapInfo,
|
||||||
|
|
|
@ -21,11 +21,12 @@ const messages = defineMessages({
|
||||||
mint_placeholder: { id: 'cashu.wallet.mint_placeholder', defaultMessage: 'https://<mint-url>' },
|
mint_placeholder: { id: 'cashu.wallet.mint_placeholder', defaultMessage: 'https://<mint-url>' },
|
||||||
submit_success: { id: 'generic.saved', defaultMessage: 'Saved!' },
|
submit_success: { id: 'generic.saved', defaultMessage: 'Saved!' },
|
||||||
create_cashu_quote: { id: 'cashu.quote', defaultMessage: 'Create Cashu Quote' },
|
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 Cashu = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const { createWallet, createNutzapInfo, swapCashuToWallet, createQuote } = useCashu();
|
const { createWallet, createNutzapInfo, swapCashuToWallet, createQuote, getQuoteState } = useCashu();
|
||||||
|
|
||||||
const [mints, setMints] = useState<string[]>([]);
|
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 (
|
return (
|
||||||
<Column label={intl.formatMessage(messages.title)}>
|
<Column label={intl.formatMessage(messages.title)}>
|
||||||
<Form onSubmit={handleCreateWalletSubmit}>
|
<Form onSubmit={handleCreateWalletSubmit}>
|
||||||
|
@ -230,6 +252,30 @@ const Cashu = () => {
|
||||||
</FormActions>
|
</FormActions>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Form>
|
</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>
|
</Column>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1163,6 +1163,7 @@
|
||||||
"cashu.nutzap.info": "Your nutzap info",
|
"cashu.nutzap.info": "Your nutzap info",
|
||||||
"cashu.nutzap.swap": "Swap your Cashu",
|
"cashu.nutzap.swap": "Swap your Cashu",
|
||||||
"cashu.quote": "Create Cashu Quote",
|
"cashu.quote": "Create Cashu Quote",
|
||||||
|
"cashu.quote.state": "Get Cashu Quote State",
|
||||||
"cashu.wallet.mints": "Your mints",
|
"cashu.wallet.mints": "Your mints",
|
||||||
"cashu.wallet.mint_placeholder": "https://<mint-url>",
|
"cashu.wallet.mint_placeholder": "https://<mint-url>",
|
||||||
"nostr_extension.found": "<link>Sign in</link> with browser extension.",
|
"nostr_extension.found": "<link>Sign in</link> with browser extension.",
|
||||||
|
|
Ładowanie…
Reference in New Issue