Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"homepage": "https://multi.bitmatrix.app",
"private": true,
"dependencies": {
"@bitmatrix/lib": "^0.1.16",
"@bitmatrix/lib": "git+https://github.com/louisinger/bitmatrix-lib.git#update-psetv2",
"@rsuite/icons": "^1.0.2",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.3.0",
Expand All @@ -24,9 +24,10 @@
"@visx/shape": "^2.12.2",
"@visx/tooltip": "^2.10.0",
"@visx/xychart": "^2.12.2",
"bip32": "^4.0.0",
"decimal.js": "^10.4.0",
"ldk": "^0.5.0",
"marina-provider": "^1.5.0",
"liquidjs-lib": "^6.0.2-liquid.27",
"marina-provider": "^2.0.0",
"numeral": "^2.0.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand All @@ -38,7 +39,7 @@
"rsuite": "^5.17.1",
"sass": "^1.54.4",
"socket.io-client": "^4.5.1",
"tiny-secp256k1": "^1.1.6",
"tiny-secp256k1": "^2.2.1",
"typescript": "^4.1.2",
"web-vitals": "^1.0.1"
},
Expand Down
5 changes: 2 additions & 3 deletions src/components/WalletListModal/WalletListModal.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { useState } from 'react';
import { Loader, Modal } from 'rsuite';
import { useWalletContext } from '../../context';
import { UnblindedOutput } from 'ldk';
import { AddressInterface } from 'marina-provider';
import { Address, UnblindedOutput } from 'marina-provider';
import MarinaIcon from '../base/Svg/Icons/Marina';
import AquaIcon from '../base/Svg/Icons/Aqua';
import JadeIcon from '../base/Svg/Icons/Jade';
Expand All @@ -15,7 +14,7 @@ type Props = {
wallet?: Wallet;
// walletOnClick: (walletName: WALLET_NAME) => void;
close: () => void;
setNewAddress?: (newAddress: AddressInterface) => void;
setNewAddress?: (newAddress: Address) => void;
setUtxos?: (utxos: UnblindedOutput[]) => void;
};

Expand Down
34 changes: 30 additions & 4 deletions src/helper/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AssetHash, ElementsValue } from 'liquidjs-lib';
import { useEffect, useRef } from 'react';
import { esplora } from '@bitmatrix/lib';
import { BmConfig, Pool, PAsset, CALL_METHOD } from '@bitmatrix/models';
Expand Down Expand Up @@ -208,9 +209,34 @@ export const padTo2Digits = (num: number): string => {
return num.toString().padStart(2, '0');
};

export const getMyPoolsChartData = async (coins: Utxo[] | undefined, assetHash?: string): Promise<ChartData[]> => {
if (coins && coins?.length > 0) {
const filteredCoins = coins.filter((coin) => coin.asset === assetHash);
const assetFilter = (assetHash: string) => (coin: Utxo) => {
if (coin.blindingData) {
return coin.blindingData.asset === assetHash;
}
if (coin.witnessUtxo) {
const asset = AssetHash.fromBytes(coin.witnessUtxo.asset);
if (asset.isConfidential) return false;
return asset.hex === assetHash;
}

return false;
}

const getCoinValue = (coin: Utxo) => {
if (coin.blindingData) {
return coin.blindingData.value;
}
if (coin.witnessUtxo) {
const value = ElementsValue.fromBytes(coin.witnessUtxo.value);
if (value.isConfidential) return undefined;
return value.number;
}
return undefined;
}

export const getMyPoolsChartData = async (coins?: Utxo[], assetHash?: string): Promise<ChartData[]> => {
if (coins && coins?.length > 0 && assetHash) {
const filteredCoins = coins.filter(assetFilter(assetHash));
const outSpendsPromises = filteredCoins.map((coin) => esplora.txDetailPromise(coin.txid));
const outSpends = await Promise.all(outSpendsPromises);

Expand All @@ -234,7 +260,7 @@ export const getMyPoolsChartData = async (coins: Utxo[] | undefined, assetHash?:

const d: ChartData = {
date: dateTime,
close: spent ? (coin.value || 0) * -1 : coin.value || 0,
close: spent ? (getCoinValue(coin) || 0) * -1 : getCoinValue(coin) || 0,
};

return d;
Expand Down
36 changes: 0 additions & 36 deletions src/lib/liquid-dev/index.txt

This file was deleted.

14 changes: 11 additions & 3 deletions src/pages/Swap/Swap.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as ecc from 'tiny-secp256k1';
import { BIP32Factory } from 'bip32';
import { useCallback, useEffect, useState } from 'react';
import Decimal from 'decimal.js';
import { Button, Content } from 'rsuite';
Expand Down Expand Up @@ -327,8 +329,14 @@ export const Swap: React.FC<Props> = ({ checkTxStatusWithIds }): JSX.Element =>
setLoading(true);

const addressInformation = await walletContext.marina.getNextChangeAddress();
const { masterXPub } = await walletContext.marina.getAccountInfo(addressInformation.accountName);


if (addressInformation.derivationPath) {
const addressPublicKey = BIP32Factory(ecc)
.fromBase58(masterXPub)
.derivePath(addressInformation.derivationPath.replace('m/', '')).publicKey.toString('hex') // remove m/ from path

if (addressInformation.publicKey) {
// setSwapWay(undefined);
setSelectedFromAmountPercent(undefined);

Expand All @@ -342,7 +350,7 @@ export const Swap: React.FC<Props> = ({ checkTxStatusWithIds }): JSX.Element =>
numberToAmount,
currentPool,
testnetConfig,
addressInformation.publicKey,
addressPublicKey,
lbtcAsset.assetHash,
true,
);
Expand All @@ -357,7 +365,7 @@ export const Swap: React.FC<Props> = ({ checkTxStatusWithIds }): JSX.Element =>
numberToAmount,
currentPool,
testnetConfig,
addressInformation.publicKey,
addressPublicKey,
lbtcAsset.assetHash,
true,
);
Expand Down