Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
Update Chain handling (#2527)
Browse files Browse the repository at this point in the history
  • Loading branch information
veado authored Jan 18, 2023
1 parent ec0c1c2 commit 60156fb
Show file tree
Hide file tree
Showing 152 changed files with 510 additions and 423 deletions.
3 changes: 2 additions & 1 deletion scripts/generateERC20Whitelist.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Asset, assetFromString, ETHChain } from '@xchainjs/xchain-util'
import { Asset, assetFromString } from '@xchainjs/xchain-util'
import ansis from 'ansis'
import axios from 'axios'
import * as IO from 'fp-ts/IO'
Expand All @@ -15,6 +15,7 @@ import prettier from 'prettier'

import { writeFile, readFile } from '../src/main/utils/file'
import { ERC20Whitelist, erc20WhitelistIO } from '../src/renderer/services/thorchain/types'
import { ETHChain } from '../src/shared/utils/chain'

const WHITELIST_URL =
'https://gitlab.com/thorchain/thornode/-/raw/release-1.97.2/common/tokenlist/ethtokens/eth_mainnet_V97.json'
Expand Down
8 changes: 4 additions & 4 deletions src/main/api/ledger/address.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import TransportNodeHidSingleton from '@ledgerhq/hw-transport-node-hid-singleton'
import * as E from 'fp-ts/Either'

import { IPCLedgerAdddressParams, LedgerError, LedgerErrorId } from '../../../shared/api/types'
import {
BCHChain,
BNBChain,
Expand All @@ -8,10 +11,7 @@ import {
ETHChain,
LTCChain,
THORChain
} from '@xchainjs/xchain-util'
import * as E from 'fp-ts/Either'

import { IPCLedgerAdddressParams, LedgerError, LedgerErrorId } from '../../../shared/api/types'
} from '../../../shared/utils/chain'
import { isError, isEthHDMode } from '../../../shared/utils/guard'
import { WalletAddress } from '../../../shared/wallet/types'
import { getAddress as getBNBAddress, verifyAddress as verifyBNBAddress } from './binance/address'
Expand Down
2 changes: 1 addition & 1 deletion src/main/api/ledger/binance/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { crypto } from '@binance-chain/javascript-sdk'
import AppBNB from '@binance-chain/javascript-sdk/lib/ledger/ledger-app'
import type Transport from '@ledgerhq/hw-transport'
import { getDerivePath, getPrefix } from '@xchainjs/xchain-binance'
import { BNBChain } from '@xchainjs/xchain-util'
import * as E from 'fp-ts/Either'

import { LedgerError, LedgerErrorId, Network } from '../../../../shared/api/types'
import { BNBChain } from '../../../../shared/utils/chain'
import { toClientNetwork } from '../../../../shared/utils/client'
import { isError } from '../../../../shared/utils/guard'
import { WalletAddress } from '../../../../shared/wallet/types'
Expand Down
2 changes: 1 addition & 1 deletion src/main/api/ledger/bitcoin/address.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import AppBTC from '@ledgerhq/hw-app-btc'
import type Transport from '@ledgerhq/hw-transport'
import { BTCChain } from '@xchainjs/xchain-util'
import * as E from 'fp-ts/Either'

import { LedgerError, LedgerErrorId, Network } from '../../../../shared/api/types'
import { BTCChain } from '../../../../shared/utils/chain'
import { toClientNetwork } from '../../../../shared/utils/client'
import { isError } from '../../../../shared/utils/guard'
import { WalletAddress } from '../../../../shared/wallet/types'
Expand Down
2 changes: 1 addition & 1 deletion src/main/api/ledger/bitcoincash/address.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import AppBTC from '@ledgerhq/hw-app-btc'
import type Transport from '@ledgerhq/hw-transport'
import { BCHChain } from '@xchainjs/xchain-util'
import * as E from 'fp-ts/Either'

import { LedgerError, LedgerErrorId, Network } from '../../../../shared/api/types'
import { BCHChain } from '../../../../shared/utils/chain'
import { toClientNetwork } from '../../../../shared/utils/client'
import { isError } from '../../../../shared/utils/guard'
import { WalletAddress } from '../../../../shared/wallet/types'
Expand Down
2 changes: 1 addition & 1 deletion src/main/api/ledger/cosmos/address.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import CosmosApp from '@ledgerhq/hw-app-cosmos'
import type Transport from '@ledgerhq/hw-transport'
import { CosmosChain } from '@xchainjs/xchain-util'
import * as E from 'fp-ts/Either'

import { LedgerError, LedgerErrorId } from '../../../../shared/api/types'
import { CosmosChain } from '../../../../shared/utils/chain'
import { isError } from '../../../../shared/utils/guard'
import { WalletAddress } from '../../../../shared/wallet/types'
import { getDerivationPath } from './common'
Expand Down
2 changes: 1 addition & 1 deletion src/main/api/ledger/doge/address.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import AppBTC from '@ledgerhq/hw-app-btc'
import type Transport from '@ledgerhq/hw-transport'
import { DOGEChain } from '@xchainjs/xchain-util'
import * as E from 'fp-ts/Either'

import { LedgerError, LedgerErrorId, Network } from '../../../../shared/api/types'
import { DOGEChain } from '../../../../shared/utils/chain'
import { toClientNetwork } from '../../../../shared/utils/client'
import { isError } from '../../../../shared/utils/guard'
import { WalletAddress } from '../../../../shared/wallet/types'
Expand Down
2 changes: 1 addition & 1 deletion src/main/api/ledger/ethereum/address.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import EthApp from '@ledgerhq/hw-app-eth'
import type Transport from '@ledgerhq/hw-transport'
import { ETHChain } from '@xchainjs/xchain-util'
import * as E from 'fp-ts/Either'

import { LedgerError, LedgerErrorId } from '../../../../shared/api/types'
import { getDerivationPath } from '../../../../shared/ethereum/ledger'
import { EthHDMode } from '../../../../shared/ethereum/types'
import { ETHChain } from '../../../../shared/utils/chain'
import { isError } from '../../../../shared/utils/guard'
import { WalletAddress } from '../../../../shared/wallet/types'

Expand Down
2 changes: 1 addition & 1 deletion src/main/api/ledger/litecoin/address.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import AppBTC from '@ledgerhq/hw-app-btc'
import type Transport from '@ledgerhq/hw-transport'
import { LTCChain } from '@xchainjs/xchain-util'
import * as E from 'fp-ts/Either'

import { LedgerError, LedgerErrorId, Network } from '../../../../shared/api/types'
import { LTCChain } from '../../../../shared/utils/chain'
import { toClientNetwork } from '../../../../shared/utils/client'
import { isError } from '../../../../shared/utils/guard'
import { WalletAddress } from '../../../../shared/wallet/types'
Expand Down
2 changes: 1 addition & 1 deletion src/main/api/ledger/thorchain/address.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type Transport from '@ledgerhq/hw-transport'
import THORChainApp, { LedgerErrorType } from '@thorchain/ledger-thorchain'
import { getPrefix } from '@xchainjs/xchain-thorchain'
import { THORChain } from '@xchainjs/xchain-util'
import * as E from 'fp-ts/Either'

import { LedgerError, LedgerErrorId, Network } from '../../../../shared/api/types'
import { THORChain } from '../../../../shared/utils/chain'
import { toClientNetwork } from '../../../../shared/utils/client'
import { isError } from '../../../../shared/utils/guard'
import { WalletAddress } from '../../../../shared/wallet/types'
Expand Down
10 changes: 5 additions & 5 deletions src/main/api/ledger/transaction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import TransportNodeHidSingleton from '@ledgerhq/hw-transport-node-hid-singleton'
import { TxHash } from '@xchainjs/xchain-client'
import * as E from 'fp-ts/Either'

import { IPCLedgerDepositTxParams, IPCLedgerSendTxParams } from '../../../shared/api/io'
import { LedgerError, LedgerErrorId } from '../../../shared/api/types'
import {
BCHChain,
BNBChain,
Expand All @@ -10,11 +14,7 @@ import {
ETHChain,
LTCChain,
THORChain
} from '@xchainjs/xchain-util'
import * as E from 'fp-ts/Either'

import { IPCLedgerDepositTxParams, IPCLedgerSendTxParams } from '../../../shared/api/io'
import { LedgerError, LedgerErrorId } from '../../../shared/api/types'
} from '../../../shared/utils/chain'
import { isError, isEthHDMode } from '../../../shared/utils/guard'
import * as BNB from './binance/transaction'
import * as BTC from './bitcoin/transaction'
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/components/Bonds/table/helpers.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react'

import { StopOutlined } from '@ant-design/icons'
import { Address, AssetRuneNative, baseToAsset, formatAssetAmountCurrency, THORChain } from '@xchainjs/xchain-util'
import { Address, AssetRuneNative, baseToAsset, formatAssetAmountCurrency } from '@xchainjs/xchain-util'
import { Col } from 'antd'
import { useIntl } from 'react-intl'

import { Network } from '../../../../shared/api/types'
import { THORChain } from '../../../../shared/utils/chain'
import { NodeInfo } from '../../../services/thorchain/types'
import { NodeStatusEnum } from '../../../types/generated/thornode'
import * as Styled from './BondsTable.styles'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/PoolShares/PoolShares.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
AssetRuneNative,
baseAmount,
baseToAsset,
Chain,
formatAssetAmountCurrency,
formatBN
} from '@xchainjs/xchain-util'
Expand All @@ -15,6 +14,7 @@ import * as FP from 'fp-ts/lib/function'
import { useIntl } from 'react-intl'

