Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dash client bug #393

Merged
merged 7 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,39 +83,38 @@
"@ledgerhq/hw-transport-node-hid-singleton": "^6.30.1",
"@storybook/addon-viewport": "^8.1.4",
"@types/electron-devtools-installer": "^2.2.2",
"@xchainjs/xchain-arbitrum": "1.0.9",
"@xchainjs/xchain-avax": "1.0.9",
"@xchainjs/xchain-bitcoin": "1.0.2",
"@xchainjs/xchain-bitcoincash": "1.0.2",
"@xchainjs/xchain-bsc": "1.0.9",
"@xchainjs/xchain-client": "1.0.5",
"@xchainjs/xchain-cosmos": "2.0.5",
"@xchainjs/xchain-crypto": "0.3.4",
"@xchainjs/xchain-dash": "1.0.2",
"@xchainjs/xchain-doge": "1.0.2",
"@xchainjs/xchain-ethereum": "1.0.9",
"@xchainjs/xchain-evm": "1.0.9",
"@xchainjs/xchain-evm-providers": "1.0.7",
"@xchainjs/xchain-kujira": "1.0.2",
"@xchainjs/xchain-litecoin": "1.0.2",
"@xchainjs/xchain-mayachain": "2.0.3",
"@xchainjs/xchain-mayachain-query": "1.0.4",
"@xchainjs/xchain-mayamidgard": "0.1.6",
"@xchainjs/xchain-mayamidgard-query": "0.1.19",
"@xchainjs/xchain-mayanode": "0.1.9",
"@xchainjs/xchain-midgard": "0.5.9",
"@xchainjs/xchain-midgard-query": "1.0.2",
"@xchainjs/xchain-radix": "1.1.2",
"@xchainjs/xchain-thorchain": "2.0.3",
"@xchainjs/xchain-thorchain-query": "1.0.3",
"@xchainjs/xchain-thornode": "0.3.19",
"@xchainjs/xchain-util": "1.0.2",
"@xchainjs/xchain-utxo": "1.0.2",
"@xchainjs/xchain-utxo-providers": "1.0.2",
"@xchainjs/xchain-arbitrum": "1.0.11",
"@xchainjs/xchain-avax": "1.0.10",
"@xchainjs/xchain-bitcoin": "1.1.2",
"@xchainjs/xchain-bitcoincash": "1.0.6",
"@xchainjs/xchain-bsc": "1.0.10",
"@xchainjs/xchain-client": "1.0.6",
"@xchainjs/xchain-cosmos": "2.0.8",
"@xchainjs/xchain-crypto": "0.3.5",
"@xchainjs/xchain-dash": "1.0.6",
"@xchainjs/xchain-doge": "1.0.6",
"@xchainjs/xchain-ethereum": "1.0.10",
"@xchainjs/xchain-evm": "1.0.10",
"@xchainjs/xchain-evm-providers": "1.0.8",
"@xchainjs/xchain-kujira": "1.0.7",
"@xchainjs/xchain-litecoin": "1.0.6",
"@xchainjs/xchain-mayachain": "2.0.7",
"@xchainjs/xchain-mayachain-query": "1.0.7",
"@xchainjs/xchain-mayamidgard": "0.1.7",
"@xchainjs/xchain-mayamidgard-query": "0.1.22",
"@xchainjs/xchain-mayanode": "0.1.10",
"@xchainjs/xchain-midgard": "0.5.10",
"@xchainjs/xchain-midgard-query": "1.0.6",
"@xchainjs/xchain-radix": "1.1.4",
"@xchainjs/xchain-thorchain": "2.0.8",
"@xchainjs/xchain-thorchain-query": "1.0.6",
"@xchainjs/xchain-thornode": "0.3.20",
"@xchainjs/xchain-util": "1.0.5",
"@xchainjs/xchain-utxo": "1.0.6",
"@xchainjs/xchain-utxo-providers": "1.0.6",
"antd": "^4.20.7",
"axios": "1.7.5",
"babel-loader": "^9.2.1",
"bignumber.js": "9.0.0",
"chart.js": "^3.8.0",
"clsx": "^2.1.1",
"dayjs": "^1.11.10",
Expand All @@ -135,6 +134,7 @@
"lodash.shuffle": "^4.2.0",
"observable-hooks": "^4.2.1",
"qrcode": "^1.5.3",
"rc-table": "^7.48.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this used, what tables?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import { GetRowKey } from 'rc-table/lib/interface'

"react": "^18.2.0",
"react-chartjs-2": "^4.1.0",
"react-circular-progressbar": "^2.0.4",
Expand Down Expand Up @@ -165,6 +165,7 @@
"@testing-library/react": "^13.3.0",
"@testing-library/react-hooks": "^8.0.0",
"@testing-library/user-event": "^14.2.0",
"@tsconfig/node18": "^18.2.4",
"@types/bchaddrjs": "^0.4.0",
"@types/fs-extra": "^9.0.13",
"@types/jest": "^29.5.12",
Expand Down Expand Up @@ -225,7 +226,6 @@
"resolutions": {
"@svgr/webpack": "^6.2.1",
"@ledgerhq/hw-transport": "6.30.6",
"bignumber.js": "^9.0.0",
"secp256k1": "4.0.3"
},
"packageManager": "yarn@4.2.2"
Expand Down
1 change: 1 addition & 0 deletions src/renderer/services/chain/transaction/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ export const sendTx$ = ({
return DASH.sendTx({
walletType,
recipient,
asset,
amount,
feeRate: rates[feeOption],
memo,
Expand Down
38 changes: 7 additions & 31 deletions src/renderer/services/dash/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,16 @@ import * as RD from '@devexperts/remote-data-ts'
import { Network } from '@xchainjs/xchain-client'
import {
AssetDASH,
BitgoProviders,
DASH_DECIMAL,
DASHChain,
Client as DashClient,
defaultDashParams,
LOWER_FEE_BOUND,
UPPER_FEE_BOUND
ClientKeystore as DashClient,
defaultDashParams
} from '@xchainjs/xchain-dash'
import {
BitgoProvider,
BlockcypherNetwork,
BlockcypherProvider,
UtxoOnlineDataProviders
} from '@xchainjs/xchain-utxo-providers'
import { BlockcypherNetwork, BlockcypherProvider, UtxoOnlineDataProviders } from '@xchainjs/xchain-utxo-providers'
import * as FP from 'fp-ts/lib/function'
import * as O from 'fp-ts/lib/Option'
import * as Rx from 'rxjs'
import { Observable } from 'rxjs'
import * as RxOp from 'rxjs/operators'

import { blockcypherApiKey } from '../../../shared/api/blockcypher'
Expand All @@ -27,21 +20,8 @@ import { clientNetwork$ } from '../app/service'
import * as C from '../clients'
import { keystoreService } from '../wallet/keystore'
import { getPhrase } from '../wallet/util'
import { ClientState, ClientState$ } from './types'

//======================
// Bitgo
//======================
const mainnetBitgoProvider = new BitgoProvider({
baseUrl: 'https://app.bitgo.com',
chain: DASHChain
})
import { ClientState, ClientState$, Client$ } from './types'

export const BitgoProviders: UtxoOnlineDataProviders = {
[Network.Testnet]: undefined,
[Network.Stagenet]: mainnetBitgoProvider,
[Network.Mainnet]: mainnetBitgoProvider
}
//======================
// Block Cypher
//======================
Expand Down Expand Up @@ -80,11 +60,7 @@ const clientState$: ClientState$ = FP.pipe(
...defaultDashParams,
phrase: phrase,
network: network,
dataProviders: [BlockcypherDataProviders, BitgoProviders],
feeBounds: {
lower: LOWER_FEE_BOUND,
upper: UPPER_FEE_BOUND
}
dataProviders: [BitgoProviders, BlockcypherDataProviders]
}
const client = new DashClient(dashInitParams)
return RD.success(client)
Expand All @@ -102,7 +78,7 @@ const clientState$: ClientState$ = FP.pipe(
RxOp.shareReplay(1)
)

const client$: Observable<O.Option<DashClient>> = clientState$.pipe(RxOp.map(RD.toOption), RxOp.shareReplay(1))
const client$: Client$ = clientState$.pipe(RxOp.map(RD.toOption), RxOp.shareReplay(1))

/**
* DASH `Address`
Expand Down
25 changes: 23 additions & 2 deletions src/renderer/services/dash/transaction.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as RD from '@devexperts/remote-data-ts'
import { Network, TxHash } from '@xchainjs/xchain-client'
import { AssetDASH, DASHChain } from '@xchainjs/xchain-dash'
import { Client, AssetDASH, DASHChain } from '@xchainjs/xchain-dash'
import * as E from 'fp-ts/lib/Either'
import * as FP from 'fp-ts/lib/function'
import * as O from 'fp-ts/lib/Option'
import * as Rx from 'rxjs'
import * as RxOp from 'rxjs/operators'

Expand All @@ -18,6 +19,26 @@ import { Client$, SendTxParams } from './types'
export const createTransactionService = (client$: Client$, network$: Network$): TransactionService => {
const common = C.createTransactionService(client$)

const sendKeystoreTx = (params: SendTxParams): TxHashLD => {
const { recipient, amount, memo } = params
return FP.pipe(
client$,
RxOp.switchMap(FP.flow(O.fold<Client, Rx.Observable<Client>>(() => Rx.EMPTY, Rx.of))),
RxOp.switchMap((client) => Rx.from(client.transfer({ asset: AssetDASH, recipient, amount, memo, feeRate: 1 }))),
RxOp.map(RD.success),
RxOp.catchError(
(e): TxHashLD =>
Rx.of(
RD.failure({
msg: e?.message ?? e.toString(),
errorId: ErrorId.SEND_TX
})
)
),
RxOp.startWith(RD.pending)
)
}

const sendLedgerTx = ({ network, params }: { network: Network; params: SendTxParams }): TxHashLD => {
const { amount, sender, recipient, memo, walletIndex, feeRate, walletAccount } = params
const sendLedgerTxParams: IPCLedgerSendTxParams = {
Expand Down Expand Up @@ -63,7 +84,7 @@ export const createTransactionService = (client$: Client$, network$: Network$):
RxOp.switchMap((network) => {
if (isLedgerWallet(params.walletType)) return sendLedgerTx({ network, params })

return common.sendTx(params)
return sendKeystoreTx(params)
})
)

Expand Down
5 changes: 3 additions & 2 deletions src/renderer/services/dash/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as RD from '@devexperts/remote-data-ts'
import { FeeRate, FeesWithRates } from '@xchainjs/xchain-client'
import { Client } from '@xchainjs/xchain-dash'
import { Address, BaseAmount } from '@xchainjs/xchain-util'
import { ClientKeystore as Client } from '@xchainjs/xchain-dash'
import { Address, AnyAsset, BaseAmount } from '@xchainjs/xchain-util'

import { HDMode, WalletType } from '../../../shared/wallet/types'
import { LiveData } from '../../helpers/rx/liveData'
Expand All @@ -21,6 +21,7 @@ export type FeesWithRatesLD = LiveData<Error, FeesWithRates>

export type SendTxParams = {
walletType: WalletType
asset: AnyAsset
sender?: Address
recipient: string
amount: BaseAmount
Expand Down
2 changes: 1 addition & 1 deletion src/shared/utils/guard.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FeeOption, Network } from '@xchainjs/xchain-client'
import { AnyAsset, assetFromString, BaseAmount, Chain, isValidAsset } from '@xchainjs/xchain-util'
import BigNumber from 'bignumber.js'
import { BigNumber } from 'ethers'
import * as IOG from 'io-ts/Guard'

import { EvmHDMode } from '../evm/types'
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.scripts.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are now at Node v20.17.0

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "@tsconfig/node16/tsconfig.json"
"extends": "@tsconfig/node18/tsconfig.json"
}
Loading
Loading