add xDAI
This commit is contained in:
parent
a6746bbc2e
commit
683f3c8623
|
@ -39,15 +39,16 @@ const val SETTINGS_BIP32_PATH = "bip32Path"
|
|||
|
||||
const val INFURA_API_KEY = "27efcb33f94e4bd0866d1aadf8e1a12d"
|
||||
const val RPC_ENDPOINT_TEMPLATE = "https://%s.infura.io/v3/${INFURA_API_KEY}"
|
||||
|
||||
const val XDAI_ENDPOINT = "https://rpc.xdaichain.com"
|
||||
const val CHAIN_ID_MAINNET = 1L
|
||||
const val CHAIN_ID_ROPSTEN = 3L
|
||||
const val CHAIN_ID_RINKEBY = 4L
|
||||
const val CHAIN_ID_GOERLI = 5L
|
||||
const val CHAIN_ID_KOVAN = 42L
|
||||
const val CHAIN_ID_XDAI = 100L
|
||||
|
||||
val CHAIN_ID_TO_SHORTNAME = mapOf(CHAIN_ID_MAINNET to "mainnet", CHAIN_ID_ROPSTEN to "ropsten", CHAIN_ID_RINKEBY to "rinkeby", CHAIN_ID_GOERLI to "goerli", CHAIN_ID_KOVAN to "kovan")
|
||||
val CHAIN_IDS = listOf(CHAIN_ID_MAINNET, CHAIN_ID_ROPSTEN, CHAIN_ID_RINKEBY, CHAIN_ID_GOERLI, CHAIN_ID_KOVAN)
|
||||
val CHAIN_IDS = listOf(CHAIN_ID_MAINNET, CHAIN_ID_XDAI, CHAIN_ID_ROPSTEN, CHAIN_ID_RINKEBY, CHAIN_ID_GOERLI, CHAIN_ID_KOVAN)
|
||||
|
||||
const val DEFAULT_CHAIN_ID = CHAIN_ID_MAINNET
|
||||
const val DEFAULT_BIP32_PATH = "m/44'/60'/0'/0/0"
|
|
@ -14,8 +14,11 @@ class SettingsManager(context: Context) {
|
|||
sharedPreferences = EncryptedSharedPreferences.create(context,"settings", masterKey, EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM)
|
||||
}
|
||||
|
||||
val rpcEndpoint
|
||||
get() = String.format(RPC_ENDPOINT_TEMPLATE, CHAIN_ID_TO_SHORTNAME.getValue(sharedPreferences.getLong(SETTINGS_CHAIN_ID, DEFAULT_CHAIN_ID)))
|
||||
val rpcEndpoint : String
|
||||
get() {
|
||||
val chainID = sharedPreferences.getLong(SETTINGS_CHAIN_ID, DEFAULT_CHAIN_ID)
|
||||
return if (chainID == CHAIN_ID_XDAI) XDAI_ENDPOINT else String.format(RPC_ENDPOINT_TEMPLATE, CHAIN_ID_TO_SHORTNAME.getValue(chainID))
|
||||
}
|
||||
|
||||
var chainID
|
||||
get() = sharedPreferences.getLong(SETTINGS_CHAIN_ID, DEFAULT_CHAIN_ID)
|
||||
|
|
|
@ -50,12 +50,14 @@ class WalletConnect(var sessionStatusListener : Session.Callback, var bip32Path:
|
|||
private val sessionStore = FileWCSessionStore(File(Registry.mainActivity.filesDir, "wcSessions.json").apply { createNewFile() }, moshi)
|
||||
private var session: WCSession? = null
|
||||
private var requestId: Long = 0
|
||||
private var currentAccount: String? = null
|
||||
private var uiAction: (Intent?) -> Unit = this::nop
|
||||
private var signAction: (RecoverableSignature) -> Unit = this::nop
|
||||
|
||||
override fun onStatus(status: Session.Status) {
|
||||
if (status == Session.Status.Closed) {
|
||||
session = null
|
||||
currentAccount = null
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -235,8 +237,8 @@ class WalletConnect(var sessionStatusListener : Session.Callback, var bip32Path:
|
|||
|
||||
override fun onResponse(keyPair: BIP32KeyPair) {
|
||||
scope.launch(Dispatchers.IO) {
|
||||
val addr = keyPair.toEthereumAddress().toHexString()
|
||||
session?.approve(listOf(addr), chainID)
|
||||
currentAccount = keyPair.toEthereumAddress().toHexString()
|
||||
session?.approve(listOf(currentAccount!!), chainID)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<resources>
|
||||
<string-array name="networks">
|
||||
<item>Ethereum Mainnet</item>
|
||||
<item>xDAI Network</item>
|
||||
<item>Ropsten PoW Testnet</item>
|
||||
<item>Rinkeby PoA Testnet</item>
|
||||
<item>Görli PoA Testnet</item>
|
||||
|
|
Loading…
Reference in New Issue