Skip to content

Commit

Permalink
feat: export hasShares function
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandermendes committed Nov 11, 2024
1 parent 712fa68 commit 89979ef
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export { StakingProvider } from './provider';
export { type StakingContextType } from './context';
export { stakingAbi } from './abis/staking';
export { config as stakingConfig } from './config';
export { hasShares } from './utils/shares';
4 changes: 2 additions & 2 deletions src/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import {
unstakeAll,
withdraw,
withdrawAll,
} from './utils';
import { sleep } from './sleep';
} from './utils/staking';
import { sleep } from './utils/sleep';
import { useWeb3Provider } from './hooks/useWeb3Provider';
import { Stream } from './types/stream';
import { Withdrawal } from './types/withdrawal';
Expand Down
21 changes: 21 additions & 0 deletions src/utils/shares.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { providers } from 'ethers';
import { AuroraNetwork } from '../types/network';
import { config } from '../config';
import { getUserShares } from './staking';

/**
* Confirm that a user's account has shares.
*/
export const hasShares = async (
network: AuroraNetwork,
address: string,
): Promise<boolean> => {
const networkConfig = config[network];
const { rpcUrl } = networkConfig;
const provider = new providers.JsonRpcProvider(rpcUrl);

// Confirm that account has shares
const userShares = await getUserShares(address, 0, provider, networkConfig);

return !userShares.isZero();
};
File renamed without changes.
8 changes: 4 additions & 4 deletions src/utils.ts → src/utils/staking.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BigNumber, ethers, providers } from 'ethers';
import { stakingAbi } from './abis/staking';
import { erc20abi } from './abis/erc20';
import { AuroraNetworkConfig } from './types/network';
import { logger } from './logger';
import { stakingAbi } from '../abis/staking';
import { erc20abi } from '../abis/erc20';
import { AuroraNetworkConfig } from '../types/network';
import { logger } from '../logger';

export const getDeposit = async (
account: string,
Expand Down

0 comments on commit 89979ef

Please sign in to comment.