Skip to content

Commit

Permalink
fix: fmt and spellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
o-az committed Jun 7, 2024
1 parent 6130ab9 commit cce6062
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 47 deletions.
54 changes: 27 additions & 27 deletions app/src/lib/wallet/cosmos/chain-info.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type {ChainInfo as KeplrChainInfo} from "@keplr-wallet/types";
import type {ChainInfo as LeapChainInfo} from "@leapwallet/types";
import type { ChainInfo as KeplrChainInfo } from "@keplr-wallet/types"
import type { ChainInfo as LeapChainInfo } from "@leapwallet/types"

//This exist according to docs
interface LeapExtendedInfo extends LeapChainInfo {
theme: {
primaryColor: string;
gradient: string;
};
image: string;
primaryColor: string
gradient: string
}
image: string
}

//todo handle this for main-net
Expand All @@ -17,23 +17,23 @@ export const keplrChainInfo: KeplrChainInfo = {
rest: "https://api.testnet.bonlulu.uno",
rpc: "https://rpc.testnet.bonlulu.uno",
bip44: {
coinType: 118,
coinType: 118
},
bech32Config: {
bech32PrefixAccAddr: "union",
bech32PrefixAccPub: "unionpub",
bech32PrefixValAddr: "unionvaloper",
bech32PrefixValPub: "unionvaloperpub",
bech32PrefixConsAddr: "unionvalcons",
bech32PrefixConsPub: "unionvalconspub",
bech32PrefixConsPub: "unionvalconspub"
},
currencies: [
{
coinDenom: "UNO",
coinMinimalDenom: "muno",
coinDecimals: 6,
coinGeckoId: "cosmos",
},
coinGeckoId: "cosmos"
}
],
feeCurrencies: [
{
Expand All @@ -44,16 +44,16 @@ export const keplrChainInfo: KeplrChainInfo = {
gasPriceStep: {
low: 0.0025,
average: 0.025,
high: 0.04,
},
},
high: 0.04
}
}
],
stakeCurrency: {
coinDenom: "UNO",
coinMinimalDenom: "muno",
coinDecimals: 6,
coinGeckoId: "union",
},
coinGeckoId: "union"
}
}

//todo handle this for main-net
Expand All @@ -63,47 +63,47 @@ export const leapChainInfo: LeapExtendedInfo = {
rest: "https://api.testnet.bonlulu.uno",
rpc: "https://rpc.testnet.bonlulu.uno",
bip44: {
coinType: 118,
coinType: 118
},
bech32Config: {
bech32PrefixAccAddr: "union",
bech32PrefixAccPub: "unionpub",
bech32PrefixValAddr: "unionvaloper",
bech32PrefixValPub: "unionvaloperpub",
bech32PrefixConsAddr: "unionvalcons",
bech32PrefixConsPub: "unionvalconspub",
bech32PrefixConsPub: "unionvalconspub"
},
currencies: [
{
coinDenom: "UNO",
coinMinimalDenom: "muno",
coinDecimals: 6,
coinGeckoId: "cosmos",
},
coinGeckoId: "cosmos"
}
],
feeCurrencies: [
{
coinDenom: "UNO",
coinMinimalDenom: "muno",
coinDecimals: 6,
coinGeckoId: "union",
},
coinGeckoId: "union"
}
],
gasPriceStep: {
low: 0.0025,
average: 0.025,
high: 0.04,
high: 0.04
},
stakeCurrency: {
coinDenom: "UNO",
coinMinimalDenom: "muno",
coinDecimals: 6,
coinGeckoId: "union",
coinGeckoId: "union"
},
theme: {
primaryColor: '#fff',
gradient:
'linear-gradient(180deg, rgba(255, 255, 255, 0.32) 0%, rgba(255, 255, 255, 0) 100%)',
primaryColor: "#fff",
gradient: "linear-gradient(180deg, rgba(255, 255, 255, 0.32) 0%, rgba(255, 255, 255, 0) 100%)"
},
image: "https://raw.githubusercontent.com/cosmos/chain-registry/master/testnets/uniontestnet/images/union.png",
image:
"https://raw.githubusercontent.com/cosmos/chain-registry/master/testnets/uniontestnet/images/union.png"
}
38 changes: 18 additions & 20 deletions app/src/lib/wallet/cosmos/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {get} from "svelte/store"
import {sleep} from "$lib/utilities/index.ts"
import {persisted} from "svelte-persisted-store"
import type {ChainWalletStore} from "$lib/wallet/types"
import {keplrChainInfo, leapChainInfo} from "$lib/wallet/cosmos/chain-info.ts";
import { get } from "svelte/store"
import { sleep } from "$lib/utilities/index.ts"
import { persisted } from "svelte-persisted-store"
import type { ChainWalletStore } from "$lib/wallet/types"
import { keplrChainInfo, leapChainInfo } from "$lib/wallet/cosmos/chain-info.ts"

