-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add current reserves to the dutch auction
- Loading branch information
1 parent
18330dc
commit 9873668
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/ui/components/ui/dutch-auction-component/reserves.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { | ||
Metadata, | ||
ValueView, | ||
} from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/asset/v1/asset_pb'; | ||
import { ValueViewComponent } from '../tx/view/value'; | ||
import { DutchAuction } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/auction/v1/auction_pb'; | ||
import { Amount } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/num/v1/num_pb'; | ||
import { ActionDetails } from '../tx/view/action-details'; | ||
|
||
const getValueView = (amount: Amount, metadata?: Metadata) => | ||
new ValueView({ | ||
valueView: { | ||
case: 'knownAssetId', | ||
value: { | ||
amount, | ||
metadata, | ||
}, | ||
}, | ||
}); | ||
|
||
export const Reserves = ({ | ||
dutchAuction, | ||
inputMetadata, | ||
outputMetadata, | ||
}: { | ||
dutchAuction: DutchAuction; | ||
inputMetadata?: Metadata; | ||
outputMetadata?: Metadata; | ||
}) => { | ||
const inputAmount = dutchAuction.state?.inputReserves; | ||
const outputAmount = dutchAuction.state?.outputReserves; | ||
|
||
if (!inputAmount && !outputAmount) return null; | ||
|
||
return ( | ||
<ActionDetails.Row label='Current reserves'> | ||
<div className='flex flex-col items-end gap-2'> | ||
{inputAmount && <ValueViewComponent view={getValueView(inputAmount, inputMetadata)} />} | ||
{outputAmount && <ValueViewComponent view={getValueView(outputAmount, outputMetadata)} />} | ||
</div> | ||
</ActionDetails.Row> | ||
); | ||
}; |