Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Views to BalancesResponse #525

Closed
Tracked by #530
grod220 opened this issue Feb 15, 2024 · 0 comments · Fixed by #615
Closed
Tracked by #530

Add Views to BalancesResponse #525

grod220 opened this issue Feb 15, 2024 · 0 comments · Fixed by #615
Assignees
Labels
refactor Improving existing system with new design rpc Related to proto rpc services/methods

Comments

@grod220
Copy link
Contributor

grod220 commented Feb 15, 2024

Pairs with: penumbra-zone/penumbra#3824

Web app currently takes assetId+amount response and transforms it to AddressView+ValueView:

const constructAssetBalanceWithMetadata = async ({
balance,
account,
}: BalancesResponse): Promise<AssetBalance> => {
if (!balance) throw new Error('No balance in response');
if (!account) throw new Error('No account in response');
const value = await getValueView(balance);
const address = await getAddressView(account);
const usdcValue = await calculateUsdcValue(balance);
return { value, address, usdcValue };
};
const getValueView = async (balance: Value): Promise<ValueView> => {
if (!balance.assetId) throw new Error('no asset id in balance');
if (!balance.amount) throw new Error('no amount in balance');
const { denomMetadata } = await viewClient.assetMetadataById({ assetId: balance.assetId });
if (!denomMetadata) {
return new ValueView({
valueView: { case: 'unknownAssetId', value: balance },
});
} else {
return new ValueView({
valueView: {
case: 'knownAssetId',
value: {
amount: balance.amount,
metadata: denomMetadata,
},
},
});
}
};

After new protos, this should move into balances view rpc method in extension.

While here, should delete calculateUsdcValue() in web app as extension now provides pricing.

@github-project-automation github-project-automation bot moved this to 🗄️ Backlog in Penumbra web Feb 15, 2024
@grod220 grod220 added rpc Related to proto rpc services/methods refactor Improving existing system with new design labels Feb 15, 2024
@grod220 grod220 moved this from 🗄️ Backlog to 📝 Todo in Penumbra web Feb 15, 2024
@grod220 grod220 moved this from 📝 Todo to 🛑 Blocked in Penumbra web Feb 19, 2024
@grod220 grod220 moved this from 🛑 Blocked to 🏗 In progress in Penumbra web Feb 27, 2024
@grod220 grod220 self-assigned this Feb 27, 2024
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Penumbra web Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Improving existing system with new design rpc Related to proto rpc services/methods
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant