Skip to content

Commit

Permalink
Build out rest of RPC method impl
Browse files Browse the repository at this point in the history
  • Loading branch information
jessepinho committed Mar 31, 2024
1 parent 137db6c commit af2781d
Showing 1 changed file with 31 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
import { BalancesRequest } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/view/v1/view_pb';
import {
BalancesRequest,
UnbondingTokensByAddressIndexRequest_Filter,
UnbondingTokensByAddressIndexResponse,
} from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/view/v1/view_pb';
import { Impl } from '..';
import { balances } from '../balances';
import Array from '@penumbra-zone/polyfills/src/Array.fromAsync';
import { isUnbondingTokenBalance } from './helpers';
import { getIsClaimable, isUnbondingTokenBalance } from './helpers';

export const unbondingTokensByAddressIndex: Impl['unbondingTokensByAddressIndex'] = async (
req,
ctx,
) => {
const allBalances = await Array.fromAsync(
balances(new BalancesRequest({ accountFilter: { account: 0 } }), ctx),
);
export const unbondingTokensByAddressIndex: Impl['unbondingTokensByAddressIndex'] =
async function* (req, ctx) {
for await (const balancesResponse of balances(
new BalancesRequest({ accountFilter: req.addressIndex }),
ctx,
)) {
if (!isUnbondingTokenBalance(balancesResponse)) continue;
const claimable = await getIsClaimable(balancesResponse, ctx);

const unbondingTokenBalances = allBalances.filter(isUnbondingTokenBalance);
};
if (req.filter === UnbondingTokensByAddressIndexRequest_Filter.CLAIMABLE && !claimable) {

Check failure on line 19 in packages/router/src/grpc/view-protocol-server/unbonding-tokens-by-address-index/index.ts

View workflow job for this annotation

GitHub Actions / Lint

The two values in this comparison do not have a shared enum type
continue;
}

if (
req.filter === UnbondingTokensByAddressIndexRequest_Filter.NOT_YET_CLAIMABLE &&

Check failure on line 24 in packages/router/src/grpc/view-protocol-server/unbonding-tokens-by-address-index/index.ts

View workflow job for this annotation

GitHub Actions / Lint

The two values in this comparison do not have a shared enum type
claimable
) {
continue;
}

yield new UnbondingTokensByAddressIndexResponse({
claimable,
valueView: balancesResponse.balanceView,
});
}
};

0 comments on commit af2781d

Please sign in to comment.