Skip to content
This repository has been archived by the owner on Oct 22, 2023. It is now read-only.

WIP: use util-lib instead of appStates #179

Closed
wants to merge 55 commits into from

Conversation

anukulpandey
Copy link
Collaborator

  • replaced apollo with axios

}
}else{
if(network=='testnet'){
return "https://squid.subsquid.io/reef-swap-testnet/graphql";
Copy link
Member

Choose a reason for hiding this comment

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

add links to local const at the top

) => {
let selectedNetwork:string="mainnet";
try {
let storedNetwork = localStorage.getItem("reef-app-active-network");
Copy link
Member

Choose a reason for hiding this comment

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

'reef-app-active-network' should be in local const at top of file as well

});
};

const getAllAccounts = (accountIds:any) => ({
Copy link
Member

Choose a reason for hiding this comment

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

getAllAccountsQuery suffix to be consistent

});
};

const getAllAccounts = (accountIds:any) => ({
query: EVM_ADDRESS_UPDATE_GQL,
variables: {accountIds}
});

const indexedAccountValues$ = combineLatest([
Copy link
Member

Choose a reason for hiding this comment

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

this should be taken from util-lib

return result.data.data.accounts.map((a) => ({ address: a.id, evmAddress: a.evmAddress, isEvmClaimed: !!a.evmAddress } as AccountEvmAddrData))}),
filter((v) => !!v),
startWith([]),
);

const signersWithUpdatedData$ = combineLatest([
Copy link
Member

Choose a reason for hiding this comment

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

should also come from util-lib

// dexClient.query<PoolsWithReservesQuery>(
// { query: POOLS_RESERVES_GQL, variables: { tokens: tokenAddresses } },
// );
return res.data.data.poolsReserves || [];
};

export const tokenPrices$: Observable<TokenWithAmount[]> = combineLatest([
Copy link
Member

Choose a reason for hiding this comment

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

should also come from util-lib

query: TRANSFER_HISTORY_GQL,
variables: {accountId}
});

export const transferHistory$: Observable<
Copy link
Member

Choose a reason for hiding this comment

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

should also come from util-lib

@@ -419,7 +418,7 @@ export const POOLS_RESERVES_GQL = `
`;

export const POOL_TRANSACTIONS_GQL = `
query transactions(
subscription transactions(
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't be using subscriptions - probably need to listen to contract events from util-lib


const [loadedReefSigners,isLoadingReefSigners] = getReefSignersArray([reefAccountToReefSigner(accountsFromUtilLib,jsonAccounts.injectedSigner!)],provider!);
useEffect(() => {
accountsSubj.next(loadedReefSigners || []);
Copy link
Member

Choose a reason for hiding this comment

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

accounts in react-lib should be transformed from util-lib observable and not set as Subject - like:
export const injectedSigners$ = reefState.accounts$.pipe(...)
and should be referenced where signers are needed

loading,
provider,
network: selectedNetwork,
extension,
signers: loadedReefSigners,
Copy link
Member

Choose a reason for hiding this comment

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

loadedReefSigners should then take value from useObservableState(injectedSigners$)

@anukulpandey
Copy link
Collaborator Author

closing this as we will be using #180

@matjazonline matjazonline deleted the apollo-v branch October 21, 2023 21:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants