Skip to content

Commit

Permalink
Merge branch 'release/1.0.13'
Browse files Browse the repository at this point in the history
  • Loading branch information
Foboz committed Mar 27, 2020
2 parents dfd2112 + 2d118a2 commit 162c367
Show file tree
Hide file tree
Showing 23 changed files with 299 additions and 54 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### Release 1.0.13 (20032601)

Updates to import process.

### Release 1.0.12 (20031101)

ANNOUNCEMENT: Full-fledged MEW wallet app is now available!
Expand Down
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ apply plugin: 'org.jetbrains.kotlin.android.extensions'

int MAJOR_VERSION = 1
int MINOR_VERSION = 0
int MICRO_VERSION = 12
int MICRO_VERSION = 13
int BUILD_FOR_TODAY = 1

def secretsPropertiesFile = rootProject.file("secrets.properties")
Expand Down Expand Up @@ -40,7 +40,8 @@ android {
vectorDrawables.useSupportLibrary = true

buildConfigField "String", "CONNECT_API_END_POINT", "\"https://connect.mewapi.io\""
buildConfigField "String", "MEW_API_END_POINT", "\"https://nodes.mewapi.io/rpc/\""
buildConfigField "String", "NODE_API_END_POINT", "\"https://nodes.mewapi.io/rpc/\""
buildConfigField "String", "MEW_API_END_POINT", "\"https://mainnet.mewwallet.dev/\""
buildConfigField "String", "APICCSWAP_API_END_POINT", "\"https://apiccswap.myetherwallet.com/\""
buildConfigField "String", "APICCSWAP_API_KEY", "\"" + secretsProperties['apiccswapApiKey'] + "\""
buildConfigField "String", "APICCSWAP_REFERER", "\"" + secretsProperties['apiccswapReferer'] + "\""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
package com.myetherwallet.mewconnect.content.api.mew

import com.myetherwallet.mewconnect.content.data.AnalyticsEventsRequest
import com.myetherwallet.mewconnect.feature.main.data.JsonRpcRequest
import com.myetherwallet.mewconnect.feature.main.data.JsonRpcResponse
import org.web3j.protocol.core.methods.request.Transaction
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.Headers
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.*

/**
* Created by BArtWell on 16.07.2018.
* Created by BArtWell on 26.03.2020.
*/

internal interface MewApi {

@POST("{apiMethod}")
@POST("analytics/record/{platform}")
@Headers("content-type: application/json")
fun getAllBalances(@Path("apiMethod") apiMethod: String, @Body jsonRpc: JsonRpcRequest<Any>): Call<JsonRpcResponse>

@POST("{apiMethod}")
@Headers("content-type: application/json")
fun getWalletBalance(@Path("apiMethod") apiMethod: String, @Body jsonRpc: JsonRpcRequest<String>): Call<JsonRpcResponse>
fun submit(@Path("platform") platform: String, @Query("iso") iso: String, @Body events: AnalyticsEventsRequest): Call<Any>
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.myetherwallet.mewconnect.content.api.mew

import com.myetherwallet.mewconnect.feature.main.data.JsonRpcRequest
import org.web3j.protocol.core.methods.request.Transaction
import com.myetherwallet.mewconnect.content.data.AnalyticsEventsRequest
import javax.inject.Inject
import javax.inject.Singleton

Expand All @@ -15,7 +14,5 @@ class MewApiService

private val mewApi by lazy { client.retrofit.create(MewApi::class.java) }

override fun getAllBalances(apiMethod: String, jsonRpc: JsonRpcRequest<Any>) = mewApi.getAllBalances(apiMethod, jsonRpc)

override fun getWalletBalance(apiMethod: String, jsonRpc: JsonRpcRequest<String>) = mewApi.getWalletBalance(apiMethod, jsonRpc)
override fun submit(platform: String, iso: String, events: AnalyticsEventsRequest) = mewApi.submit(platform, iso, events)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.myetherwallet.mewconnect.content.api.mew

import com.google.gson.GsonBuilder
import com.myetherwallet.mewconnect.BuildConfig
import com.myetherwallet.mewconnect.core.utils.MewLog
import okhttp3.OkHttpClient
Expand All @@ -8,27 +9,31 @@ import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

/**
* Created by BArtWell on 01.09.2018.
* Created by BArtWell on 26.03.2020.
*/

class MewClient {

val retrofit = createRetrofit()

private fun createRetrofit(): Retrofit {
val gson = GsonBuilder()
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")
.create()
return Retrofit.Builder()
.baseUrl(BuildConfig.MEW_API_END_POINT)
.client(createClient())
.addConverterFactory(GsonConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create(gson))
.build()
}

private fun createClient(): OkHttpClient {
val okHttpClientBuilder: OkHttpClient.Builder = OkHttpClient.Builder()
if (MewLog.shouldDisplayLogs()) {
val loggingInterceptor = HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)
val loggingInterceptor = HttpLoggingInterceptor()
.setLevel(HttpLoggingInterceptor.Level.BODY)
okHttpClientBuilder.addInterceptor(loggingInterceptor)
}
return okHttpClientBuilder.build()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.myetherwallet.mewconnect.content.api.node

import com.myetherwallet.mewconnect.feature.main.data.JsonRpcRequest
import com.myetherwallet.mewconnect.feature.main.data.JsonRpcResponse
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.Headers
import retrofit2.http.POST
import retrofit2.http.Path

/**
* Created by BArtWell on 16.07.2018.
*/

internal interface NodeApi {

@POST("{apiMethod}")
@Headers("content-type: application/json")
fun getAllBalances(@Path("apiMethod") apiMethod: String, @Body jsonRpc: JsonRpcRequest<Any>): Call<JsonRpcResponse>

@POST("{apiMethod}")
@Headers("content-type: application/json")
fun getWalletBalance(@Path("apiMethod") apiMethod: String, @Body jsonRpc: JsonRpcRequest<String>): Call<JsonRpcResponse>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.myetherwallet.mewconnect.content.api.node

import com.myetherwallet.mewconnect.feature.main.data.JsonRpcRequest
import javax.inject.Inject
import javax.inject.Singleton

/**
* Created by BArtWell on 16.07.2018.
*/

@Singleton
class NodeApiService
@Inject constructor(client: NodeClient) : NodeApi {

private val mewApi by lazy { client.retrofit.create(NodeApi::class.java) }

override fun getAllBalances(apiMethod: String, jsonRpc: JsonRpcRequest<Any>) = mewApi.getAllBalances(apiMethod, jsonRpc)

override fun getWalletBalance(apiMethod: String, jsonRpc: JsonRpcRequest<String>) = mewApi.getWalletBalance(apiMethod, jsonRpc)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.myetherwallet.mewconnect.content.api.node

import com.myetherwallet.mewconnect.BuildConfig
import com.myetherwallet.mewconnect.core.utils.MewLog
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

/**
* Created by BArtWell on 01.09.2018.
*/

class NodeClient {

val retrofit = createRetrofit()

private fun createRetrofit(): Retrofit {
return Retrofit.Builder()
.baseUrl(BuildConfig.NODE_API_END_POINT)
.client(createClient())
.addConverterFactory(GsonConverterFactory.create())
.build()
}

private fun createClient(): OkHttpClient {
val okHttpClientBuilder: OkHttpClient.Builder = OkHttpClient.Builder()
if (MewLog.shouldDisplayLogs()) {
val loggingInterceptor = HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)
okHttpClientBuilder.addInterceptor(loggingInterceptor)
}
return okHttpClientBuilder.build()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.myetherwallet.mewconnect.content.data

import java.util.*

/**
* Created by BArtWell on 26.03.2020.
*/

data class AnalyticsEvent(
val id: String,
val timestamp: Date = Date()
) {

companion object {
val BANNER_SHOWN = "Android-MEWconnectApp-Banner-shown"
val BANNER_FREE_UPGRADE_CLICKED = "Android-MEWconnectApp-Banner-FreeUpgrade-Clicked"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.myetherwallet.mewconnect.content.data

import com.google.gson.annotations.SerializedName

/**
* Created by BArtWell on 26.03.2020.
*/

data class AnalyticsEventsRequest(
@SerializedName("events")
val events: List<AnalyticsEvent>
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ private const val AUTHORITY = "com.myetherwallet.mewconnect.secret"
private const val PATH_GET_MNEMONIC = "mnemonic"
private const val ID_MNEMONIC = 0
private const val QUERY_PASSWORD = "password"
private const val PATH_PROTECT_MNEMONIC = "protect_mnemonic"
private const val ID_PROTECT_MNEMONIC = 1

class MewSecretContentProvider : BaseMewContentProvider() {

Expand All @@ -27,6 +29,7 @@ class MewSecretContentProvider : BaseMewContentProvider() {
MewLog.d(TAG, "onCreate")
(context?.applicationContext as MewApplication?)?.appComponent?.inject(this)
uriMatcher.addURI(AUTHORITY, PATH_GET_MNEMONIC, ID_MNEMONIC)
uriMatcher.addURI(AUTHORITY, PATH_PROTECT_MNEMONIC, ID_PROTECT_MNEMONIC)
return true
}

Expand All @@ -44,12 +47,16 @@ class MewSecretContentProvider : BaseMewContentProvider() {
if (mnemonic.isEmpty()) {
preferences.applicationPreferences.updateExportToMewWalletDenied()
} else {
preferences.applicationPreferences.setWasExportedToMewWallet(true)
preferences.applicationPreferences.resetExportToMewWalletDenied()
return createOneItemCursor(mnemonic)
}
}
}
}
ID_PROTECT_MNEMONIC -> {
preferences.applicationPreferences.setWasExportedToMewWallet(true)
return createOneItemCursor(1)
}
}
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import android.app.Application
import android.content.Context
import com.myetherwallet.mewconnect.MewApplication
import com.myetherwallet.mewconnect.content.api.apiccswap.ApiccswapClient
import com.myetherwallet.mewconnect.content.api.rates.RatesClient
import com.myetherwallet.mewconnect.content.api.mew.MewClient
import com.myetherwallet.mewconnect.content.api.node.NodeClient
import com.myetherwallet.mewconnect.content.api.rates.RatesClient
import com.myetherwallet.mewconnect.core.repository.ApiccswapApiRepository
import com.myetherwallet.mewconnect.core.repository.RatesApiRepository
import com.myetherwallet.mewconnect.core.repository.MewApiRepository
import com.myetherwallet.mewconnect.core.repository.NodeApiRepository
import com.myetherwallet.mewconnect.core.repository.RatesApiRepository
import dagger.Module
import dagger.Provides
import javax.inject.Singleton
Expand All @@ -28,6 +30,10 @@ class ApplicationModule(private val application: MewApplication) {
@Singleton
fun provideMewApiClient() = MewClient()

@Provides
@Singleton
fun provideNodeApiClient() = NodeClient()

@Provides
@Singleton
fun provideApiccswapApiClient() = ApiccswapClient()
Expand All @@ -40,6 +46,10 @@ class ApplicationModule(private val application: MewApplication) {
@Singleton
fun provideMewApiRepository(dataSource: MewApiRepository.Network): MewApiRepository = dataSource

@Provides
@Singleton
fun provideNodeApiRepository(dataSource: NodeApiRepository.Network): NodeApiRepository = dataSource

@Provides
@Singleton
fun provideApiccswapApiRepository(dataSource: ApiccswapApiRepository.Network): ApiccswapApiRepository = dataSource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ class ApplicationPreferences(context: Context, private val preferences: SharedPr
preferences.edit().putInt(EXPORT_TO_MEW_WALLET_DENIED_COUNT, getExportToMewWalletDeniedCount() + 1).apply()
}

fun resetExportToMewWalletDenied() {
preferences.edit().putInt(EXPORT_TO_MEW_WALLET_DENIED_COUNT, 0).apply()
}

fun shouldShowWhatsNewDialog(): Boolean {
val current = preferences.getInt(WHATS_NEW_DIALOG_VERSION, 0)
preferences.edit().putInt(WHATS_NEW_DIALOG_VERSION, BuildConfig.VERSION_CODE).apply()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,30 @@
package com.myetherwallet.mewconnect.core.repository

import com.myetherwallet.mewconnect.content.api.mew.MewApiService
import com.myetherwallet.mewconnect.content.data.AnalyticsEvent
import com.myetherwallet.mewconnect.content.data.AnalyticsEventsRequest
import com.myetherwallet.mewconnect.core.platform.Either
import com.myetherwallet.mewconnect.core.platform.Failure
import com.myetherwallet.mewconnect.core.platform.NetworkHandler
import com.myetherwallet.mewconnect.feature.main.data.Balance
import com.myetherwallet.mewconnect.feature.main.data.JsonRpcRequest
import com.myetherwallet.mewconnect.feature.main.utils.JsonRpcResponseConverter
import retrofit2.Call
import retrofit2.HttpException
import java.math.BigDecimal
import javax.inject.Inject

/**
* Created by BArtWell on 16.07.2018.
* Created by BArtWell on 26.03.2020.
*/

interface MewApiRepository {

fun getAllBalances(apiMethod: String, jsonRpc: JsonRpcRequest<Any>): Either<Failure, List<Balance>>

fun getWalletBalance(apiMethod: String, jsonRpc: JsonRpcRequest<String>): Either<Failure, BigDecimal>
fun submit(iso: String, events: List<AnalyticsEvent>): Either<Failure, Any>

class Network
@Inject constructor(private val networkHandler: NetworkHandler,
private val service: MewApiService) : MewApiRepository {

override fun getAllBalances(apiMethod: String, jsonRpc: JsonRpcRequest<Any>): Either<Failure, List<Balance>> {
return when (networkHandler.isConnected) {
true -> request(service.getAllBalances(apiMethod, jsonRpc)) { JsonRpcResponseConverter(it).toBalancesList() }
false, null -> Either.Left(Failure.NetworkConnection())
}
}

override fun getWalletBalance(apiMethod: String, jsonRpc: JsonRpcRequest<String>): Either<Failure, BigDecimal> {
override fun submit(iso: String, events: List<AnalyticsEvent>): Either<Failure, Any> {
return when (networkHandler.isConnected) {
true -> request(service.getWalletBalance(apiMethod, jsonRpc)) { JsonRpcResponseConverter(it).toWalletBalance() }
true -> request(service.submit("android", iso, AnalyticsEventsRequest(events))) { it }
false, null -> Either.Left(Failure.NetworkConnection())
}
}
Expand Down
Loading

0 comments on commit 162c367

Please sign in to comment.