-
Notifications
You must be signed in to change notification settings - Fork 3
WIP: use util-lib instead of appStates #179
Conversation
anukulpandey
commented
Aug 23, 2023
- replaced apollo with axios
src/appState/accountState.ts
Outdated
} | ||
}else{ | ||
if(network=='testnet'){ | ||
return "https://squid.subsquid.io/reef-swap-testnet/graphql"; |
There was a problem hiding this comment.
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
src/appState/accountState.ts
Outdated
) => { | ||
let selectedNetwork:string="mainnet"; | ||
try { | ||
let storedNetwork = localStorage.getItem("reef-app-active-network"); |
There was a problem hiding this comment.
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
src/appState/accountState.ts
Outdated
}); | ||
}; | ||
|
||
const getAllAccounts = (accountIds:any) => ({ |
There was a problem hiding this comment.
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([ |
There was a problem hiding this comment.
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([ |
There was a problem hiding this comment.
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([ |
There was a problem hiding this comment.
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< |
There was a problem hiding this comment.
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
src/graphql/pools.ts
Outdated
@@ -419,7 +418,7 @@ export const POOLS_RESERVES_GQL = ` | |||
`; | |||
|
|||
export const POOL_TRANSACTIONS_GQL = ` | |||
query transactions( | |||
subscription transactions( |
There was a problem hiding this comment.
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 || []); |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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$)
closing this as we will be using #180 |