Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
retroboydev committed Dec 13, 2023
1 parent 6f124e8 commit 9bad7f9
Show file tree
Hide file tree
Showing 7 changed files with 930 additions and 28 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
"@web3-react/injected-connector": "^6.0.7",
"events": "^3.3.0",
"get-starknet-core": "^3.2.0",
"starknetkit": "^1.0.22",
"vite-plugin-svgr": "^2.2.0",
"wido-widget": "1.5.3"
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/WalletModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,12 @@ export default function WalletModal({
key={wallet.id}
header={wallet.name}
icon={wallet.icon}
subheader={''}
subheader={wallet.id === 'argentWebWallet' && 'Powered by Argent'}
onClick={() => {
option === connector ? setWalletView(WALLET_VIEWS.ACCOUNT) : tryActivation(option)
}}
active={connector === connector}
color={wallet.id === 'argentX' ? '#FF875B' : '#E0B137'}
color={wallet?.color}
link={wallet?.href}
size={wallet?.size ?? null}
/>
Expand Down
1 change: 0 additions & 1 deletion src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ export const SUPPORTED_WALLETS: { [key: string]: WalletInfo } = {
icon: ARGENTX_ICON,
connector: argentX,
color: '#FF875B',

description: 'Starknet Browser Wallet',
href: null,
mobile: true
Expand Down
21 changes: 12 additions & 9 deletions src/context/StarknetProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
// @ts-nocheck

'use client'
import React from 'react'
import React, {useMemo} from 'react'

import { goerli, mainnet } from '@starknet-react/chains'
import { StarknetConfig, argent, braavos, useInjectedConnectors } from '@starknet-react/core'
import { WebWalletConnector } from "starknetkit/webwallet";
import rpcProvider from '../utils/getLibrary'
import { isTestnetEnvironment } from '../connectors'

export function StarknetProvider({ children }: { children: React.ReactNode }) {
const chains = [mainnet, goerli]
const { connectors } = useInjectedConnectors({
// Show these connectors if the user has no connector installed.
recommended: [argent(), braavos()],
// Hide recommended connectors if the user has any connector installed.
includeRecommended: 'onlyIfNoConnectors',
// Randomize the order of the connectors.
order: 'random'
})
const connectors = useMemo(() => [
argent(),
new WebWalletConnector({
url: isTestnetEnvironment() ? "https://web.hydrogen.argent47.net" : "https://web.argent.xyz/",
}),
braavos()
], []);

return (
<StarknetConfig chains={chains} connectors={connectors} provider={rpcProvider} autoConnect>
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {useChain} from "react-spring";

export const useAccountDetails = () => {
const { account, address, connector, status } = useAccount()
const chainId = account?.chainId ?? account?.provider?.chainId ?? ChainId.SN_MAIN;
const chainId = account?.chainId ?? account?.provider?.chainId;

return useMemo(() => {
return { address, connector, chainId, account, status }
Expand Down
11 changes: 8 additions & 3 deletions src/utils/getLibrary.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import {infuraProvider, publicProvider} from "@starknet-react/core";
import {jsonRpcProvider} from "@starknet-react/core";

// const provider = infuraProvider({apiKey: 'd2d7de54ec90453dbdc9af6d52dad2a5'})
const provider = publicProvider()
const provider = jsonRpcProvider({
rpc: (chain) => {
return {
nodeUrl: chain.network === 'goerli' ? 'https://rpc.starknet-testnet.lava.build' : `https://starknet-${chain.network}-rpc.dwellir.com/dd28e566-3260-4d8d-8180-6ef1a161e41c`
}
}
})

export default provider
Loading

0 comments on commit 9bad7f9

Please sign in to comment.