export const cosmosWalletsInformation = [
{
Expand Down Expand Up @@ -33,7 +33,7 @@ function createCosmosStore(
}
) {
console.log("[cosmosStore] previousState", previousState)
const {subscribe, set, update} = persisted("cosmos-store", previousState, {
const { subscribe, set, update } = persisted("cosmos-store", previousState, {
syncTabs: true,
storage: "session"
})
Expand All @@ -43,26 +43,26 @@ function createCosmosStore(
subscribe,
connect: async (walletId: string) => {
if (!walletId || (walletId !== "keplr" && walletId !== "leap")) return
update(v => ({...v, connectionStatus: "connecting", connectedWallet: walletId}))
const walletApi = window[walletId];
update(v => ({ ...v, connectionStatus: "connecting", connectedWallet: walletId }))
const walletApi = window[walletId]
if (!walletApi) {
alert(`Please install ${walletId} wallet`)
return update(v => ({...v, connectionStatus: "disconnected"}))
return update(v => ({ ...v, connectionStatus: "disconnected" }))
}
const chainInfoMap = {
keplr: keplrChainInfo,
leap: leapChainInfo
};
const chainInfo = chainInfoMap[walletId];
}
const chainInfo = chainInfoMap[walletId]
if (!chainInfo) {
alert('Chain information is missing for the selected wallet.');
return update(v => ({...v, connectionStatus: "disconnected"}));
alert("Chain information is missing for the selected wallet.")
return update(v => ({ ...v, connectionStatus: "disconnected" }))
}
try {
await walletApi.experimentalSuggestChain(chainInfo);
await walletApi.experimentalSuggestChain(chainInfo)
await walletApi.enable(["union-testnet-8"])
} catch (e) {
return update(v => ({...v, connectionStatus: "disconnected"}));
return update(v => ({ ...v, connectionStatus: "disconnected" }))
}
const account = await walletApi.getKey("union-testnet-8")
update(v => ({
Expand All @@ -74,21 +74,19 @@ function createCosmosStore(
await sleep(2_000)
},
disconnect: async () => {
const cosmosWalletId = get({subscribe}).connectedWallet as CosmosWalletId
console.log({cosmosWalletId})
const cosmosWalletId = get({ subscribe }).connectedWallet as CosmosWalletId
console.log("[cosmos] cosmosDisconnectClick", get(cosmosStore))
if (cosmosWalletId && cosmosWalletId === "keplr" && window[cosmosWalletId]) {
await window[cosmosWalletId]?.disable("union-testnet-8")
update(v => ({...v, connectedWallet: "none", connectionStatus: "disconnected"}))
update(v => ({ ...v, connectedWallet: "none", connectionStatus: "disconnected" }))
}
if (cosmosWalletId && cosmosWalletId === "leap" && window[cosmosWalletId]) {
await window[cosmosWalletId]?.disconnect("union-testnet-8")
update(v => ({...v, connectedWallet: "none", connectionStatus: "disconnected"}))
update(v => ({ ...v, connectedWallet: "none", connectionStatus: "disconnected" }))
}
}
}
}

export const cosmosStore = createCosmosStore()
// cosmosStore.subscribe(value => localStorage.setItem("cosmos-config", JSON.stringify(value)))

7 changes: 7 additions & 0 deletions dictionary.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

0xbonlulu
0xc0dejug
0xkaiserkarel
Expand Down Expand Up @@ -1076,8 +1077,14 @@ unionmodule
unionmodulekeeper
unionmoduletypes
unionp
unionpub
unionsimulation
unionstaking
uniontestnet
unionvalcons
unionvalconspub
unionvaloper
unionvaloperpub
unionvisor
unittests
unjail
Expand Down

0 comments on commit cce6062

Please sign in to comment.