Skip to content

Commit

Permalink
fix(site): fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cor committed Oct 18, 2023
1 parent 3016472 commit cf999ce
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 56 deletions.
3 changes: 1 addition & 2 deletions site/src/lib/Ethers.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
import { ethers } from "ethers";
import { onMount } from 'svelte';
let provider;
let signer;
onMount(async () => {
console.log("connecting to ethereum")
provider = new ethers.providers.Web3Provider(window.ethereum, "any")
provider = new ethers.providers.Web3Provider(window.ethereum, "any");
provider.on("network", (newNetwork, oldNetwork) => {
// When a Provider makes its initial connection, it emits a "network"
// event with a null oldNetwork along with the newNetwork. So, if the
Expand Down
50 changes: 0 additions & 50 deletions site/src/lib/initClients.ts

This file was deleted.

4 changes: 3 additions & 1 deletion site/src/lib/stores/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import type { Writable } from 'svelte/store';
import type { Tendermint37Client } from '@cosmjs/tendermint-rpc';
import type { SigningStargateClient } from '@cosmjs/stargate';
import type { AccountData, Coin } from '@cosmjs/amino';
import type { ApolloClient, InMemoryCache, NormalizedCacheObject } from '@apollo/client';

export const tendermintClient: Writable<Tendermint37Client | null> = writable(null);
export const stargateClient: Writable<SigningStargateClient | null> = writable(null);
export const unionAccount: Writable<AccountData | null> = writable(null);
export const unionBalance: Writable<Coin | null> = writable(null);
export const apolloClient: Writable<ApolloClient | null> = writable(null);
export const apolloClient: Writable<ApolloClient<NormalizedCacheObject> | null> = writable(null);
export const ethersProvider: Writable<any | null> = writable(null);
8 changes: 6 additions & 2 deletions site/src/lib/transferDemo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ const GET_UNO_FROM_FAUCET = gql`
export const getUnoFromFaucet = async () => {
const uAccount = get(unionAccount);
const apollo = get(apolloClient);
if (uAccount === null) {
console.error('trying to get uno from faucet before accounts are loaded');
if (uAccount === null || apollo === null) {
console.error(
'trying to get uno from faucet before accounts are loaded or apollo client has not been init'
);
return;
}

Expand Down Expand Up @@ -129,3 +131,5 @@ export const getBalance = async () => {
}
unionBalance.set(await sgClient.getBalance(uAccount.address, 'muno'));
};

export const setupEthers = async () => {};
3 changes: 2 additions & 1 deletion site/src/routes/blog/start-of-the-endgame/+page.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ published: true
import TokenTransfer from '$lib/TokenTransfer.svelte';
// import Ethers from '$lib/Ethers.svelte';
import { browser } from '$app/environment';
import { initClients, getBalanceWorker } from '$lib/transferDemo';
import { initClients, getBalanceWorker, setupEthers } from '$lib/transferDemo';
import { onMount } from 'svelte';

onMount(async () => {
if (browser) {
await initClients();
getBalanceWorker();
setupEthers();
}
})
</script>
Expand Down

0 comments on commit cf999ce

Please sign in to comment.