import { Network } from '../../../shared/api/types'
import { Chain } from '../../../shared/utils/chain'
import * as PoolHelpers from '../../helpers/poolHelper'
import { MimirHalt } from '../../services/thorchain/types'
import { AssetLabel } from '../uielements/assets/assetLabel'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/deposit/Deposit.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useMemo } from 'react'

import * as RD from '@devexperts/remote-data-ts'
import { Chain } from '@xchainjs/xchain-util'
import { Grid } from 'antd'
import * as FP from 'fp-ts/function'
import * as O from 'fp-ts/Option'
import { useIntl } from 'react-intl'

import { Chain } from '../../../shared/utils/chain'
import { WalletAddress } from '../../../shared/wallet/types'
import { eqAddress, eqOAddress } from '../../helpers/fp/eq'
import { PoolDetailRD, PoolShareRD, PoolSharesRD } from '../../services/midgard/types'
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/components/deposit/add/Deposit.helper.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as RD from '@devexperts/remote-data-ts'
import { PoolData } from '@thorchain/asgardex-util'
import { Asset, baseAmount, BaseAmount, Chain } from '@xchainjs/xchain-util'
import { Asset, baseAmount, BaseAmount } from '@xchainjs/xchain-util'
import BigNumber from 'bignumber.js'
import * as E from 'fp-ts/Either'
import * as FP from 'fp-ts/function'
import * as A from 'fp-ts/lib/Array'
import * as O from 'fp-ts/Option'

import { Chain } from '../../../../shared/utils/chain'
import { SUPPORTED_LEDGER_APPS, ZERO_BASE_AMOUNT } from '../../../const'
import {
convertBaseAmountDecimal,
Expand Down
5 changes: 2 additions & 3 deletions src/renderer/components/deposit/add/SymDeposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ import {
baseAmount,
BaseAmount,
baseToAsset,
chainToString,
formatAssetAmountCurrency,
isAssetRuneNative,
THORChain
isAssetRuneNative
} from '@xchainjs/xchain-util'
import BigNumber from 'bignumber.js'
import * as A from 'fp-ts/lib/Array'
Expand All @@ -27,6 +25,7 @@ import { useIntl } from 'react-intl'
import * as RxOp from 'rxjs/operators'

import { Network } from '../../../../shared/api/types'
import { chainToString, THORChain } from '../../../../shared/utils/chain'
import { isLedgerWallet } from '../../../../shared/utils/guard'
import { WalletType } from '../../../../shared/wallet/types'
import { ZERO_ASSET_AMOUNT, ZERO_BASE_AMOUNT } from '../../../const'
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/deposit/withdraw/Withdraw.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import {
assetToBase,
assetToString,
baseAmount,
bn,
BNBChain
bn
} from '@xchainjs/xchain-util'
import * as O from 'fp-ts/lib/Option'
import * as Rx from 'rxjs'
import * as RxOp from 'rxjs/operators'

import { BNB_ADDRESS_TESTNET } from '../../../../shared/mock/address'
import { mockValidatePassword$ } from '../../../../shared/mock/wallet'
import { BNBChain } from '../../../../shared/utils/chain'
import { BNB_DECIMAL, THORCHAIN_DECIMAL } from '../../../helpers/assetHelper'
import { mockWalletAddress } from '../../../helpers/test/testWalletHelper'
import { INITIAL_WITHDRAW_STATE } from '../../../services/chain/const'
Expand Down
5 changes: 2 additions & 3 deletions src/renderer/components/deposit/withdraw/Withdraw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import {
BaseAmount,
baseToAsset,
formatAssetAmount,
Chain,
formatAssetAmountCurrency,
THORChain
formatAssetAmountCurrency
} from '@xchainjs/xchain-util'
import { Col } from 'antd'
import BigNumber from 'bignumber.js'
Expand All @@ -21,6 +19,7 @@ import { useObservableState } from 'observable-hooks'
import { useIntl } from 'react-intl'

import { Network } from '../../../../shared/api/types'
import { Chain, THORChain } from '../../../../shared/utils/chain'
import { isLedgerWallet } from '../../../../shared/utils/guard'
import { WalletAddress } from '../../../../shared/wallet/types'
import { ZERO_BASE_AMOUNT } from '../../../const'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ComponentMeta } from '@storybook/react'
import { Chain } from '@xchainjs/xchain-util'
import * as O from 'fp-ts/lib/Option'

