vega-frontend-monorepo/apps/trading/client-pages/portfolio/withdrawals-container.tsx

52 lines
1.7 KiB
TypeScript
Raw Normal View History

import { AsyncRenderer, Button } from '@vegaprotocol/ui-toolkit';
feat (#896): large withdraws (#1180) * feat: add deposits table to deposits tab on portfolio page * feat: refactor use-withdraw hook to not invoke eth tx * feat: rename hook for clarity * feat: fix withdrawal creation test * feat: update withdraw-manager and withrawals-table tests * chore: fix lint * feat: remove web3 input to avoid double dialog * chore: use renderHook from testing-library/react * chore: update to use non deprecated fields * chore: remove usage of all bridge contract * feat: correctly merge cache update in withdrawals table * feat: changes to support token app withdrawals * chore: add height to ag grid table wrapping element * feat: add txhash col to withdraw table * feat: provide better ui if withdrawal is not ready to be completed * feat: use separate dialogs for txs * feat: allow user to immediately complete withdrawal if delay not triggered * feat: add withdraw store to tidy up state management * chore: fix tests * chore: convert callback to promises, fix tests, delete withdraw page * chore: fix lint errors * fix: withdrawals link in nav * feat: style changes after design update * fix: proposal form test * chore: tidy error ui logic * feat: review comments * chore: lint * feat: add better typing for tables * chore: put withdrawals tab at the end * chore: update i18n * fix: dialog in positions manager due to rename * chore: increase spacing in withdrawal form * chore: update tests * chore: lint * chore: use new assetsConnection and update cy test * fix: incorrect shape of withdrawal generate function * feat: delete withdrawals page now that its shown on the portfolio page * chore: update tests to check for withdrawals page * chore: fix tests again * fix: page title test
2022-09-06 01:30:13 +00:00
import {
withdrawalProvider,
useWithdrawalDialog,
feat (#896): large withdraws (#1180) * feat: add deposits table to deposits tab on portfolio page * feat: refactor use-withdraw hook to not invoke eth tx * feat: rename hook for clarity * feat: fix withdrawal creation test * feat: update withdraw-manager and withrawals-table tests * chore: fix lint * feat: remove web3 input to avoid double dialog * chore: use renderHook from testing-library/react * chore: update to use non deprecated fields * chore: remove usage of all bridge contract * feat: correctly merge cache update in withdrawals table * feat: changes to support token app withdrawals * chore: add height to ag grid table wrapping element * feat: add txhash col to withdraw table * feat: provide better ui if withdrawal is not ready to be completed * feat: use separate dialogs for txs * feat: allow user to immediately complete withdrawal if delay not triggered * feat: add withdraw store to tidy up state management * chore: fix tests * chore: convert callback to promises, fix tests, delete withdraw page * chore: fix lint errors * fix: withdrawals link in nav * feat: style changes after design update * fix: proposal form test * chore: tidy error ui logic * feat: review comments * chore: lint * feat: add better typing for tables * chore: put withdrawals tab at the end * chore: update i18n * fix: dialog in positions manager due to rename * chore: increase spacing in withdrawal form * chore: update tests * chore: lint * chore: use new assetsConnection and update cy test * fix: incorrect shape of withdrawal generate function * feat: delete withdrawals page now that its shown on the portfolio page * chore: update tests to check for withdrawals page * chore: fix tests again * fix: page title test
2022-09-06 01:30:13 +00:00
WithdrawalsTable,
} from '@vegaprotocol/withdraws';
import { useVegaWallet } from '@vegaprotocol/wallet';
import { t, useDataProvider } from '@vegaprotocol/react-helpers';
feat (#896): large withdraws (#1180) * feat: add deposits table to deposits tab on portfolio page * feat: refactor use-withdraw hook to not invoke eth tx * feat: rename hook for clarity * feat: fix withdrawal creation test * feat: update withdraw-manager and withrawals-table tests * chore: fix lint * feat: remove web3 input to avoid double dialog * chore: use renderHook from testing-library/react * chore: update to use non deprecated fields * chore: remove usage of all bridge contract * feat: correctly merge cache update in withdrawals table * feat: changes to support token app withdrawals * chore: add height to ag grid table wrapping element * feat: add txhash col to withdraw table * feat: provide better ui if withdrawal is not ready to be completed * feat: use separate dialogs for txs * feat: allow user to immediately complete withdrawal if delay not triggered * feat: add withdraw store to tidy up state management * chore: fix tests * chore: convert callback to promises, fix tests, delete withdraw page * chore: fix lint errors * fix: withdrawals link in nav * feat: style changes after design update * fix: proposal form test * chore: tidy error ui logic * feat: review comments * chore: lint * feat: add better typing for tables * chore: put withdrawals tab at the end * chore: update i18n * fix: dialog in positions manager due to rename * chore: increase spacing in withdrawal form * chore: update tests * chore: lint * chore: use new assetsConnection and update cy test * fix: incorrect shape of withdrawal generate function * feat: delete withdrawals page now that its shown on the portfolio page * chore: update tests to check for withdrawals page * chore: fix tests again * fix: page title test
2022-09-06 01:30:13 +00:00
import { VegaWalletContainer } from '../../components/vega-wallet-container';
Feat/104 withdraws (#263) * add withdraw page * add create page and withdraws lib with basic components * add create withdrawal functionality, add withdrawal dialog * re arrange pages so we have a pending page with a list of withdrawals and a withdraw page with the form * handle withdrawal completion * add withdraw dialog so withdraw is completed in one flow * rename and arrange prop getter function to avoid use of any * tidy up and make eth transaction and vega transaction hooks follow similar patterns * make complete withdraw hook fetch approval, combine hooks for full flow * delete unused file * add accounts to query to get use max withdraw button * use ag grid fro withdrawals list * format amount in grid * ensure party has id field for cache * update to use t i18n function * change complete status to better match values of WithdrawalStatus * add asset lib file for type guard * share queries for withdraws lib * move web3 related hooks to the web3 lib and make web3 lib buildable * add unit test for use-complete-withdraw * add test for use-withdraw * add e2e scenarios for withdrawals * don render custom no withdrawals message and use ag grid prop * make withdraw form take ethereum account as prop * add test config, update withdraw form to handle min/max amounts, add unit test for withdraw form * fix rendering 0 if not pending withdrawals * use controlled component for select box * tidy up async parts of tests, add test for withdraw-manager * update withdraw dialog to use map for different tx states * add fallback etherscan link, add test for withdraw-dialog.spec.tsx * rename erc20 query in token app, change page structure to /withdraw and /withdrawals * change linked vegawallet-service-api-client to newly published version * ignore not implemented withdrawals e2e tests * make vega tx pending and requested states the same, for now, until tx confirmation work is done * Add some unit tests for determine-ids and remove0x Neither are critical, but both are libs expected to be shared between projects so some unit tests will hopefully ensure projects all have the same expectations about how the functions act. - Add 1 determine-ids test - Add a few remove-0x tests - Update determine-ids to use remove-0x - Add a comment describing why i18n is what it is * modify cache with client only field for tracking foreign chain progress * move withdrawals-list to lib, add useWithdrawals hook * add container component for withdrawals page * add unit tests for withdrawals-table * add some tests for use-withdrawals hook * revert changes to generated files in other libs and apps * update withdrawals scenarios * resolve pr comments * update page containers to use render prop rather than children * delete unused files * remove transaction dialog story Co-authored-by: Ditmir-Vega <ditmir@vega.xyz> Co-authored-by: Edd <edd@vega.xyz>
2022-04-27 02:51:39 +00:00
export const WithdrawalsContainer = () => {
const { pubKey } = useVegaWallet();
const { data, loading, error } = useDataProvider({
dataProvider: withdrawalProvider,
variables: { partyId: pubKey || '' },
skip: !pubKey,
});
const openWithdrawDialog = useWithdrawalDialog((state) => state.open);
Feat/104 withdraws (#263) * add withdraw page * add create page and withdraws lib with basic components * add create withdrawal functionality, add withdrawal dialog * re arrange pages so we have a pending page with a list of withdrawals and a withdraw page with the form * handle withdrawal completion * add withdraw dialog so withdraw is completed in one flow * rename and arrange prop getter function to avoid use of any * tidy up and make eth transaction and vega transaction hooks follow similar patterns * make complete withdraw hook fetch approval, combine hooks for full flow * delete unused file * add accounts to query to get use max withdraw button * use ag grid fro withdrawals list * format amount in grid * ensure party has id field for cache * update to use t i18n function * change complete status to better match values of WithdrawalStatus * add asset lib file for type guard * share queries for withdraws lib * move web3 related hooks to the web3 lib and make web3 lib buildable * add unit test for use-complete-withdraw * add test for use-withdraw * add e2e scenarios for withdrawals * don render custom no withdrawals message and use ag grid prop * make withdraw form take ethereum account as prop * add test config, update withdraw form to handle min/max amounts, add unit test for withdraw form * fix rendering 0 if not pending withdrawals * use controlled component for select box * tidy up async parts of tests, add test for withdraw-manager * update withdraw dialog to use map for different tx states * add fallback etherscan link, add test for withdraw-dialog.spec.tsx * rename erc20 query in token app, change page structure to /withdraw and /withdrawals * change linked vegawallet-service-api-client to newly published version * ignore not implemented withdrawals e2e tests * make vega tx pending and requested states the same, for now, until tx confirmation work is done * Add some unit tests for determine-ids and remove0x Neither are critical, but both are libs expected to be shared between projects so some unit tests will hopefully ensure projects all have the same expectations about how the functions act. - Add 1 determine-ids test - Add a few remove-0x tests - Update determine-ids to use remove-0x - Add a comment describing why i18n is what it is * modify cache with client only field for tracking foreign chain progress * move withdrawals-list to lib, add useWithdrawals hook * add container component for withdrawals page * add unit tests for withdrawals-table * add some tests for use-withdrawals hook * revert changes to generated files in other libs and apps * update withdrawals scenarios * resolve pr comments * update page containers to use render prop rather than children * delete unused files * remove transaction dialog story Co-authored-by: Ditmir-Vega <ditmir@vega.xyz> Co-authored-by: Edd <edd@vega.xyz>
2022-04-27 02:51:39 +00:00
return (
<VegaWalletContainer>
<div className="h-full relative grid grid-rows-[1fr,min-content]">
<div className="h-full relative">
<WithdrawalsTable
data-testid="withdrawals-history"
rowData={data}
noRowsOverlayComponent={() => null}
/>
<div className="pointer-events-none absolute inset-0">
<AsyncRenderer
data={data}
loading={loading}
error={error}
noDataCondition={(data) => !(data && data.length)}
noDataMessage={t('No withdrawals')}
/>
</div>
feat (#896): large withdraws (#1180) * feat: add deposits table to deposits tab on portfolio page * feat: refactor use-withdraw hook to not invoke eth tx * feat: rename hook for clarity * feat: fix withdrawal creation test * feat: update withdraw-manager and withrawals-table tests * chore: fix lint * feat: remove web3 input to avoid double dialog * chore: use renderHook from testing-library/react * chore: update to use non deprecated fields * chore: remove usage of all bridge contract * feat: correctly merge cache update in withdrawals table * feat: changes to support token app withdrawals * chore: add height to ag grid table wrapping element * feat: add txhash col to withdraw table * feat: provide better ui if withdrawal is not ready to be completed * feat: use separate dialogs for txs * feat: allow user to immediately complete withdrawal if delay not triggered * feat: add withdraw store to tidy up state management * chore: fix tests * chore: convert callback to promises, fix tests, delete withdraw page * chore: fix lint errors * fix: withdrawals link in nav * feat: style changes after design update * fix: proposal form test * chore: tidy error ui logic * feat: review comments * chore: lint * feat: add better typing for tables * chore: put withdrawals tab at the end * chore: update i18n * fix: dialog in positions manager due to rename * chore: increase spacing in withdrawal form * chore: update tests * chore: lint * chore: use new assetsConnection and update cy test * fix: incorrect shape of withdrawal generate function * feat: delete withdrawals page now that its shown on the portfolio page * chore: update tests to check for withdrawals page * chore: fix tests again * fix: page title test
2022-09-06 01:30:13 +00:00
</div>
<div className="w-full dark:bg-black bg-white absolute bottom-0 h-auto flex justify-end px-[11px] py-2">
<Button
size="sm"
onClick={() => openWithdrawDialog()}
data-testid="withdraw-dialog-button"
>
{t('Make withdrawal')}
</Button>
</div>
</div>
</VegaWalletContainer>
Feat/104 withdraws (#263) * add withdraw page * add create page and withdraws lib with basic components * add create withdrawal functionality, add withdrawal dialog * re arrange pages so we have a pending page with a list of withdrawals and a withdraw page with the form * handle withdrawal completion * add withdraw dialog so withdraw is completed in one flow * rename and arrange prop getter function to avoid use of any * tidy up and make eth transaction and vega transaction hooks follow similar patterns * make complete withdraw hook fetch approval, combine hooks for full flow * delete unused file * add accounts to query to get use max withdraw button * use ag grid fro withdrawals list * format amount in grid * ensure party has id field for cache * update to use t i18n function * change complete status to better match values of WithdrawalStatus * add asset lib file for type guard * share queries for withdraws lib * move web3 related hooks to the web3 lib and make web3 lib buildable * add unit test for use-complete-withdraw * add test for use-withdraw * add e2e scenarios for withdrawals * don render custom no withdrawals message and use ag grid prop * make withdraw form take ethereum account as prop * add test config, update withdraw form to handle min/max amounts, add unit test for withdraw form * fix rendering 0 if not pending withdrawals * use controlled component for select box * tidy up async parts of tests, add test for withdraw-manager * update withdraw dialog to use map for different tx states * add fallback etherscan link, add test for withdraw-dialog.spec.tsx * rename erc20 query in token app, change page structure to /withdraw and /withdrawals * change linked vegawallet-service-api-client to newly published version * ignore not implemented withdrawals e2e tests * make vega tx pending and requested states the same, for now, until tx confirmation work is done * Add some unit tests for determine-ids and remove0x Neither are critical, but both are libs expected to be shared between projects so some unit tests will hopefully ensure projects all have the same expectations about how the functions act. - Add 1 determine-ids test - Add a few remove-0x tests - Update determine-ids to use remove-0x - Add a comment describing why i18n is what it is * modify cache with client only field for tracking foreign chain progress * move withdrawals-list to lib, add useWithdrawals hook * add container component for withdrawals page * add unit tests for withdrawals-table * add some tests for use-withdrawals hook * revert changes to generated files in other libs and apps * update withdrawals scenarios * resolve pr comments * update page containers to use render prop rather than children * delete unused files * remove transaction dialog story Co-authored-by: Ditmir-Vega <ditmir@vega.xyz> Co-authored-by: Edd <edd@vega.xyz>
2022-04-27 02:51:39 +00:00
);
};