Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

[Deposit] Update UI to show pending assets #1505

Merged
merged 9 commits into from
Jun 7, 2021

Conversation

veado
Copy link
Collaborator

@veado veado commented Jun 3, 2021

Peek.2021-06-07.18-38.mp4
  • Show alert box in case of pending assets
  • Disable deposit form in case of pending assets
  • Reload data of pending assets by clicking "reload" button
  • Link to asgard.exchange to recover pending asset
  • Update i18n

Closes #1496

@veado veado self-assigned this Jun 3, 2021
veado added 7 commits June 4, 2021 14:10
into issue-1496/ui-pending-assets
Still WIP - currently it fails to get data of liquidity providers
Note: address$ causes the race condition. Also instead of subscribing
selectedPoolAsset$, just use oRouteAsset (which is available asap)
@veado veado changed the title WIP: [Deposit] Update UI to show pending assets [Deposit] Update UI to show pending assets Jun 7, 2021
@veado veado marked this pull request as ready for review June 7, 2021 16:41
src/renderer/components/deposit/add/SymDeposit.tsx Outdated Show resolved Hide resolved
src/renderer/components/deposit/add/SymDeposit.tsx Outdated Show resolved Hide resolved
src/renderer/i18n/ru/deposit.ts Outdated Show resolved Hide resolved
}))
A.map((provider): LiquidityProvider => {
const pendingRuneAmount = baseAmount(provider.pending_rune, THORCHAIN_DECIMAL)
const pendingAssetAmount = baseAmount(provider.pending_asset, assetDecimal)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just realized that such transformation to the BaseAmount is a little bit incorrect... assetDecimal is not always the same as selectedPoolAsset's decimal in general.
for the future i believe we need to pass pending amounts as strings directly and transform to the BaseAmount only "on demand" (at the view level when we know assets' decimals...)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be done with another PR - see #1512

@@ -84,16 +84,19 @@ export type GetLiquidityProvidersParams = {
}

export type GetLiquidityProviderParams = GetLiquidityProvidersParams & {
runeAddress: O.Option<Address>
assetAddress: O.Option<Address>
runeAddress: Address
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would keep runeAddress: O.Option<Address>:

  • assetAddress is always required for both sym/asym providers
  • runeAddress is optional to detect if we want to get sym/asym provider.
    i know we now "ignore" all asym-related stuff but if this is a brand-new stuff we should be "aimed" to the future stuff

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good points as well!

Copy link
Collaborator Author

@veado veado Jun 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be done with another PR - see #1512

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runeAddress is optional to detect if we want to get sym/asym provider.

That's not correct, but as follow: "if member is assym - they will only have either rune_address or asset_address in their member details." (see https://thorchain.slack.com/archives/C012CLYR1DG/p1612347969232600?thread_ts=1612288793.231200&cid=C012CLYR1DG). We will check always both addresses then.

Check for pending asset is for sym. deposit needed only. If an asym. deposit might fail, there won't be a pending asset.

Comment on lines +161 to +175
const [liquidityProvider] = useObservableState<LiquidityProviderRD>(() => {
return Rx.combineLatest([
network$,
// We should look for THORChain's wallet at the response of liqudity_providers endpoint
address$,
addressByChain$(THORChain),
assetWithDecimalLD
]).pipe(
RxOp.switchMap(([network, oAssetAddress, oRuneAddress, assetWithDecimalRD]) => {
return FP.pipe(
sequenceTOption(oRuneAddress, oAssetAddress, RD.toOption(assetWithDecimalRD)),
O.fold(
(): LiquidityProviderLD => Rx.of(RD.initial),
([runeAddress, assetAddress, assetWithDecimal]) =>
getLiquidityProvider({ assetWithDecimal, network, runeAddress, assetAddress })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would move this data getter directly inside of SymDepositView. with optional runeAddress at the getLiquidityProvider we can easily split this logic between 2 views without passing-down liquidityProvider through few levels:

  • SymDepositView: getLiquidityProvider({ assetWithDecimal: ..., network: ..., runeAddress: O.some(Address), assetAddress: Address })
  • AsymDepositView: getLiquidityProvider({ assetWithDecimal: ..., network: ..., runeAddress: O.none, assetAddress: Address })

what do you think ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

Copy link
Collaborator Author

@veado veado Jun 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be done with another PR - see #1512

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to skip this for same reason mentioned in #1505 (comment)

part 2 will be following tomorrow
@veado veado marked this pull request as draft June 7, 2021 18:07
@veado
Copy link
Collaborator Author

veado commented Jun 7, 2021

Merging now to have it in next release... All open suggestion will be done with another PR - see #1512

@veado veado marked this pull request as ready for review June 7, 2021 19:49
@veado veado merged commit 8d7537b into develop Jun 7, 2021
@veado veado deleted the issue-1496/ui-pending-assets branch June 7, 2021 19:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Deposit] Update UI to show pending assets
2 participants