import { Chain } from '../../../../shared/utils/chain'
import { LedgerConfirmationModal } from './'

type Args = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { useCallback, useState } from 'react'

import { isCashAddress, toCashAddress, toLegacyAddress } from '@xchainjs/xchain-bitcoincash'
import { Address, Chain, chainToString } from '@xchainjs/xchain-util'
import { Address } from '@xchainjs/xchain-util'
import * as FP from 'fp-ts/function'
import * as O from 'fp-ts/lib/Option'
import { useIntl } from 'react-intl'

import { Network } from '../../../../shared/api/types'
import { Chain, chainToString } from '../../../../shared/utils/chain'
import { getChainAsset, isBchChain } from '../../../helpers/chainHelper'
import { AttentionIcon } from '../../icons'
import { AddressEllipsis } from '../../uielements/addressEllipsis'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as RD from '@devexperts/remote-data-ts'
import { ComponentMeta } from '@storybook/react'
import { Chain } from '@xchainjs/xchain-util'
import * as Rx from 'rxjs'

import { mockValidatePassword$ } from '../../../../shared/mock/wallet'
import { Chain } from '../../../../shared/utils/chain'
import { WalletPasswordConfirmationModal } from './WalletPasswordConfirmationModal'

type ValidatePasswordVariant = 'initial' | 'pending' | 'failure' | 'success' | 'all'
Expand Down
35 changes: 16 additions & 19 deletions src/renderer/components/settings/WalletSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'

import { SearchOutlined } from '@ant-design/icons'
import * as RD from '@devexperts/remote-data-ts'
import {
Asset,
BNBChain,
THORChain,
ETHChain,
BCHChain,
BTCChain,
LTCChain,
CosmosChain,
Chain,
DOGEChain,
TerraChain,
chainToString,
AVAXChain,
Address
} from '@xchainjs/xchain-util'
import { Asset, Address } from '@xchainjs/xchain-util'
import { List, Collapse, RadioChangeEvent } from 'antd'
import * as FP from 'fp-ts/function'
import * as A from 'fp-ts/lib/Array'
Expand All @@ -28,6 +13,19 @@ import { useNavigate } from 'react-router-dom'
import { KeystoreId, Network } from '../../../shared/api/types'
import { getDerivationPath as getEthDerivationPath } from '../../../shared/ethereum/ledger'
import { EthHDMode } from '../../../shared/ethereum/types'
import {
AvalancheChain,
BCHChain,
BNBChain,
BTCChain,
Chain,
chainToString,
CosmosChain,
DOGEChain,
ETHChain,
LTCChain,
THORChain
} from '../../../shared/utils/chain'
import { isError } from '../../../shared/utils/guard'
import { HDMode, WalletAddress } from '../../../shared/wallet/types'
import { ReactComponent as UnlockOutlined } from '../../assets/svg/icon-unlock-warning.svg'
Expand Down Expand Up @@ -166,9 +164,8 @@ export const WalletSettings: React.FC<Props> = (props): JSX.Element => {
[THORChain]: 0,
[ETHChain]: 0,
[CosmosChain]: 0,
[AVAXChain]: 0, // not supported in ASGDX yet, but part of xchain-util
[DOGEChain]: 0,
[TerraChain]: 0 // not supported in ASGDX anymore, but part of xchain-util
[AvalancheChain]: 0, // not supported in ASGDX yet, but part of xchain-util
[DOGEChain]: 0
})

const {
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/swap/Swap.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import {
assetToBase,
assetToString,
baseAmount,
bn,
BNBChain
bn
} from '@xchainjs/xchain-util'
import * as O from 'fp-ts/lib/Option'
import * as Rx from 'rxjs'
import * as RxOp from 'rxjs/operators'

import { mockValidatePassword$ } from '../../../shared/mock/wallet'
import { BNBChain } from '../../../shared/utils/chain'
import { ONE_BN } from '../../const'
import { THORCHAIN_DECIMAL } from '../../helpers/assetHelper'
import { RUNE_PRICE_POOL } from '../../helpers/poolHelper'
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/swap/Swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
delay,
assetToBase,
assetAmount,
chainToString,
Address
} from '@xchainjs/xchain-util'
import BigNumber from 'bignumber.js'
Expand All @@ -32,6 +31,7 @@ import { useIntl } from 'react-intl'
import * as RxOp from 'rxjs/operators'

import { Network } from '../../../shared/api/types'
import { chainToString } from '../../../shared/utils/chain'
import { isLedgerWallet } from '../../../shared/utils/guard'
import { WalletType } from '../../../shared/wallet/types'
import { ZERO_BASE_AMOUNT } from '../../const'
Expand Down
Loading

0 comments on commit 60156fb

Please sign in to comment.