-
Notifications
You must be signed in to change notification settings - Fork 892
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13359 from brave/open-account-in-dapp-panel
feat(wallet): implement account selector
- Loading branch information
Showing
18 changed files
with
425 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
android/java/org/chromium/chrome/browser/app/domain/CryptoSharedData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.chromium.chrome.browser.app.domain; | ||
|
||
public interface CryptoSharedData { | ||
int getCoinType(); | ||
String getChainId(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
android/java/org/chromium/chrome/browser/app/domain/NetworkModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.chromium.chrome.browser.app.domain; | ||
|
||
import android.text.TextUtils; | ||
|
||
import androidx.lifecycle.LiveData; | ||
import androidx.lifecycle.MutableLiveData; | ||
|
||
import org.chromium.brave_wallet.mojom.BraveWalletConstants; | ||
import org.chromium.brave_wallet.mojom.JsonRpcService; | ||
import org.chromium.brave_wallet.mojom.JsonRpcServiceObserver; | ||
import org.chromium.mojo.system.MojoException; | ||
|
||
public class NetworkModel implements JsonRpcServiceObserver { | ||
private final JsonRpcService mJsonRpcService; | ||
private final MutableLiveData<String> _mChainId; | ||
public LiveData<String> mChainId; | ||
private final CryptoSharedData mSharedData; | ||
|
||
public NetworkModel(JsonRpcService jsonRpcService, CryptoSharedData sharedData) { | ||
mJsonRpcService = jsonRpcService; | ||
mSharedData = sharedData; | ||
_mChainId = new MutableLiveData<>(BraveWalletConstants.MAINNET_CHAIN_ID); | ||
mChainId = _mChainId; | ||
jsonRpcService.addObserver(this); | ||
} | ||
|
||
public void init() { | ||
mJsonRpcService.getChainId(mSharedData.getCoinType(), chainId -> { | ||
String id = BraveWalletConstants.MAINNET_CHAIN_ID; | ||
if (TextUtils.isEmpty(chainId)) { | ||
mJsonRpcService.setNetwork(id, mSharedData.getCoinType(), hasSetNetwork -> {}); | ||
} else { | ||
id = chainId; | ||
} | ||
_mChainId.postValue(id); | ||
}); | ||
} | ||
|
||
@Override | ||
public void chainChangedEvent(String chainId, int coin) { | ||
_mChainId.postValue(chainId); | ||
} | ||
|
||
@Override | ||
public void onAddEthereumChainRequestCompleted(String chainId, String error) {} | ||
|
||
@Override | ||
public void onIsEip1559Changed(String chainId, boolean isEip1559) {} | ||
|
||
@Override | ||
public void onConnectionError(MojoException e) {} | ||
|
||
@Override | ||
public void close() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.