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

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim committed Jul 14, 2023
2 parents c5b4ca3 + ed54bcf commit fb244b8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
13 changes: 6 additions & 7 deletions src/components/MemoViewComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@ export const MemoViewComponent: React.FC<MemoViewComponentProps> = ({

return (
<div className='flex flex-col p-[16px] gap-y-[16px] w-[800px] bg-brown rounded-[10px]'>
{memoText === 'Encrypted' ? (
<ActionCell title='Sender Address'>
<Copy text={memoSender} type='last' />
</ActionCell>
) : (
<ActionCell title='Message'>{memoText}</ActionCell>
)}
<ActionCell
title={memoText === 'Encrypted' ? 'Sender Address' : 'Message'}
isEncrypted={memoText === 'Encrypted'}
>
{memoText}
</ActionCell>
<ActionCell
title='Return Address'
isEncrypted={memoSender === 'Encrypted'}
Expand Down
28 changes: 28 additions & 0 deletions src/components/penumbra/view/SwapView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { UNKNOWN_ASSET_PREFIX } from '@/lib/constants'
import { uint8ToBase64 } from '@/lib/uint8ToBase64'
import {
SwapView,
SwapView_Opaque,
SwapView_Visible,
} from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/dex/v1alpha1/dex_pb'
import { bech32m } from 'bech32'
Expand Down Expand Up @@ -76,6 +77,33 @@ export const SwapViewComponent: React.FC<{ view: SwapView }> = ({ view }) => {
</ActionCell>
)
}
case 'opaque': {
const opaqueSwap: SwapView_Opaque = view.swapView.value

const asset1Id = opaqueSwap.swap?.body?.tradingPair?.asset1
const asset1 = getAssetByAssetId(assets, uint8ToBase64(asset1Id!.inner!))
const asset1Amount = opaqueSwap.swap?.body?.delta1I
const { asssetHumanDenom: assset1HumanDenom } = getHumanReadableValue(
asset1,
asset1Amount,
asset1Id!
)

const asset2Id = opaqueSwap.swap?.body?.tradingPair?.asset2
const asset2 = getAssetByAssetId(assets, uint8ToBase64(asset2Id!.inner!))
const asset2Amount = opaqueSwap.swap?.body?.delta2I
const { asssetHumanDenom: assset2HumanDenom } = getHumanReadableValue(
asset2,
asset2Amount,
asset2Id!
)

return (
<ActionCell title='Swap'>
{`Opaque swap for trading pair: ${assset1HumanDenom} <=> ${assset2HumanDenom}`}
</ActionCell>
)
}
default: {
return <ActionCell title='Swap' isEncrypted={true} />
}
Expand Down
8 changes: 3 additions & 5 deletions src/lib/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@ export const getHumanReadableValue = (
?.exponent || 0
}

const assetHumanAmount = calculateAmount(
Number(amount?.lo),
Number(amount?.hi),
assetExponent
)
const assetHumanAmount = amount
? calculateAmount(Number(amount?.lo), Number(amount?.hi), assetExponent)
: 0

return {
assetHumanAmount,
Expand Down

0 comments on commit fb244b8

Please sign in to comment.