Skip to content

Commit

Permalink
chore: save progress
Browse files Browse the repository at this point in the history
  • Loading branch information
o-az committed Feb 16, 2024
1 parent c0f32a3 commit 64ae6bc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
8 changes: 4 additions & 4 deletions app/src/lib/components/Connect.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
getUnoERC20Balance,
unionBalanceStore,
getUnoUnionBalance,
sendAssetFromEthereumToUnion,
_getOfflineSigner,
sendUnoFromUnionToSepolia
sendUnoFromUnionToSepolia,
sendAssetFromEthereumToUnion
} from '$/lib/union-actions'
let error: any
Expand Down Expand Up @@ -93,13 +93,13 @@
>
Switch Chain
</button>
<div class="my-3">
<!-- <div class="my-3">
{#if $unoTokenAddedToMetaMask}
<div>✅ UNO Token Added to Metamask</div>
{:else}
<button on:click={addUnoERC20}>OPTIONAL: Track UNO to Metamask</button>
{/if}
</div>
</div> -->
<div class="my-4">
{#if $connectedToUnion}
<div>✅ Connected to Union</div>
Expand Down
11 changes: 7 additions & 4 deletions app/src/lib/union-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,17 @@ export async function getDenomAddress(): Promise<Address> {
})
}

export const unionBalanceStore: Writable<bigint | null> = writable(null)
export const unionBalanceStore: Writable<string | null> = writable(null)

export async function getUnoUnionBalance(address: string) {
const signer = get(cosmjsSigner)
const tendermintClient = await Comet38Client.connect('https://union-testnet-rpc.polkachu.com')
const cosmwasmClient = await SigningCosmWasmClient.createWithSigner(tendermintClient, signer, {
gasPrice: GasPrice.fromString('0.001muno')
})
const cosmwasmClient = await SigningCosmWasmClient.createWithSigner(
tendermintClient,
// @ts-expect-error
signer,
{ gasPrice: GasPrice.fromString('0.001muno') }
)
const { amount } = await cosmwasmClient.getBalance(address, 'muno')
return amount
}
4 changes: 3 additions & 1 deletion app/src/lib/wallet/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
getOfflineSigner,
experimentalSuggestChain
} from '@leapwallet/cosmos-snap-provider'
import { getDenomAddress } from '$/lib/union-actions'

const ssr = !browser

Expand Down Expand Up @@ -140,6 +141,7 @@ export async function checkConnectedToUnion() {

export async function addUnoERC20() {
try {
const denomAddress = await getDenomAddress()
const hasBeenAdded = await window.ethereum.request({
method: 'wallet_watchAsset',
params: {
Expand All @@ -148,7 +150,7 @@ export async function addUnoERC20() {
/**
* TODO: THIS SHOULD NOT BE HARDCODED. INSTEAD CALL unionWalletClient().getDenomAddress()
*/
address: '0x465F49DE53eDDAc9635C4Cc941F442C12bE351B0',
address: denomAddress,
/**
* TODO: this should be UNO but our latest deployment to Sepolia has this as symbol
*/
Expand Down

0 comments on commit 64ae6bc

Please sign in to comment.