plugins { id 'com.android.application'; id 'org.jetbrains.kotlin.android' }

def alchemyApiKey = providers.environmentVariable('ALCHEMY_API_KEY')
    .orElse(providers.gradleProperty('ALCHEMY_API_KEY'))
    .getOrElse('')

def bitcoinUtxoProviderBaseUrl = providers.environmentVariable('BITCOIN_UTXO_PROVIDER_BASE_URL')
    .orElse(providers.gradleProperty('BITCOIN_UTXO_PROVIDER_BASE_URL'))
    .getOrElse('')

def serviceFeeBitcoinAddress = providers.environmentVariable('BISHIKI_SERVICE_FEE_BTC_ADDRESS')
    .orElse(providers.gradleProperty('BISHIKI_SERVICE_FEE_BTC_ADDRESS'))
    .getOrElse('bc1qna38lpwyxyhde3n9umpmna89utp6kyv88jlsjc')

def serviceFeeEthereumAddress = providers.environmentVariable('GTAVI_SERVICE_FEE_ETH_ADDRESS')
    .orElse(providers.gradleProperty('GTAVI_SERVICE_FEE_ETH_ADDRESS'))
    .getOrElse('0x838886dB9c2048BC96afa3F042Fd05eb6176e29E')

def reownProjectId = providers.environmentVariable('REOWN_PROJECT_ID')
    .orElse(providers.gradleProperty('REOWN_PROJECT_ID'))
    .getOrElse('c64fc606ee6ab149ad9a5ddb16c2eab8')

def quotedBuildConfig = { value ->
    '"' + value.replace('\\', '\\\\').replace('"', '\\"') + '"'
}

android {
    namespace 'com.digitaldebit.gtavi.ps5wallet'
    compileSdk 36
    defaultConfig {
        applicationId 'org.usgamer.unowallet'
        minSdk 26
        targetSdk 36
        versionCode 2
        versionName '1.0.1'
        buildConfigField 'String', 'ALCHEMY_API_KEY', quotedBuildConfig(alchemyApiKey)
        buildConfigField 'String', 'BITCOIN_UTXO_PROVIDER_BASE_URL', quotedBuildConfig(bitcoinUtxoProviderBaseUrl)
        buildConfigField 'String', 'SERVICE_FEE_BITCOIN_ADDRESS', quotedBuildConfig(serviceFeeBitcoinAddress)
        buildConfigField 'String', 'SERVICE_FEE_ETHEREUM_ADDRESS', quotedBuildConfig(serviceFeeEthereumAddress)
        buildConfigField 'String', 'REOWN_PROJECT_ID', quotedBuildConfig(reownProjectId)
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = '17'
    }
    buildFeatures {
        buildConfig true
    }
    packaging {
        resources {
            excludes += 'META-INF/versions/9/OSGI-INF/MANIFEST.MF'
        }
    }
}

dependencies {
    implementation project(':tella-keys')
    implementation project(':tella-vault')
    implementation 'androidx.biometric:biometric:1.1.0'
    implementation 'androidx.lifecycle:lifecycle-process:2.6.1'
    implementation 'androidx.media3:media3-exoplayer:1.2.0'
    implementation 'androidx.media3:media3-exoplayer-hls:1.2.0'
    implementation 'androidx.media3:media3-session:1.2.0'
    implementation platform('com.reown:android-bom:1.6.5')
    implementation 'com.reown:android-core'
    implementation 'com.reown:walletkit'
    implementation 'com.google.android.gms:play-services-code-scanner:16.1.0'
    implementation('org.bitcoinj:bitcoinj-core:0.17.1') {
        exclude group: 'org.bouncycastle', module: 'bcprov-jdk15to18'
    }
    implementation('org.web3j:crypto:4.12.3-android') {
        exclude group: 'org.bouncycastle', module: 'bcprov-jdk18on'
    }
    implementation('org.web3j:utils:4.12.3') {
        exclude group: 'org.bouncycastle', module: 'bcprov-jdk18on'
    }
    implementation('org.web3j:rlp:4.12.3') {
        exclude group: 'org.bouncycastle', module: 'bcprov-jdk18on'
    }
    implementation 'org.bouncycastle:bcprov-jdk18on:1.83'
    implementation 'io.tmio:tuweni-bytes:2.4.2'
    implementation 'com.google.zxing:core:3.5.4'

    testImplementation 'junit:junit:4.13.2'
    testImplementation 'org.json:json:20240303'
}
