-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move files for more cohesion (#183)
* move avatar input and chain select * move helper into chains module * move isConnected helper to providers module * update exports/imports for useStorage * update provider exports * move connect icons * make route names more obvious * move mod select into edit route * move more components closer to the place of usage
- Loading branch information
1 parent
fd8581a
commit 659b1ad
Showing
36 changed files
with
222 additions
and
229 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { invariant } from '@epic-web/invariant' | ||
import { parsePrefixedAddress, PrefixedAddress } from 'ser-kit' | ||
|
||
export const getChainId = (address: PrefixedAddress) => { | ||
// atm, we don't yet support cross-chain routes, so can derive a general chainId from the avatar | ||
const [chainId] = parsePrefixedAddress(address) | ||
|
||
invariant(chainId != null, 'chainId is empty') | ||
|
||
return chainId | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './const' | ||
export { getChainId } from './getChainId' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { ChainId, parsePrefixedAddress, PrefixedAddress } from 'ser-kit' | ||
import { InjectedWalletContextT } from './useInjectedWallet' | ||
import { WalletConnectResult } from './useWalletConnect' | ||
|
||
export const isConnected = ( | ||
providerContext: InjectedWalletContextT | WalletConnectResult | null, | ||
account: PrefixedAddress, | ||
chainId: ChainId | ||
) => { | ||
if (providerContext == null) { | ||
return false | ||
} | ||
|
||
if (providerContext.connected === false) { | ||
return false | ||
} | ||
|
||
if (providerContext.chainId !== chainId) { | ||
return false | ||
} | ||
|
||
const [, accountAddress] = parsePrefixedAddress(account) | ||
|
||
return providerContext.accounts.some( | ||
(account) => account.toLowerCase() === accountAddress.toLowerCase() | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.