fix: provider is by default null and account page redirect to provider setup (#437)

This commit is contained in:
Vojtech Simetka
2022-06-24 14:03:37 +02:00
committed by GitHub
parent a756eedc49
commit 2e0eeb7a1b
9 changed files with 48 additions and 42 deletions
+1
View File
@@ -25,6 +25,7 @@ export default function Index(): ReactElement {
useEffect(() => {
async function mapGiftWallets() {
if (!provider) return
const results = []
for (const giftWallet of giftWallets) {
results.push(await ResolvedWallet.make(giftWallet, provider))
+3 -1
View File
@@ -19,6 +19,8 @@ export default function Index(): ReactElement {
const navigate = useNavigate()
async function onSubmit() {
if (!localProviderUrl) return
try {
await Rpc.eth_getBlockByNumber(new providers.JsonRpcProvider(localProviderUrl))
enqueueSnackbar('Connected to RPC provider successfully.', { variant: 'success' })
@@ -54,7 +56,7 @@ export default function Index(): ReactElement {
name="rpc-endpoint"
label="RPC Endpoint"
onChange={event => setLocalProviderUrl(event.target.value)}
defaultValue={providerUrl}
defaultValue={providerUrl || ''}
/>
</Box>
<SwarmButton iconType={Check} onClick={onSubmit}>
+2 -2
View File
@@ -31,7 +31,7 @@ export function GiftCardFund(): ReactElement {
const navigate = useNavigate()
useEffect(() => {
if (!privateKeyString) {
if (!privateKeyString || !provider) {
return
}
@@ -43,7 +43,7 @@ export function GiftCardFund(): ReactElement {
}
async function onFund() {
if (!wallet || !nodeAddresses) {
if (!wallet || !nodeAddresses || !providerUrl) {
return
}
+2
View File
@@ -24,6 +24,8 @@ export function GiftCardTopUpIndex(): ReactElement {
const navigate = useNavigate()
async function onProceed() {
if (!provider) return
setLoading(true)
try {
const wallet = new Wallet(giftCode, provider)
+1 -1
View File
@@ -45,7 +45,7 @@ export function Swap({ header }: Props): ReactElement {
const bzzAfterSwap = new BzzToken(daiToSwap.toBigNumber.dividedToIntegerBy(200))
async function onSwap() {
if (hasSwapped) {
if (hasSwapped || !providerUrl) {
return
}
setLoading(true)