Skip to content

Commit

Permalink
Review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cypt4 committed Jan 24, 2023
1 parent 411a98b commit be3bd52
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ public GetNftErc721MetadataContext(Runnable responseCompleteCallback) {
}

@Override
public void call(String tokenUrl, String erc721Metadata, Integer errorCode, String errorMessage) {
public void call(
String tokenUrl, String erc721Metadata, Integer errorCode, String errorMessage) {
this.tokenMetadata = erc721Metadata;
this.errorCode = errorCode;
this.errorMessage = errorMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ void BraveWalletAutoPinService::OnTokenListResolved(
continue;
}

auto it = known_tokens.find(current_token_path.value());
if (it != known_tokens.end()) {
known_tokens.erase(it);
}
known_tokens.erase(current_token_path.value());

mojom::TokenPinStatusPtr status =
brave_wallet_pin_service_->GetTokenStatus(absl::nullopt, token);
Expand Down
5 changes: 5 additions & 0 deletions components/brave_wallet/browser/brave_wallet_pin_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ const char kAssetUrlListKey[] = "cids";
namespace {

const char kNftPart[] = "nft";
/**
* Service name used in prefs for local pinning service.
* Use absl::nullopt in methods to perform operations on
* the local pinning service.
*/
const char kLocalService[] = "local";

absl::optional<mojom::TokenPinStatusCode> StringToStatus(
Expand Down
4 changes: 4 additions & 0 deletions components/brave_wallet/browser/brave_wallet_pin_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@

namespace brave_wallet {

/**
* At the moment only local pinning is supported so use absl::nullopt
* for optional service argument.
*/
class BraveWalletPinService : public KeyedService,
public brave_wallet::mojom::WalletPinService,
public ipfs::IpfsServiceObserver {
Expand Down
3 changes: 2 additions & 1 deletion components/brave_wallet/browser/brave_wallet_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,8 @@ void BraveWalletService::DiscoverAssetsOnAllSupportedChains() {
addresses[mojom::CoinType::SOL] = std::move(sol_account_addresses);

// Discover assets owned by the SOL and ETH addresses on all supported chains
asset_discovery_manager_->DiscoverAssetsOnAllSupportedChainsRefresh(addresses);
asset_discovery_manager_->DiscoverAssetsOnAllSupportedChainsRefresh(
addresses);
}

void BraveWalletService::CancelAllSuggestedTokenCallbacks() {
Expand Down
6 changes: 5 additions & 1 deletion components/brave_wallet/common/brave_wallet.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ interface BraveWalletPinServiceObserver {
};

// Low-level interface for token pinning.
// String service argument is used to select on which pinning
// service operation should be performed.
// At the moment we have only local pinning, so use null.
interface WalletPinService {
AddObserver(pending_remote<BraveWalletPinServiceObserver> observer);

Expand All @@ -279,13 +282,14 @@ interface WalletPinService {
// Returns overview for provided token.
GetTokenStatus(BlockchainToken token) => (TokenPinOverview? status,
PinError? error);
// Checks whether token in pinned correctly.
// Checks whether token is pinned correctly.
Validate(BlockchainToken token, string? service) => (bool result,
PinError? error);
// Returns whether IPFS localnode is currently running.
IsLocalNodeRunning() => (bool result);

// Returns whether token is supported for pinning.
// Note: You should manually check token metadata url to have ipfs:// url.
IsTokenSupported(BlockchainToken token) => (bool result);
};

Expand Down

0 comments on commit be3bd52

Please sign in to comment.