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

fix: staking now shows when no wallet attached #147

Merged
merged 1 commit into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/helpers/markets/markets-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export type NetworkConfig = {
* In the upcoming version this will no longer be needed.
*/
uiPoolDataProvider: string;
uiIncentiveDataProvider: string;
uiIncentiveDataProvider?: string;
chainlinkFeedRegistry?: string;
};
protocolDataUrl: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export function IncentivesDataProvider({ children }: { children: ReactNode }) {
currentAccount,
networkConfig.addresses.chainlinkFeedRegistry,
networkConfig.usdMarket ? Denominations.usd : Denominations.eth,
preferredConnectionMode === ConnectionMode.rpc || network !== apolloClientNetwork
preferredConnectionMode === ConnectionMode.rpc ||
network !== apolloClientNetwork ||
!networkConfig.addresses.uiIncentiveDataProvider
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not happy with that fix, when i have some time i'll look into redoing the dataflow.
It's kinda nutzs that we go soo deep down the dom just to set a boolean skip flag because there's no address set

);

const {
Expand All @@ -74,7 +76,7 @@ export function IncentivesDataProvider({ children }: { children: ReactNode }) {
currentMarketData.addresses.LENDING_POOL_ADDRESS_PROVIDER,
network,
networkConfig.addresses.uiIncentiveDataProvider,
!isRPCActive,
!isRPCActive || !networkConfig.addresses.uiIncentiveDataProvider,
currentAccount
);

Expand Down
10 changes: 6 additions & 4 deletions src/libs/pool-data-provider/hooks/use-incentives-data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export interface IncentiveDataResponse {
export function useIncentivesData(
lendingPoolAddressProvider: string,
network: Network,
incentiveDataProviderAddress: string,
incentiveDataProviderAddress: string | undefined,
skip: boolean,
userAddress?: string
): IncentiveDataResponse {
Expand Down Expand Up @@ -162,7 +162,7 @@ export function useIncentivesData(
setLoadingReserveIncentives(true);
setLoadingUserIncentives(true);

if (!skip) {
if (!skip && incentiveDataProviderAddress) {
fetchData(currentAccount, lendingPoolAddressProvider, incentiveDataProviderAddress);
const intervalID = setInterval(
() => fetchData(currentAccount, lendingPoolAddressProvider, incentiveDataProviderAddress),
Expand All @@ -182,7 +182,9 @@ export function useIncentivesData(
loading,
error,
data: { reserveIncentiveData, userIncentiveData },
refresh: () =>
fetchData(currentAccount, lendingPoolAddressProvider, incentiveDataProviderAddress),
refresh: async () => {
if (incentiveDataProviderAddress)
return fetchData(currentAccount, lendingPoolAddressProvider, incentiveDataProviderAddress);
},
};
}
6 changes: 2 additions & 4 deletions src/libs/pool-data-provider/hooks/use-stake-data-with-rpc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ export function useStakeDataWithRpc(
const [stakeData, setStakeData] = useState<StakesData>();
const [usdPriceEth, setUsdPriceEth] = useState<string>('0');

const loadStakeData = async (
userAddress: string = ethers.constants.AddressZero,
helperAddress: string
) => {
const loadStakeData = async (_userAddress: string | undefined, helperAddress: string) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useraddress is not undefined, but an empty string if not set so this default value doesn't work

const userAddress = _userAddress ? _userAddress : ethers.constants.AddressZero;
const helperContract = StakeUiHelperIFactory.connect(helperAddress, getProvider(network));
try {
const data = await helperContract.getUserUIData(userAddress);
Expand Down