do not commit generated protobuf code and .proto files

generate the code on npm install and npm test from .proto files from haveno repository
This commit is contained in:
premek 2021-11-21 16:33:56 +01:00 committed by woodser
parent ee9cbda667
commit db509778a8
11 changed files with 22 additions and 93208 deletions

3
.gitignore vendored
View File

@ -21,3 +21,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# generated code
/src/protobuf/**

View File

@ -9,10 +9,13 @@ This application is a lightly modified [create-react-app](https://github.com/fac
1. [Run a local Haveno test network](https://github.com/haveno-dex/haveno/blob/master/docs/installing.md), running Alice as a daemon with `make alice-daemon`.
2. `git clone https://github.com/haveno-dex/haveno-ui-poc`
3. In a new terminal, start envoy with the config in haveno-ui-poc/config/envoy.yaml (change absolute path for your system): `docker run --rm --add-host host.docker.internal:host-gateway -it -v ~/git/haveno-ui-poc/config/envoy.yaml:/envoy.yaml -p 8080:8080 envoyproxy/envoy-dev:8a2143613d43d17d1eb35a24b4a4a4c432215606 -c /envoy.yaml`
4. `cd haveno-ui-poc`
5. `npm install`
6. `npm start` to open http://localhost:3000 in a browser
7. Confirm that the Haveno daemon version is displayed (1.6.2)
4. Install protobuf for your system:<br>
mac: `brew install protobuf`<br>
linux: `apt install protobuf-compiler`
5. `cd haveno-ui-poc`
6. `npm install`
7. `npm start` to open http://localhost:3000 in a browser
8. Confirm that the Haveno daemon version is displayed (1.6.2)
<p align="center">
<img src="haveno-ui-poc.png" width="500"/><br>
@ -28,15 +31,9 @@ Running the [top-level API tests](./src/HavenoDaemon.test.tsx) is a great way to
2. `git clone https://github.com/haveno-dex/haveno-ui-poc`
3. In a new terminal, start envoy with the config in haveno-ui-poc/config/envoy.test.yaml (change absolute path for your system): `docker run --rm --add-host host.docker.internal:host-gateway -it -v ~/git/haveno-ui-poc/config/envoy.test.yaml:/envoy.test.yaml -p 8080:8080 -p 8081:8081 envoyproxy/envoy-dev:8a2143613d43d17d1eb35a24b4a4a4c432215606 -c /envoy.test.yaml`
4. In a new terminal, start an instance of monero-wallet-rpc at port 38084. This wallet will be automatically funded in order to fund Alice and Bob during the tests.<br>For example: `cd ~/git/haveno/.localnet/ && ./monero-wallet-rpc --daemon-address http://localhost:38081 --daemon-login superuser:abctesting123 --stagenet --rpc-bind-port 38084 --rpc-login rpc_user:abc123 --wallet-dir ./ --rpc-access-control-origins http://localhost:8080`
5. `cd haveno-ui-poc`
6. `npm install`
7. `npm test` to run all tests or `npm run test -- -t 'my test'` to run tests by name.
## How to Update the Protobuf Client
If the protobuf definitions in haveno-dex/haveno are updated, the typescript imports must be regenerated:
1. Copy grpc.proto and pb.proto from Haveno's [protobuf definitions](https://github.com/haveno-dex/haveno/tree/master/proto/src/main/proto) to ./config.
2. Install protobuf for your system, e.g. on mac: `brew install protobuf`
3. `./bin/build_protobuf.sh`
5. Install protobuf for your system:<br>
mac: `brew install protobuf`<br>
linux: `apt install protobuf-compiler`
6. `cd haveno-ui-poc`
7. `npm install`
8. `npm test` to run all tests or `npm run test -- -t 'my test'` to run tests by name.

View File

@ -1,13 +1,6 @@
#!/bin/sh
# generate imports for haveno services and types using grpc-web
cd ./config || exit 1
protoc -I=./ *.proto --js_out=import_style=commonjs,binary:./ --grpc-web_out=import_style=typescript,mode=grpcwebtext:./ || exit 1
cd ../
# move imports to src folder
mv ./config/grpc_pb.d.ts ./src/protobuf || exit 1
mv ./config/grpc_pb.js ./src/protobuf || exit 1
mv ./config/pb_pb.d.ts ./src/protobuf || exit 1
mv ./config/pb_pb.js ./src/protobuf || exit 1
mv ./config/GrpcServiceClientPb.ts ./src/protobuf || exit 1
mkdir -p ./src/protobuf
cd ./src/protobuf || exit 1
protoc -I=../../../haveno/proto/src/main/proto/ ../../../haveno/proto/src/main/proto/*.proto --js_out=import_style=commonjs,binary:./ --grpc-web_out=import_style=typescript,mode=grpcwebtext:./ || exit 1

View File

@ -1,615 +0,0 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/
syntax = "proto3";
package io.bisq.protobuffer;
import "pb.proto";
option java_package = "bisq.proto.grpc";
option java_multiple_files = true;
///////////////////////////////////////////////////////////////////////////////////////////
// DisputeAgents
///////////////////////////////////////////////////////////////////////////////////////////
service DisputeAgents {
rpc RegisterDisputeAgent (RegisterDisputeAgentRequest) returns (RegisterDisputeAgentReply) {
}
}
message RegisterDisputeAgentRequest {
string dispute_agent_type = 1;
string registration_key = 2;
}
message RegisterDisputeAgentReply {
}
///////////////////////////////////////////////////////////////////////////////////////////
// Help
///////////////////////////////////////////////////////////////////////////////////////////
service Help {
rpc GetMethodHelp (GetMethodHelpRequest) returns (GetMethodHelpReply) {
}
}
message GetMethodHelpRequest {
string method_name = 1;
}
message GetMethodHelpReply {
string method_help = 1;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Offers
///////////////////////////////////////////////////////////////////////////////////////////
service Offers {
rpc GetOffer (GetOfferRequest) returns (GetOfferReply) {
}
rpc GetMyOffer (GetMyOfferRequest) returns (GetMyOfferReply) {
}
rpc GetOffers (GetOffersRequest) returns (GetOffersReply) {
}
rpc GetMyOffers (GetMyOffersRequest) returns (GetMyOffersReply) {
}
rpc CreateOffer (CreateOfferRequest) returns (CreateOfferReply) {
}
rpc CancelOffer (CancelOfferRequest) returns (CancelOfferReply) {
}
}
message GetOfferRequest {
string id = 1;
}
message GetOfferReply {
OfferInfo offer = 1;
}
message GetMyOfferRequest {
string id = 1;
}
message GetMyOfferReply {
OfferInfo offer = 1;
}
message GetOffersRequest {
string direction = 1;
string currency_code = 2;
}
message GetOffersReply {
repeated OfferInfo offers = 1;
}
message GetMyOffersRequest {
string direction = 1;
string currency_code = 2;
}
message GetMyOffersReply {
repeated OfferInfo offers = 1;
}
message CreateOfferRequest {
string currency_code = 1;
string direction = 2;
string price = 3;
bool use_market_based_price = 4;
double market_price_margin = 5;
uint64 amount = 6 [jstype = JS_STRING];
uint64 min_amount = 7 [jstype = JS_STRING];
double buyer_security_deposit = 8;
uint64 trigger_price = 9 [jstype = JS_STRING];
string payment_account_id = 10;
}
message CreateOfferReply {
OfferInfo offer = 1;
}
message CancelOfferRequest {
string id = 1;
}
message CancelOfferReply {
}
message OfferInfo {
string id = 1;
string direction = 2;
uint64 price = 3;
bool use_market_based_price = 4;
double market_price_margin = 5;
uint64 amount = 6;
uint64 min_amount = 7;
uint64 volume = 8;
uint64 min_volume = 9;
uint64 buyer_security_deposit = 10;
uint64 trigger_price = 11;
string payment_account_id = 12;
string payment_method_id = 13;
string payment_method_short_name = 14;
string base_currency_code = 15;
string counter_currency_code = 16;
uint64 date = 17;
string state = 18;
uint64 seller_security_deposit = 19;
string offer_fee_payment_tx_id = 20;
uint64 tx_fee = 21;
uint64 maker_fee = 22;
}
message AvailabilityResultWithDescription {
AvailabilityResult availability_result = 1;
string description = 2;
}
///////////////////////////////////////////////////////////////////////////////////////////
// PaymentAccounts
///////////////////////////////////////////////////////////////////////////////////////////
service PaymentAccounts {
rpc CreatePaymentAccount (CreatePaymentAccountRequest) returns (CreatePaymentAccountReply) {
}
rpc GetPaymentAccounts (GetPaymentAccountsRequest) returns (GetPaymentAccountsReply) {
}
rpc GetPaymentMethods (GetPaymentMethodsRequest) returns (GetPaymentMethodsReply) {
}
rpc GetPaymentAccountForm (GetPaymentAccountFormRequest) returns (GetPaymentAccountFormReply) {
}
rpc CreateCryptoCurrencyPaymentAccount (CreateCryptoCurrencyPaymentAccountRequest) returns (CreateCryptoCurrencyPaymentAccountReply) {
}
rpc GetCryptoCurrencyPaymentMethods (GetCryptoCurrencyPaymentMethodsRequest) returns (GetCryptoCurrencyPaymentMethodsReply) {
}
}
message CreatePaymentAccountRequest {
string payment_account_form = 1;
}
message CreatePaymentAccountReply {
PaymentAccount payment_account = 1;
}
message GetPaymentAccountsRequest {
}
message GetPaymentAccountsReply {
repeated PaymentAccount payment_accounts = 1;
}
message GetPaymentMethodsRequest {
}
message GetPaymentMethodsReply {
repeated PaymentMethod payment_methods = 1;
}
message GetPaymentAccountFormRequest {
string payment_method_id = 1;
}
message GetPaymentAccountFormReply {
string payment_account_form_json = 1;
}
message CreateCryptoCurrencyPaymentAccountRequest {
string account_name = 1;
string currency_code = 2;
string address = 3;
bool trade_instant = 4;
}
message CreateCryptoCurrencyPaymentAccountReply {
PaymentAccount payment_account = 1;
}
message GetCryptoCurrencyPaymentMethodsRequest {
}
message GetCryptoCurrencyPaymentMethodsReply {
repeated PaymentMethod payment_methods = 1;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Price
///////////////////////////////////////////////////////////////////////////////////////////
service Price {
rpc GetMarketPrice (MarketPriceRequest) returns (MarketPriceReply) {
}
rpc GetMarketPrices (MarketPricesRequest) returns (MarketPricesReply) {
}
}
message MarketPriceRequest {
string currency_code = 1;
}
message MarketPriceReply {
double price = 1;
}
message MarketPricesRequest {
}
message MarketPricesReply {
repeated MarketPriceInfo market_price = 1;
}
message MarketPriceInfo {
string currency_code = 1;
double price = 2;
}
///////////////////////////////////////////////////////////////////////////////////////////
// GetTradeStatistics
///////////////////////////////////////////////////////////////////////////////////////////
service GetTradeStatistics {
rpc GetTradeStatistics (GetTradeStatisticsRequest) returns (GetTradeStatisticsReply) {
}
}
message GetTradeStatisticsRequest {
}
message GetTradeStatisticsReply {
repeated TradeStatistics3 trade_statistics = 1;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Shutdown
///////////////////////////////////////////////////////////////////////////////////////////
service ShutdownServer {
rpc Stop (StopRequest) returns (StopReply) {
}
}
message StopRequest {
}
message StopReply {
}
///////////////////////////////////////////////////////////////////////////////////////////
// Trades
///////////////////////////////////////////////////////////////////////////////////////////
service Trades {
rpc GetTrade (GetTradeRequest) returns (GetTradeReply) {
}
rpc TakeOffer (TakeOfferRequest) returns (TakeOfferReply) {
}
rpc ConfirmPaymentStarted (ConfirmPaymentStartedRequest) returns (ConfirmPaymentStartedReply) {
}
rpc ConfirmPaymentReceived (ConfirmPaymentReceivedRequest) returns (ConfirmPaymentReceivedReply) {
}
rpc KeepFunds (KeepFundsRequest) returns (KeepFundsReply) {
}
rpc WithdrawFunds (WithdrawFundsRequest) returns (WithdrawFundsReply) {
}
}
message TakeOfferRequest {
string offer_id = 1;
string payment_account_id = 2;
}
message TakeOfferReply {
TradeInfo trade = 1;
AvailabilityResultWithDescription failure_reason = 2;
}
message ConfirmPaymentStartedRequest {
string trade_id = 1;
}
message ConfirmPaymentStartedReply {
}
message ConfirmPaymentReceivedRequest {
string trade_id = 1;
}
message ConfirmPaymentReceivedReply {
}
message GetTradeRequest {
string trade_id = 1;
}
message GetTradeReply {
TradeInfo trade = 1;
}
message KeepFundsRequest {
string trade_id = 1;
}
message KeepFundsReply {
}
message WithdrawFundsRequest {
string trade_id = 1;
string address = 2;
string memo = 3;
}
message WithdrawFundsReply {
}
message TradeInfo {
OfferInfo offer = 1;
string trade_id = 2;
string short_id = 3;
uint64 date = 4;
string role = 5;
uint64 tx_fee_as_long = 7;
uint64 taker_fee_as_long = 8;
string taker_fee_tx_id = 9;
reserved 10; // was depositTxId
string payout_tx_id = 11;
uint64 trade_amount_as_long = 12;
uint64 trade_price = 13;
string trading_peer_node_address = 14;
string state = 15;
string phase = 16;
string trade_period_state = 17;
bool is_deposit_published = 18;
bool is_deposit_confirmed = 19;
bool is_fiat_sent = 20;
bool is_fiat_received = 21;
bool is_payout_published = 22;
bool is_withdrawn = 23;
string contract_as_json = 24;
ContractInfo contract = 25;
string maker_deposit_tx_id = 100;
string taker_deposit_tx_id = 101;
}
message ContractInfo {
string buyer_node_address = 1;
string seller_node_address = 2;
reserved 3; // was mediator_node_address
reserved 4; // was refund_agent_node_address
bool is_buyer_maker_and_seller_taker = 5;
string maker_account_id = 6;
string taker_account_id = 7;
PaymentAccountPayloadInfo maker_payment_account_payload = 8;
PaymentAccountPayloadInfo taker_payment_account_payload = 9;
string maker_payout_address_string = 10;
string taker_payout_address_string = 11;
uint64 lock_time = 12;
string arbitrator_node_address = 100;
}
message PaymentAccountPayloadInfo {
string id = 1;
string payment_method_id = 2;
string address = 3;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Transactions
///////////////////////////////////////////////////////////////////////////////////////////
message TxFeeRateInfo {
bool use_custom_tx_fee_rate = 1;
uint64 custom_tx_fee_rate = 2;
uint64 fee_service_rate = 3;
uint64 last_fee_service_request_ts = 4;
uint64 min_fee_service_rate = 5;
}
message TxInfo {
string tx_id = 1;
uint64 input_sum = 2;
uint64 output_sum = 3;
uint64 fee = 4;
int32 size = 5;
bool is_pending = 6;
string memo = 7;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Wallets
///////////////////////////////////////////////////////////////////////////////////////////
service Wallets {
rpc GetBalances (GetBalancesRequest) returns (GetBalancesReply) {
}
rpc GetNewDepositSubaddress (GetNewDepositSubaddressRequest) returns (GetNewDepositSubaddressReply) {
}
rpc GetAddressBalance (GetAddressBalanceRequest) returns (GetAddressBalanceReply) {
}
rpc SendBtc (SendBtcRequest) returns (SendBtcReply) {
}
rpc GetTxFeeRate (GetTxFeeRateRequest) returns (GetTxFeeRateReply) {
}
rpc SetTxFeeRatePreference (SetTxFeeRatePreferenceRequest) returns (SetTxFeeRatePreferenceReply) {
}
rpc UnsetTxFeeRatePreference (UnsetTxFeeRatePreferenceRequest) returns (UnsetTxFeeRatePreferenceReply) {
}
rpc GetTransaction (GetTransactionRequest) returns (GetTransactionReply) {
}
rpc GetFundingAddresses (GetFundingAddressesRequest) returns (GetFundingAddressesReply) {
}
rpc SetWalletPassword (SetWalletPasswordRequest) returns (SetWalletPasswordReply) {
}
rpc RemoveWalletPassword (RemoveWalletPasswordRequest) returns (RemoveWalletPasswordReply) {
}
rpc LockWallet (LockWalletRequest) returns (LockWalletReply) {
}
rpc UnlockWallet (UnlockWalletRequest) returns (UnlockWalletReply) {
}
}
message GetBalancesRequest {
string currency_code = 1;
}
message GetBalancesReply {
BalancesInfo balances = 1;
}
message GetNewDepositSubaddressRequest {
}
message GetNewDepositSubaddressReply {
string subaddress = 1;
}
message GetAddressBalanceRequest {
string address = 1;
}
message GetAddressBalanceReply {
AddressBalanceInfo address_balance_info = 1;
}
message SendBtcRequest {
string address = 1;
string amount = 2;
string tx_fee_rate = 3;
string memo = 4;
}
message SendBtcReply {
TxInfo tx_info = 1;
}
message GetTxFeeRateRequest {
}
message GetTxFeeRateReply {
TxFeeRateInfo tx_fee_rate_info = 1;
}
message SetTxFeeRatePreferenceRequest {
uint64 tx_fee_rate_preference = 1;
}
message SetTxFeeRatePreferenceReply {
TxFeeRateInfo tx_fee_rate_info = 1;
}
message UnsetTxFeeRatePreferenceRequest {
}
message UnsetTxFeeRatePreferenceReply {
TxFeeRateInfo tx_fee_rate_info = 1;
}
message GetTransactionRequest {
string tx_id = 1;
}
message GetTransactionReply {
TxInfo tx_info = 1;
}
message GetFundingAddressesRequest {
}
message GetFundingAddressesReply {
repeated AddressBalanceInfo address_balance_info = 1;
}
message SetWalletPasswordRequest {
string password = 1;
string new_password = 2;
}
message SetWalletPasswordReply {
}
message RemoveWalletPasswordRequest {
string password = 1;
}
message RemoveWalletPasswordReply {
}
message LockWalletRequest {
}
message LockWalletReply {
}
message UnlockWalletRequest {
string password = 1;
uint64 timeout = 2;
}
message UnlockWalletReply {
}
message BalancesInfo {
// Field names are shortened for readability's sake, i.e.,
// balancesInfo.getBtc().getAvailableBalance() is cleaner than
// balancesInfo.getBtcBalanceInfo().getAvailableBalance().
BtcBalanceInfo btc = 1;
XmrBalanceInfo xmr = 2;
}
message BtcBalanceInfo {
uint64 available_balance = 1;
uint64 reserved_balance = 2;
uint64 total_available_balance = 3;
uint64 locked_balance = 4;
}
message XmrBalanceInfo {
uint64 balance = 1 [jstype = JS_STRING];
uint64 unlocked_balance = 2 [jstype = JS_STRING];
uint64 locked_balance = 3 [jstype = JS_STRING];
uint64 reserved_offer_balance = 4 [jstype = JS_STRING];
uint64 reserved_trade_balance = 5 [jstype = JS_STRING];
}
message AddressBalanceInfo {
string address = 1;
int64 balance = 2;
int64 num_confirmations = 3;
bool is_address_unused = 4;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Version
///////////////////////////////////////////////////////////////////////////////////////////
service GetVersion {
rpc GetVersion (GetVersionRequest) returns (GetVersionReply) {
}
}
message GetVersionRequest {
}
message GetVersionReply {
string version = 1;
}

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,9 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --runInBand",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"prepare": "bin/build_protobuf.sh",
"pretest": "bin/build_protobuf.sh"
},
"eslintConfig": {
"extends": [

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

7798
src/protobuf/pb_pb.d.ts vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff