Skip to content

Commit

Permalink
Review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cypt4 committed Oct 11, 2023
1 parent 60ce4d2 commit 0603bd9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 4 additions & 0 deletions browser/browser_context_keyed_service_factories.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "brave/browser/brave_rewards/rewards_service_factory.h"
#include "brave/browser/brave_shields/ad_block_pref_service_factory.h"
#include "brave/browser/brave_wallet/asset_ratio_service_factory.h"
#include "brave/browser/brave_wallet/bitcoin_wallet_service_factory.h"
#include "brave/browser/brave_wallet/brave_wallet_ipfs_service_factory.h"
#include "brave/browser/brave_wallet/brave_wallet_service_factory.h"
#include "brave/browser/brave_wallet/json_rpc_service_factory.h"
Expand Down Expand Up @@ -152,6 +153,9 @@ void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
brave_wallet::TxServiceFactory::GetInstance();
brave_wallet::BraveWalletServiceFactory::GetInstance();

if (brave_wallet::IsBitcoinEnabled()) {
brave_wallet::BitcoinWalletServiceFactory::GetInstance();
}
if (brave_wallet::IsZCashEnabled()) {
brave_wallet::ZCashWalletServiceFactory::GetInstance();
}
Expand Down
19 changes: 7 additions & 12 deletions components/brave_wallet/browser/zcash/zcash_rpc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,24 +115,19 @@ absl::optional<std::string> ResolveSerializedMessage(
if (grpc_response_body.size() < 5) {
return absl::nullopt;
}
if (grpc_response_body.c_str()[0] != 0) {
if (grpc_response_body[0] != 0) {
// Compression is not supported yet
return absl::nullopt;
}
uint32_t size = 0;

uint8_t as_bytes[4];
const char* size_start = &(grpc_response_body.c_str()[1]);
for (int i = 0; i < 4; i++) {
as_bytes[i] = static_cast<uint8_t>(size_start[i]);
}
base::ReadBigEndian<uint32_t>(as_bytes, &size);
base::ReadBigEndian(
reinterpret_cast<const uint8_t*>(&(grpc_response_body[1])), &size);

if (grpc_response_body.size() != size + 5) {
return absl::nullopt;
}

return grpc_response_body.substr(5, grpc_response_body.size() - 5);
return grpc_response_body.substr(5);
}

} // namespace
Expand All @@ -145,7 +140,7 @@ ZCashRpc::ZCashRpc(
ZCashRpc::~ZCashRpc() = default;

void ZCashRpc::GetUtxoList(const std::string& chain_id,
const std::vector<std::string>& addresses,
const std::string& address,
ZCashRpc::GetUtxoListCallback callback) {
GURL request_url = MakeGetAddressUtxosURL(
GetNetworkURL(prefs_, chain_id, mojom::CoinType::ZEC));
Expand All @@ -156,7 +151,7 @@ void ZCashRpc::GetUtxoList(const std::string& chain_id,
}

auto url_loader =
MakeGRPCLoader(request_url, MakeGetAddressUtxosURLParams(addresses));
MakeGRPCLoader(request_url, MakeGetAddressUtxosURLParams({address}));

UrlLoadersList::iterator it = url_loaders_list_.insert(
url_loaders_list_.begin(), std::move(url_loader));
Expand All @@ -174,7 +169,6 @@ void ZCashRpc::OnGetUtxosResponse(
const std::unique_ptr<std::string> response_body) {
auto current_loader = std::move(*it);
url_loaders_list_.erase(it);
zcash::GetAddressUtxosResponse response;
if (current_loader->NetError()) {
std::move(callback).Run(base::unexpected("Network error"));
return;
Expand All @@ -191,6 +185,7 @@ void ZCashRpc::OnGetUtxosResponse(
return;
}

zcash::GetAddressUtxosResponse response;
if (!response.ParseFromString(message.value())) {
std::move(callback).Run(base::unexpected("Can't parse response"));
return;
Expand Down
2 changes: 1 addition & 1 deletion components/brave_wallet/browser/zcash/zcash_rpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ZCashRpc {
~ZCashRpc();

void GetUtxoList(const std::string& chain_id,
const std::vector<std::string>& addresses,
const std::string& address,
GetUtxoListCallback callback);

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export const CreateAccountModal = () => {
}
{selectedAccountType?.coin === BraveWallet.CoinType.ZEC &&
<SelectWrapper>
<Select value={bitcoinNetwork} onChange={onChangeZCashNetwork}>
<Select value={zcashNetwork} onChange={onChangeZCashNetwork}>
{ZCashNetworkTypes.map((network) => {
return (
<div data-value={network} key={network}>
Expand Down
1 change: 1 addition & 0 deletions components/brave_wallet_ui/constants/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,7 @@ export interface TransactionProviderErrorRegistry {

export const SupportedCoinTypes = [
BraveWallet.CoinType.SOL,
BraveWallet.CoinType.ETH,
BraveWallet.CoinType.FIL,
BraveWallet.CoinType.BTC,
BraveWallet.CoinType.ZEC
Expand Down

0 comments on commit 0603bd9

Please sign in to comment.