fix(governance): fix time delay notice for withdrawal of 0.00 assets (#3740)

Co-authored-by: Bartłomiej Głownia <bglownia@gmail.com>
This commit is contained in:
Sam Keen 2023-05-12 14:04:53 +01:00 committed by GitHub
parent fae61c28ca
commit 2c7934a8c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 11 deletions

View File

@ -44,7 +44,7 @@ export class CollateralBridge {
is_asset_listed(address: string) { is_asset_listed(address: string) {
return this.contract.is_asset_listed(address); return this.contract.is_asset_listed(address);
} }
get_withdraw_threshold(assetSource: string) { get_withdraw_threshold(assetSource: string): Promise<BigNumber> {
return this.contract.get_withdraw_threshold(assetSource); return this.contract.get_withdraw_threshold(assetSource);
} }
default_withdraw_delay() { default_withdraw_delay() {

View File

@ -70,13 +70,14 @@ const WithdrawDelayNotification = ({
return ( return (
<Notification <Notification
intent={Intent.Warning} intent={Intent.Warning}
key={symbol}
testId={ testId={
threshold.isFinite() threshold.isEqualTo(0)
? 'amount-withdrawal-delay-notification' ? 'withdrawals-delay-notification'
: 'withdrawals-delay-notification' : 'amount-withdrawal-delay-notification'
} }
message={[ message={[
!threshold.isFinite() threshold.isEqualTo(0)
? t('All %s withdrawals are subject to a %s delay.', replacements) ? t('All %s withdrawals are subject to a %s delay.', replacements)
: t('Withdrawals of %s %s or more will be delayed for %s.', [ : t('Withdrawals of %s %s or more will be delayed for %s.', [
formatNumber(threshold, decimals), formatNumber(threshold, decimals),
@ -166,10 +167,7 @@ export const WithdrawForm = ({
}; };
const showWithdrawDelayNotification = const showWithdrawDelayNotification =
delay && delay && selectedAsset && new BigNumber(amount).isGreaterThan(threshold);
selectedAsset &&
(!threshold.isFinite() ||
new BigNumber(amount).isGreaterThanOrEqualTo(threshold));
return ( return (
<> <>

View File

@ -120,7 +120,7 @@ describe('WithdrawManager', () => {
it('shows withdraw delay notification if amount greater than threshold', async () => { it('shows withdraw delay notification if amount greater than threshold', async () => {
render(generateJsx(props)); render(generateJsx(props));
fireEvent.change(screen.getByLabelText('Amount'), { fireEvent.change(screen.getByLabelText('Amount'), {
target: { value: '1000' }, target: { value: '1001' },
}); });
expect( expect(
await screen.findByTestId('amount-withdrawal-delay-notification') await screen.findByTestId('amount-withdrawal-delay-notification')
@ -128,7 +128,7 @@ describe('WithdrawManager', () => {
}); });
it('shows withdraw delay notification if threshold is 0', async () => { it('shows withdraw delay notification if threshold is 0', async () => {
withdrawAsset.threshold = new BigNumber(Infinity); withdrawAsset.threshold = new BigNumber(0);
render(generateJsx(props)); render(generateJsx(props));
fireEvent.change(screen.getByLabelText('Amount'), { fireEvent.change(screen.getByLabelText('Amount'), {
target: { value: '0.01' }, target: { value: '0.01' },