Skip to content

Commit

Permalink
update to haveno-ts v0.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
woodser committed May 23, 2023
1 parent fcd209f commit 1cd1ecf
Show file tree
Hide file tree
Showing 11 changed files with 12,198 additions and 12,027 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
### Prerequisites

1. Node 16.x
1. yarn 1.x
1. Haveno daemon and envoy proxy
2. yarn 1.x
3. Run user1-daemon-local and envoy proxy by following [these instructions](https://github.com/haveno-dex/haveno-ts#run-tests)

### Install dependencies

Expand All @@ -27,11 +27,19 @@ yarn watch
### Tests

```sh
yarn tests
yarn test
```

### Storybook

```sh
yarn storybook
```

### App Data Folder

The UI's data folder can be cleared to reset the UI state, located at:

- Mac: ~/Library/Application Support/haveno-ui/
- Linux: ~/.local/share/haveno-ui/
- Windows: ~\AppData\Roaming\haveno-ui\
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"dayjs": "^1.11.0",
"electron-store": "^8.0.1",
"electron-updater": "4.6.5",
"haveno-ts": "0.0.6",
"haveno-ts": "0.0.10",
"joi": "^17.6.0",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.21",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const transformToMarketsOffers = (
amountCurrency: offer.baseCurrencyCode,
costCurrency: offer.baseCurrencyCode,
paymentMethod: offer.paymentMethodShortName,
cost: offer.txFee,
cost: offer.makerFee,
priceComparison: 0.1,
accountAge: 1,
accountTrades: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ describe("organisms::MyWalletMoneroBalance", () => {
{
timestamp: 1653593643913,
height: "1.334423",
fee: "3.33",
fee: "33300000",
isConfirmed: true,
isLocked: false,
hash: "HASHADDRESS",
incomingTransfersList: [
{
amount: "10000",
amount: "10000000000000000",
accountIndex: 1,
subaddressIndex: 1,
address: "INCOMINGADDRESS",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { isEmpty } from "lodash";
import type { XmrTx } from "haveno-ts";
import { HavenoUtils } from "haveno-ts";
import { WalletTransactionType } from "@molecules/WalletTransactions/_types";
import type { TWalletTransaction } from "@molecules/WalletTransactions/_types";

Expand All @@ -30,12 +31,15 @@ const transfromXmrTx = (xmrTx: XmrTx.AsObject): TWalletTransaction => ({
? WalletTransactionType.Sent
: WalletTransactionType.Received,

fee: parseFloat(xmrTx.fee),
fee: HavenoUtils.atomicUnitsToXmr(xmrTx.fee),
height: xmrTx.height,

// TODO: this skips incoming transfers of tx which has both incoming and outgoing transfer
amount: !isEmpty(xmrTx.outgoingTransfer)
? parseFloat(xmrTx.outgoingTransfer?.amount || "")
: parseFloat(xmrTx.incomingTransfersList[0]?.amount),
? HavenoUtils.atomicUnitsToXmr(xmrTx.outgoingTransfer?.amount || "0")
: HavenoUtils.atomicUnitsToXmr(
xmrTx.incomingTransfersList[0]?.amount || "0"
),

amountCurrency: "XMR",
transactionId: xmrTx.hash,
Expand Down
15 changes: 11 additions & 4 deletions packages/renderer/src/hooks/haveno/useBalances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License.
// =============================================================================

import { HavenoUtils } from "haveno-ts";
import { useQuery } from "react-query";
import { useHavenoClient } from "./useHavenoClient";
import { QueryKeys } from "@constants/query-keys";
Expand All @@ -37,10 +38,16 @@ export function useBalances() {
const balances = xmrBalances.toObject();

const balance = parseFloat(balances.balance);
const unlockedBalance = parseFloat(balances.unlockedBalance);
const lockedBalance = parseFloat(balances.lockedBalance);
const reservedOfferBalance = parseFloat(balances.reservedOfferBalance);
const reservedTradeBalance = parseFloat(balances.reservedTradeBalance);
const unlockedBalance = HavenoUtils.atomicUnitsToXmr(
balances.availableBalance
);
const lockedBalance = HavenoUtils.atomicUnitsToXmr(balances.pendingBalance);
const reservedOfferBalance = HavenoUtils.atomicUnitsToXmr(
balances.reservedOfferBalance
);
const reservedTradeBalance = HavenoUtils.atomicUnitsToXmr(
balances.reservedTradeBalance
);

const availableBalance = unlockedBalance;
const reservedBalance = reservedOfferBalance + reservedTradeBalance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function useIsMoneroNodeRunning() {
QueryKeys.MoneroNodeIsRunning,
async () => {
try {
const value = await client.isMoneroNodeRunning();
const value = await client.isMoneroNodeOnline();
return value;
} catch {
return false;
Expand Down
12 changes: 10 additions & 2 deletions packages/renderer/src/hooks/haveno/useMarketsOffers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { useQuery } from "react-query";
import type { OfferInfo } from "haveno-ts";
import { HavenoUtils } from "haveno-ts";
import { useHavenoClient } from "./useHavenoClient";
import { QueryKeys } from "@constants/query-keys";

Expand All @@ -42,6 +43,15 @@ const transformData = (offers: Array<OfferInfo>) => {

return {
...offer,
amount: HavenoUtils.atomicUnitsToXmr(offer.amount),
minAmount: HavenoUtils.atomicUnitsToXmr(offer.minAmount),
buyerSecurityDeposit: HavenoUtils.atomicUnitsToXmr(
offer.buyerSecurityDeposit
),
sellerSecurityDeposit: HavenoUtils.atomicUnitsToXmr(
offer.sellerSecurityDeposit
),
makerFee: HavenoUtils.atomicUnitsToXmr(offer.makerFee),
price: parseFloat(offer.price),
volume: parseFloat(offer.volume),
minVolume: parseFloat(offer.minVolume),
Expand Down Expand Up @@ -70,8 +80,6 @@ export interface MarketOfferData {
date: number;
state: string;
sellerSecurityDeposit: number;
offerFeePaymentTxId: string;
txFee: number;
makerFee: number;
isActivated: boolean;
isMyOffer: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/renderer/src/hooks/haveno/useRestoreBackup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function useRestoreBackup() {
deleteSession();
navigate(ROUTES.Login);

if (await client.isMoneroNodeRunning()) {
if (await client.isMoneroNodeOnline()) {
await client.stopMoneroNode();
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function useSaveLocalMoneroNode() {
nodeSettings.setStartupFlagsList(data.startupFlags);
nodeSettings.setBootstrapUrl(data.bootstrapUrl);

if (await client.isMoneroNodeRunning()) {
if (await client.isMoneroNodeOnline()) {
// stop the node if it's running
await client.stopMoneroNode();
}
Expand Down
Loading

0 comments on commit 1cd1ecf

Please sign in to comment.