Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: wip correct wallet address handling
- Loading branch information
simodrws
committed
May 5, 2023
1 parent
4870a36
commit 206592f
Showing
7 changed files
with
132 additions
and
9 deletions.
There are no files selected for viewing
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 @@ | ||
export * from './configured-rainbowkit-provider'; |
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,71 @@ | ||
import { Network, SupportedNetworks } from '@masa-finance/masa-sdk'; | ||
import { Alfajores, Celo } from '@celo/rainbowkit-celo/chains'; | ||
import { | ||
baseGoerli, | ||
bsc, | ||
bscTestnet, | ||
goerli, | ||
mainnet, | ||
polygon, | ||
polygonMumbai, | ||
} from 'wagmi/chains'; | ||
|
||
const rainbowkitChains = [ | ||
Alfajores, | ||
baseGoerli, | ||
bsc, | ||
bscTestnet, | ||
Celo, | ||
goerli, | ||
mainnet, | ||
polygon, | ||
polygonMumbai, | ||
]; | ||
|
||
type MasaNetworks = Partial<{ | ||
goerli: Network; | ||
ethereum: Network; | ||
mainnet: Network; | ||
alfajores: Network; | ||
celo: Network; | ||
mumbai: Network; | ||
polygon: Network; | ||
bsctest: Network; | ||
bsc: Network; | ||
basegoerli: Network; | ||
unknown: Network; | ||
}>; | ||
|
||
export const getRainbowkitChains = ( | ||
networkList?: Array<keyof MasaNetworks> | ||
) => { | ||
if (!networkList || (networkList && !networkList.length)) { | ||
return rainbowkitChains; | ||
} | ||
|
||
const masaNetworks = Object.keys(SupportedNetworks) | ||
.filter((x: string) => x !== 'ethereum' && x !== 'unknown') // remove unused network | ||
.reduce((acc: MasaNetworks, val: string) => { | ||
acc[val] = SupportedNetworks[val] as Network; | ||
return acc; | ||
}, {}); | ||
|
||
const masaNetworkNames = Object.keys(masaNetworks); | ||
|
||
const userNetworksFiltered = networkList.filter((networkName) => | ||
masaNetworkNames.includes(networkName) | ||
); | ||
|
||
const userNetworksMasa = userNetworksFiltered.map((un) => masaNetworks[un]); | ||
const userNetworksRainbowkit = userNetworksMasa.map((unm) => unm?.chainId); | ||
const userChainsRainbowkit = rainbowkitChains.filter((rainbowkitChain) => | ||
userNetworksRainbowkit.includes(rainbowkitChain.id) | ||
); | ||
return userChainsRainbowkit; | ||
|
||
// const networkLi; | ||
// const rainbowkitChains = networkList.filter((network: any) => { | ||
// return network.name === SupportedNetworks.Rainbowkit; | ||
// }); | ||
// return rainbowkitChains; | ||
}; |
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