From 1eea9fbab39876c2d68bd03e29d8710b24699ea1 Mon Sep 17 00:00:00 2001
From: veado <61792675+veado@users.noreply.github.com>
Date: Mon, 13 Jun 2022 18:56:21 +0200
Subject: [PATCH] Enable `GAIA.*` pools (#2290)
---
.env.sample | 2 +-
CHANGELOG.md | 8 +-
src/renderer/assets/svg/asset-atom.svg | 85 +++++++++++++++++++
src/renderer/components/icons/index.ts | 2 +
.../assets/assetData/AssetData.styles.tsx | 4 +-
.../uielements/assets/assetIcon/AssetIcon.tsx | 11 ++-
.../assets/assetLabel/AssetLabel.styles.ts | 2 +-
.../uielements/label/Label.styles.ts | 6 +-
.../assets/AssetsTableCollapsable.styles.ts | 2 +-
src/renderer/helpers/assetHelper.test.ts | 4 +
src/renderer/helpers/assetHelper.ts | 6 ++
src/renderer/helpers/chainHelper.ts | 3 +-
src/renderer/services/chain/address.ts | 2 +-
src/renderer/services/chain/client.ts | 4 +
.../services/chain/transaction/common.ts | 3 +-
src/renderer/services/const.ts | 2 +-
src/renderer/services/wallet/balances.ts | 7 ++
17 files changed, 137 insertions(+), 16 deletions(-)
create mode 100644 src/renderer/assets/svg/asset-atom.svg
diff --git a/.env.sample b/.env.sample
index 118cdb8d3..18342c28f 100644
--- a/.env.sample
+++ b/.env.sample
@@ -1,7 +1,7 @@
# ASGARDEX
REACT_APP_DEFAULT_NETWORK=mainnet
# Chains enabled development mode
-REACT_APP_CHAINS_ENABLED=THOR,BNB,BTC,LTC,BCH,ETH
+REACT_APP_CHAINS_ENABLED=THOR,BNB,BTC,LTC,BCH,ETH,DOGE,GAIA
# Midgard
REACT_APP_MIDGARD_TESTNET_URL=https://testnet.midgard.thorchain.info
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d7d3ca964..6cd81a5f0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,8 +1,12 @@
-# 0.xx.x (2022-xx-xx)
+# 0.16.0 (2022-xx-xx)
+
+## ADD
+
+- Support Terra [#2002](https://github.com/thorchain/asgardex-electron/issues/2002), [#2193](https://github.com/thorchain/asgardex-electron/pull/2193), [#2290](https://github.com/thorchain/asgardex-electron/pull/2290)
## Update
-- [Pools] Toggle filter buttons to remove clear button
+- [Pools] Toggle filter buttons to remove clear button [#2287](https://github.com/thorchain/asgardex-electron/pull/2287)
# 0.15.2 (2022-06-06)
diff --git a/src/renderer/assets/svg/asset-atom.svg b/src/renderer/assets/svg/asset-atom.svg
new file mode 100644
index 000000000..26782420b
--- /dev/null
+++ b/src/renderer/assets/svg/asset-atom.svg
@@ -0,0 +1,85 @@
+
+
diff --git a/src/renderer/components/icons/index.ts b/src/renderer/components/icons/index.ts
index f6e4e0d1e..6a6ac60d0 100644
--- a/src/renderer/components/icons/index.ts
+++ b/src/renderer/components/icons/index.ts
@@ -7,6 +7,7 @@ import arrowGreenIcon from '../../assets/svg/asset-arrow-green.svg'
import greyArrowIcon from '../../assets/svg/asset-arrow-grey.svg'
import arrowTwoIcon from '../../assets/svg/asset-arrow-twoway.svg'
import arrowYellowIcon from '../../assets/svg/asset-arrow-yello.svg'
+import atomIcon from '../../assets/svg/asset-atom.svg'
import bnbRuneIcon from '../../assets/svg/asset-bnb-rune.svg'
import bnbIcon from '../../assets/svg/asset-bnb.svg'
import btcIcon from '../../assets/svg/asset-btc.svg'
@@ -29,6 +30,7 @@ import orbGreenIcon from '../../assets/svg/orb-green.svg'
import terraIcon from '../../assets/svg/terra.svg'
export {
+ atomIcon,
bnbIcon,
btcIcon,
dogeIcon,
diff --git a/src/renderer/components/uielements/assets/assetData/AssetData.styles.tsx b/src/renderer/components/uielements/assets/assetData/AssetData.styles.tsx
index 3af3c84c3..6bceb64e7 100644
--- a/src/renderer/components/uielements/assets/assetData/AssetData.styles.tsx
+++ b/src/renderer/components/uielements/assets/assetData/AssetData.styles.tsx
@@ -23,7 +23,7 @@ export const AssetIcon = styled(UIAssetIcon)``
export const TickerLabel = styled(UILabel).attrs({
textTransform: 'uppercase',
- weight: '600'
+ weight: 'bold'
})`
height: 18px;
padding: 0px 16px 0px 11px;
@@ -39,7 +39,7 @@ export const ChainLabel = styled(TickerLabel)`
export const AmountLabel = styled(UILabel).attrs({
textTransform: 'uppercase',
- weight: '600'
+ weight: 'bold'
})`
font-family: 'MainFontRegular';
padding-left: 10px;
diff --git a/src/renderer/components/uielements/assets/assetIcon/AssetIcon.tsx b/src/renderer/components/uielements/assets/assetIcon/AssetIcon.tsx
index 3e9d86790..559b51331 100644
--- a/src/renderer/components/uielements/assets/assetIcon/AssetIcon.tsx
+++ b/src/renderer/components/uielements/assets/assetIcon/AssetIcon.tsx
@@ -22,7 +22,8 @@ import {
isRuneBnbAsset,
isRuneNativeAsset,
isTgtERC20Asset,
- isXRuneAsset
+ isXRuneAsset,
+ isAtomAsset
} from '../../../../helpers/assetHelper'
import { isBnbChain, isEthChain } from '../../../../helpers/chainHelper'
import { getIntFromName, rainbowStop } from '../../../../helpers/colorHelpers'
@@ -37,7 +38,8 @@ import {
xRuneIcon,
tgtIcon,
lunaIcon,
- ustIcon
+ ustIcon,
+ atomIcon
} from '../../../icons'
import * as Styled from './AssetIcon.styles'
import { Size } from './AssetIcon.types'
@@ -96,6 +98,11 @@ export const AssetIcon: React.FC = ({ asset, size = 'normal', className =
return dogeIcon
}
+ // Atom
+ if (isAtomAsset(asset)) {
+ return atomIcon
+ }
+
// LUNA
if (isLunaAsset(asset)) {
return lunaIcon
diff --git a/src/renderer/components/uielements/assets/assetLabel/AssetLabel.styles.ts b/src/renderer/components/uielements/assets/assetLabel/AssetLabel.styles.ts
index 851134067..11d804ade 100644
--- a/src/renderer/components/uielements/assets/assetLabel/AssetLabel.styles.ts
+++ b/src/renderer/components/uielements/assets/assetLabel/AssetLabel.styles.ts
@@ -19,7 +19,7 @@ export const Wrapper = styled(Row).attrs({
export const TickerLabel = styled(UILabel).attrs({
textTransform: 'uppercase',
- weight: '600'
+ weight: 'bold'
})`
height: 18px;
padding: 0px 16px 0px 11px;
diff --git a/src/renderer/components/uielements/label/Label.styles.ts b/src/renderer/components/uielements/label/Label.styles.ts
index 3bcea49de..f45d5b4d8 100644
--- a/src/renderer/components/uielements/label/Label.styles.ts
+++ b/src/renderer/components/uielements/label/Label.styles.ts
@@ -11,7 +11,7 @@ export type Props = {
size?: Size
color?: Color
disabled?: boolean
- weight?: string
+ weight?: 'normal' | 'bold'
textTransform?: TextTransform
nowrap?: boolean
onClick?: (_: React.MouseEvent) => void
@@ -55,12 +55,12 @@ const colors: Colors = {
}
export const LabelWrapper = styled.div`
- padding: 10px 0;
+ padding: 0;
width: 100%;
white-space: ${({ nowrap = false }) => (nowrap ? 'nowrap' : 'normal')};
font-size: ${({ size = 'normal' }) => fontSettings[size].size};
text-transform: ${({ textTransform = 'none' }) => textTransform};
- font-weight: ${({ weight }) => weight};
+ font-family: ${({ weight }) => (weight === 'bold' ? 'MainFontBold' : 'MainFontRegular')};
letter-spacing: ${({ size = 'normal' }) => fontSettings[size].spacing};
color: ${({ color }) => colors[color || 'normal']};
opacity: ${({ disabled }) => (disabled ? 0.5 : 1)};
diff --git a/src/renderer/components/wallet/assets/AssetsTableCollapsable.styles.ts b/src/renderer/components/wallet/assets/AssetsTableCollapsable.styles.ts
index 7824e3407..8177f2d17 100644
--- a/src/renderer/components/wallet/assets/AssetsTableCollapsable.styles.ts
+++ b/src/renderer/components/wallet/assets/AssetsTableCollapsable.styles.ts
@@ -58,7 +58,7 @@ export const Label = styled(UILabel)`
export const TickerLabel = styled(UILabel).attrs({
textTransform: 'uppercase',
- weight: '600'
+ weight: 'bold'
})`
padding: 0px;
font-size: 16px;
diff --git a/src/renderer/helpers/assetHelper.test.ts b/src/renderer/helpers/assetHelper.test.ts
index 6a635e040..cc75f3ff9 100644
--- a/src/renderer/helpers/assetHelper.test.ts
+++ b/src/renderer/helpers/assetHelper.test.ts
@@ -1,3 +1,4 @@
+import { AssetAtom } from '@xchainjs/xchain-cosmos'
import { ETHAddress } from '@xchainjs/xchain-ethereum'
import { AssetLUNA } from '@xchainjs/xchain-terra'
import {
@@ -328,6 +329,9 @@ describe('helpers/assetHelper', () => {
it('UST', () => {
expect(isChainAsset(AssetUST)).toBeFalsy()
})
+ it('ATOM', () => {
+ expect(isChainAsset(AssetAtom)).toBeTruthy()
+ })
})
describe('isUSDAsset', () => {
diff --git a/src/renderer/helpers/assetHelper.ts b/src/renderer/helpers/assetHelper.ts
index c83928d79..a634b598e 100644
--- a/src/renderer/helpers/assetHelper.ts
+++ b/src/renderer/helpers/assetHelper.ts
@@ -1,4 +1,5 @@
import { Address } from '@xchainjs/xchain-client'
+import { AssetAtom } from '@xchainjs/xchain-cosmos'
import { ETHAddress, getTokenAddress } from '@xchainjs/xchain-ethereum'
import { AssetLUNA } from '@xchainjs/xchain-terra'
import {
@@ -133,6 +134,11 @@ export const isLunaAsset = (asset: Asset): boolean => eqAsset.equals(asset, Asse
*/
export const isUstAsset = (asset: Asset): boolean => eqAsset.equals(asset, AssetUST)
+/**
+ * Check whether an asset is a ATOM asset
+ */
+export const isAtomAsset = (asset: Asset): boolean => eqAsset.equals(asset, AssetAtom)
+
/**
* Check whether an ERC20 asset is white listed or not
*/
diff --git a/src/renderer/helpers/chainHelper.ts b/src/renderer/helpers/chainHelper.ts
index 32fe7fcf0..4885adec3 100644
--- a/src/renderer/helpers/chainHelper.ts
+++ b/src/renderer/helpers/chainHelper.ts
@@ -1,3 +1,4 @@
+import { AssetAtom } from '@xchainjs/xchain-cosmos'
import { AssetLUNA } from '@xchainjs/xchain-terra'
import {
Asset,
@@ -36,7 +37,7 @@ export const getChainAsset = (chain: Chain): Asset => {
case THORChain:
return AssetRuneNative
case CosmosChain:
- throw Error('Cosmos is not supported yet')
+ return AssetAtom
case BCHChain:
return AssetBCH
case LTCChain:
diff --git a/src/renderer/services/chain/address.ts b/src/renderer/services/chain/address.ts
index 5273213c6..a5baa0932 100644
--- a/src/renderer/services/chain/address.ts
+++ b/src/renderer/services/chain/address.ts
@@ -45,7 +45,7 @@ const addressByChain$ = (chain: Chain): WalletAddress$ => {
// not supported yet
return Rx.of(O.none)
case CosmosChain:
- // not supported yet
+ // TODO (@veado) Implement Cosmos
return Rx.of(O.none)
case BCHChain:
return BCH.address$
diff --git a/src/renderer/services/chain/client.ts b/src/renderer/services/chain/client.ts
index 46d9a34bb..4baba8c0d 100644
--- a/src/renderer/services/chain/client.ts
+++ b/src/renderer/services/chain/client.ts
@@ -3,6 +3,7 @@ import {
BNBChain,
BTCChain,
Chain,
+ CosmosChain,
DOGEChain,
ETHChain,
LTCChain,
@@ -43,6 +44,9 @@ export const clientByChain$ = (chain: Chain): XChainClient$ => {
return DOGE.client$
case TerraChain:
return TERRA.client$
+ case CosmosChain:
+ // TODO (@veado) Implement Cosmos
+ return Rx.of(O.none)
default:
return Rx.of(O.none)
}
diff --git a/src/renderer/services/chain/transaction/common.ts b/src/renderer/services/chain/transaction/common.ts
index 0e0674c75..8a995f01c 100644
--- a/src/renderer/services/chain/transaction/common.ts
+++ b/src/renderer/services/chain/transaction/common.ts
@@ -75,7 +75,7 @@ export const sendTx$ = ({
return THOR.sendTx({ walletType, amount, asset, memo, recipient, walletIndex })
case CosmosChain:
- // not available yet
+ // TODO (@veado) Implement Cosmos
return txFailure$(`sendTx$ has not been implemented for Cosmos yet`)
case PolkadotChain:
@@ -182,6 +182,7 @@ export const txStatusByChain$ = ({ txHash, chain }: { txHash: TxHash; chain: Cha
case THORChain:
return THOR.txStatus$(txHash, O.none)
case CosmosChain:
+ // TODO (@veado) Implement Cosmos
return txStatusFailure$(`txStatusByChain$ has not been implemented for Cosmos`)
case PolkadotChain:
return txStatusFailure$(`txStatusByChain$ has not been implemented for Polkadot`)
diff --git a/src/renderer/services/const.ts b/src/renderer/services/const.ts
index 3dc565027..2112bb00a 100644
--- a/src/renderer/services/const.ts
+++ b/src/renderer/services/const.ts
@@ -14,7 +14,7 @@ export const AVAILABLE_NETWORKS: Network[] = ['testnet', 'stagenet', 'mainnet']
export const ENABLED_CHAINS: Chain[] = envOrDefault(
process.env.REACT_APP_CHAINS_ENABLED,
- 'THOR,BNB,BTC,LTC,BCH,ETH,DOGE,TERRA'
+ 'THOR,BNB,BTC,LTC,BCH,ETH,DOGE,TERRA,GAIA'
)
.replace(/\s/g, '')
.split(',')
diff --git a/src/renderer/services/wallet/balances.ts b/src/renderer/services/wallet/balances.ts
index 1db3d854f..2668b4550 100644
--- a/src/renderer/services/wallet/balances.ts
+++ b/src/renderer/services/wallet/balances.ts
@@ -73,6 +73,8 @@ export const createBalancesService = ({
LTC.reloadBalances()
DOGE.reloadBalances()
TERRA.reloadBalances()
+ // TODO (@veado) Implement Cosmos
+ // GAIA.reloadBalances()
}
// Returns lazy functions to reload balances by given chain
@@ -95,6 +97,7 @@ export const createBalancesService = ({
case TerraChain:
return TERRA.reloadBalances
case CosmosChain:
+ // TODO (@veado) Implement Cosmos
return FP.constVoid
case PolkadotChain:
return FP.constVoid
@@ -175,6 +178,8 @@ export const createBalancesService = ({
balances$: TERRA.balances$(walletType, walletIndex),
reloadBalances$: TERRA.reloadBalances$
}
+ // TODO (@veado) Implement Cosmos
+ // case CosmosChain:
default:
return {
reloadBalances: FP.constVoid,
@@ -580,6 +585,8 @@ export const createBalancesService = ({
LTC: [ltcBalance$, ltcLedgerChainBalance$],
DOGE: [dogeChainBalance$, dogeLedgerChainBalance$],
TERRA: [terraChainBalance$, terraLedgerChainBalance$]
+ // TODO (@veado) Implement Cosmos
+ // GAIA: [cosmosChainBalance$, cosmosLedgerChainBalance$]
})
),
// we ignore all `ChainBalances` with state of `initial` balances