From 077529b9cf59940a5992dd8f52f63d7e03672a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Bordalo?= Date: Thu, 20 Jan 2022 17:11:50 +0000 Subject: [PATCH 1/9] remove all dependencies from taxi-protobuf --- src/application/utils/constants.ts | 4 +- src/application/utils/taxi.ts | 45 +++++++++++++-------- src/application/utils/transaction.ts | 5 +-- src/presentation/wallet/send/choose-fee.tsx | 4 +- 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/application/utils/constants.ts b/src/application/utils/constants.ts index e0f012fc..e1f3de0b 100644 --- a/src/application/utils/constants.ts +++ b/src/application/utils/constants.ts @@ -12,8 +12,8 @@ export const feeLevelToSatsPerByte: { [key: string]: number } = { export const taxiURL: Record = { regtest: 'http://localhost:8000', - testnet: 'http://todo.com', // TODO is there a taxi running on testnet ? - liquid: 'https://grpc.liquid.taxi', + testnet: 'https://grpc.liquid.taxi:18000/v1', + liquid: 'https://grpc.liquid.taxi/v1', }; const makeImagePath = (fileName: string): string => `assets/images/liquid-assets/${fileName}`; diff --git a/src/application/utils/taxi.ts b/src/application/utils/taxi.ts index 88abca91..0b21e8b6 100644 --- a/src/application/utils/taxi.ts +++ b/src/application/utils/taxi.ts @@ -1,24 +1,35 @@ -import { TaxiClient } from 'taxi-protobuf/generated/js/TaxiServiceClientPb'; -import { - AssetDetails, - ListAssetsRequest, - TopupWithAssetReply, - TopupWithAssetRequest, -} from 'taxi-protobuf/generated/js/taxi_pb'; +import axios from 'axios'; + +interface AssetDetails { + assetHash: string, + basisPoint: number, + assetPrice: number, +} + +export interface Topup { + topupId: string, + partial: string, + assetHash: string, + assetAmount: number, + assetSpread: number, +} + +export interface TopupWithAssetReply { + topup?: Topup, + expiry: number, + privateBlindingKey: string, + publicBlindingKey: string, +} export const fetchAssetsFromTaxi = async (taxiUrl: string): Promise => { - const client = new TaxiClient(taxiUrl, undefined); - const res = await client.listAssets(new ListAssetsRequest(), null); - return res.getAssetsList().map((asset: AssetDetails) => asset.getAssetHash()); + const { data } = await axios.get(`${taxiUrl}/assets`); + return data.assets.map((asset: AssetDetails) => asset.assetHash); }; export const fetchTopupFromTaxi = async ( taxiUrl: string, - asset: string -): Promise => { - const client = new TaxiClient(taxiUrl, undefined); - const request = new TopupWithAssetRequest(); - request.setAssetHash(asset); - const res = await client.topupWithAsset(request, null); - return res.toObject(); + assetHash: string +): Promise => { + const { data } = await axios.post(`${taxiUrl}/asset/topup`, { assetHash }); + return data; }; diff --git a/src/application/utils/transaction.ts b/src/application/utils/transaction.ts index f13c853c..adb3631e 100644 --- a/src/application/utils/transaction.ts +++ b/src/application/utils/transaction.ts @@ -21,9 +21,8 @@ import { import { confidential, networks, payments, Psbt } from 'liquidjs-lib'; import { blindingKeyFromAddress, isConfidentialAddress } from './address'; import { Transfer, TxDisplayInterface, TxStatusEnum, TxType } from '../../domain/transaction'; -import { Topup } from 'taxi-protobuf/generated/js/taxi_pb'; import { lbtcAssetByNetwork } from './network'; -import { fetchTopupFromTaxi } from './taxi'; +import { fetchTopupFromTaxi, Topup } from './taxi'; import { taxiURL } from './constants'; import { DataRecipient, isAddressRecipient, isDataRecipient, Recipient } from 'marina-provider'; @@ -92,7 +91,7 @@ const throwErrorCoinSelector: CoinSelectorErrorFn = ( * @param changeAddressGetter define the way we get change addresses (if needed). */ export function createTaxiTxFromTopup( - taxiTopup: Topup.AsObject, + taxiTopup: Topup, unspents: UnblindedOutput[], recipients: RecipientInterface[], coinSelector: CoinSelector, diff --git a/src/presentation/wallet/send/choose-fee.tsx b/src/presentation/wallet/send/choose-fee.tsx index 1ec60773..f97c8266 100644 --- a/src/presentation/wallet/send/choose-fee.tsx +++ b/src/presentation/wallet/send/choose-fee.tsx @@ -35,7 +35,7 @@ import { } from '../../../application/redux/actions/transaction'; import { ProxyStoreDispatch } from '../../../application/redux/proxyStore'; import { Address, createAddress } from '../../../domain/address'; -import { Topup } from 'taxi-protobuf/generated/js/taxi_pb'; +import { Topup } from '../../../application/utils/taxi'; import { incrementChangeAddressIndex } from '../../../application/redux/actions/wallet'; export interface ChooseFeeProps { @@ -76,7 +76,7 @@ const ChooseFeeView: React.FC = ({ const [errorMessage, setErrorMessage] = useState(); const [loading, setLoading] = useState(false); const [feeChange, setFeeChange] = useState
(); - const [topup, setTopup] = useState(); + const [topup, setTopup] = useState(); const circleLoaderRef = React.useRef(null); useLottieLoader(circleLoaderRef, '/assets/animations/circle-loader.json'); From f39600fa87de40015fbcdd99dc5fd2b3305fa554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Bordalo?= Date: Thu, 20 Jan 2022 17:19:24 +0000 Subject: [PATCH 2/9] remove taxi-protobuf --- jest.config.js | 1 - package.json | 1 - yarn.lock | 11 ----------- 3 files changed, 13 deletions(-) diff --git a/jest.config.js b/jest.config.js index f866a3c5..db451305 100644 --- a/jest.config.js +++ b/jest.config.js @@ -10,5 +10,4 @@ module.exports = { transform: { '.+\\.ts$': 'ts-jest', }, - transformIgnorePatterns: ['node_modules/(?!(taxi-protobuf)/)"'], }; diff --git a/package.json b/package.json index 49519b6b..538e5fba 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,6 @@ "redux-thunk": "^2.3.0", "stream-browserify": "^3.0.0", "tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.1.2", - "taxi-protobuf": "vulpemventures/taxi-protobuf", "uuid": "^8.3.2", "webext-redux": "^2.1.7", "webextension-polyfill": "^0.8.0", diff --git a/yarn.lock b/yarn.lock index 752b4eee..a14ca70b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4534,11 +4534,6 @@ growly@^1.3.0: resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" integrity sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE= -grpc-web@1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/grpc-web/-/grpc-web-1.2.0.tgz#96402a1245ea834fedb1dd5a80f910476ddbbb1c" - integrity sha512-QS0RF+xiWnMEiHWyA0A0I8JYYJLOiF/DGEpRQ7vJDOzEZYfmNqI7d7d29sYBbNfTi+arVh2JpeGIX7ch24a+tA== - har-schema@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" @@ -8841,12 +8836,6 @@ tapable@^2.1.1, tapable@^2.2.0: resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.0.tgz#5c373d281d9c672848213d0e037d1c4165ab426b" integrity sha512-FBk4IesMV1rBxX2tfiK8RAmogtWn53puLOQlvO8XuwlgxcYbP4mVPS9Ph4aeamSyyVjOl24aYWAuc8U5kCVwMw== -taxi-protobuf@vulpemventures/taxi-protobuf: - version "1.0.0" - resolved "https://codeload.github.com/vulpemventures/taxi-protobuf/tar.gz/43fad1d83547a9fb340147e622673b36b1e63b25" - dependencies: - grpc-web "1.2.0" - terminal-link@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/terminal-link/-/terminal-link-2.1.1.tgz#14a64a27ab3c0df933ea546fba55f2d078edc994" From d37c2438c9e46f2d34c9f6c117e88e688323e77a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Bordalo?= Date: Thu, 20 Jan 2022 17:20:50 +0000 Subject: [PATCH 3/9] merge master --- src/application/utils/constants.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/application/utils/constants.ts b/src/application/utils/constants.ts index 902cffd2..e1f3de0b 100644 --- a/src/application/utils/constants.ts +++ b/src/application/utils/constants.ts @@ -12,13 +12,8 @@ export const feeLevelToSatsPerByte: { [key: string]: number } = { export const taxiURL: Record = { regtest: 'http://localhost:8000', -<<<<<<< HEAD testnet: 'https://grpc.liquid.taxi:18000/v1', liquid: 'https://grpc.liquid.taxi/v1', -======= - testnet: 'https://grpc.liquid.taxi:18000', - liquid: 'https://grpc.liquid.taxi', ->>>>>>> master }; const makeImagePath = (fileName: string): string => `assets/images/liquid-assets/${fileName}`; From ca8888ddb1676d18aa4c3ae820873b688efa406e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Bordalo?= Date: Thu, 20 Jan 2022 17:59:50 +0000 Subject: [PATCH 4/9] throw response, not response.data --- src/application/utils/network.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/application/utils/network.ts b/src/application/utils/network.ts index 3df9fac2..eaccc5a1 100644 --- a/src/application/utils/network.ts +++ b/src/application/utils/network.ts @@ -5,8 +5,8 @@ import { IAssets } from '../../domain/assets'; export const broadcastTx = async (baseUrl: string, txHex: string): Promise => { const response = await axios.post(`${baseUrl}/tx`, txHex); if (response.status !== 200) { - console.error(response.data); - throw new Error(response.data); + console.error(response); + throw new Error(JSON.stringify(response)); } return response.data; }; From 81961b0b5baafd73a72fc572e42130244bf8fe48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Bordalo?= Date: Thu, 20 Jan 2022 19:07:32 +0000 Subject: [PATCH 5/9] puts keys in alphabetical order --- src/application/utils/taxi.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/application/utils/taxi.ts b/src/application/utils/taxi.ts index 0b21e8b6..b8f8c5f7 100644 --- a/src/application/utils/taxi.ts +++ b/src/application/utils/taxi.ts @@ -2,23 +2,23 @@ import axios from 'axios'; interface AssetDetails { assetHash: string, - basisPoint: number, assetPrice: number, + basisPoint: number, } export interface Topup { - topupId: string, - partial: string, - assetHash: string, assetAmount: number, + assetHash: string, assetSpread: number, + partial: string, + topupId: string, } export interface TopupWithAssetReply { - topup?: Topup, expiry: number, privateBlindingKey: string, publicBlindingKey: string, + topup?: Topup, } export const fetchAssetsFromTaxi = async (taxiUrl: string): Promise => { From d8ece1f3c2af13689315ecfee6d77fed65d1587c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Bordalo?= Date: Thu, 20 Jan 2022 19:10:17 +0000 Subject: [PATCH 6/9] prettier --- src/application/utils/taxi.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/application/utils/taxi.ts b/src/application/utils/taxi.ts index b8f8c5f7..43cf22c5 100644 --- a/src/application/utils/taxi.ts +++ b/src/application/utils/taxi.ts @@ -1,24 +1,24 @@ import axios from 'axios'; interface AssetDetails { - assetHash: string, - assetPrice: number, - basisPoint: number, + assetHash: string; + assetPrice: number; + basisPoint: number; } export interface Topup { - assetAmount: number, - assetHash: string, - assetSpread: number, - partial: string, - topupId: string, + assetAmount: number; + assetHash: string; + assetSpread: number; + partial: string; + topupId: string; } export interface TopupWithAssetReply { - expiry: number, - privateBlindingKey: string, - publicBlindingKey: string, - topup?: Topup, + expiry: number; + privateBlindingKey: string; + publicBlindingKey: string; + topup?: Topup; } export const fetchAssetsFromTaxi = async (taxiUrl: string): Promise => { From 91c510c2fcebb94a77cfe90620c7cd22d2431234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Bordalo?= Date: Thu, 20 Jan 2022 19:17:44 +0000 Subject: [PATCH 7/9] bug fix --- src/application/utils/taxi.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/application/utils/taxi.ts b/src/application/utils/taxi.ts index 43cf22c5..d3fd9623 100644 --- a/src/application/utils/taxi.ts +++ b/src/application/utils/taxi.ts @@ -30,6 +30,6 @@ export const fetchTopupFromTaxi = async ( taxiUrl: string, assetHash: string ): Promise => { - const { data } = await axios.post(`${taxiUrl}/asset/topup`, { assetHash }); + const { data } = await axios.post(`${taxiUrl}/asset/topup`, assetHash); return data; }; From 9eaef505403d50b4ef0c5aad5c0a4953520eab5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Bordalo?= Date: Fri, 21 Jan 2022 09:58:18 +0000 Subject: [PATCH 8/9] bug fix --- src/application/utils/taxi.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/application/utils/taxi.ts b/src/application/utils/taxi.ts index d3fd9623..43cf22c5 100644 --- a/src/application/utils/taxi.ts +++ b/src/application/utils/taxi.ts @@ -30,6 +30,6 @@ export const fetchTopupFromTaxi = async ( taxiUrl: string, assetHash: string ): Promise => { - const { data } = await axios.post(`${taxiUrl}/asset/topup`, assetHash); + const { data } = await axios.post(`${taxiUrl}/asset/topup`, { assetHash }); return data; }; From 119c83a8c896366f9ed71ba39e01dab9a54f8680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Bordalo?= Date: Fri, 21 Jan 2022 10:12:18 +0000 Subject: [PATCH 9/9] remove google protobuf --- package.json | 1 - yarn.lock | 5 ----- 2 files changed, 6 deletions(-) diff --git a/package.json b/package.json index 538e5fba..941ce45e 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ "crypto-browserify": "^3.12.0", "decimal.js": "^10.2.1", "formik": "^2.2.6", - "google-protobuf": "^3.15.8", "ldk": "^0.4.0", "lodash.debounce": "^4.0.8", "lottie-web": "^5.7.8", diff --git a/yarn.lock b/yarn.lock index a14ca70b..c93737aa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4497,11 +4497,6 @@ globby@^6.1.0: pify "^2.0.0" pinkie-promise "^2.0.0" -google-protobuf@^3.15.8: - version "3.17.3" - resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.17.3.tgz#f87595073545a77946c8f0b67c302c5f7646d700" - integrity sha512-OVPzcSWIAJ+d5yiHyeaLrdufQtrvaBrF4JQg+z8ynTkbO3uFcujqXszTumqg1cGsAsjkWnI+M5B1xZ19yR4Wyg== - got@^9.6.0: version "9.6.0" resolved "https://registry.yarnpkg.com/got/-/got-9.6.0.tgz#edf45e7d67f99545705de1f7bbeeeb121765ed85"