-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1b52025
Showing
40 changed files
with
1,207 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
/build |
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,57 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'kotlin-android' | ||
id 'dagger.hilt.android.plugin' | ||
id 'kotlin-kapt' | ||
} | ||
|
||
android { | ||
compileSdk 31 | ||
|
||
defaultConfig { | ||
applicationId "com.dev.web3js_android" | ||
minSdk 21 | ||
targetSdk 31 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'androidx.core:core-ktx:1.7.0' | ||
implementation 'androidx.appcompat:appcompat:1.4.0' | ||
implementation 'com.google.android.material:material:1.4.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.1.2' | ||
implementation 'androidx.activity:activity-ktx:1.4.0' | ||
//Viewodel and Livedata | ||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0" | ||
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.0" | ||
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" | ||
|
||
|
||
// Hilt | ||
implementation "com.google.dagger:hilt-android:2.38.1" | ||
kapt "com.google.dagger:hilt-compiler:2.38.1" | ||
|
||
testImplementation 'junit:junit:' | ||
implementation 'org.web3j:core:4.1.0-android' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.3' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' | ||
} |
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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
app/src/androidTest/java/com/dev/web3js_android/ExampleInstrumentedTest.kt
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,24 @@ | ||
package com.dev.web3js_android | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.dev.web3js_android", appContext.packageName) | ||
} | ||
} |
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,25 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.dev.web3js_android"> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> | ||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.Web3JsAndroid"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
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,91 @@ | ||
package com.dev.web3js_android | ||
|
||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
import android.os.StrictMode | ||
import android.view.View | ||
import android.widget.Button | ||
import android.widget.EditText | ||
import android.widget.TextView | ||
import android.widget.Toast | ||
import androidx.activity.viewModels | ||
import androidx.lifecycle.LifecycleOwner | ||
import androidx.lifecycle.Observer | ||
import org.bouncycastle.jce.provider.BouncyCastleProvider | ||
import org.web3j.crypto.Credentials | ||
import org.web3j.crypto.WalletUtils | ||
import org.web3j.protocol.Web3j | ||
import org.web3j.protocol.core.DefaultBlockParameterName | ||
import org.web3j.protocol.core.methods.response.EthGetBalance | ||
import org.web3j.protocol.core.methods.response.TransactionReceipt | ||
import org.web3j.protocol.core.methods.response.Web3ClientVersion | ||
import org.web3j.protocol.http.HttpService | ||
import org.web3j.tx.Transfer | ||
import org.web3j.utils.Convert | ||
import java.io.File | ||
import java.lang.Exception | ||
import java.math.BigDecimal | ||
import java.security.Security | ||
|
||
class MainActivity : AppCompatActivity() { | ||
var web3: Web3j? = null | ||
var file: File? = null | ||
var Walletname: String? = null | ||
var credentials: Credentials? = null | ||
var txtaddress: TextView? = null | ||
val main: Mainviewmodel by viewModels() | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
txtaddress = findViewById(R.id.text_address) | ||
|
||
//enter your own infura api key below | ||
// web3 = Web3j.build(HttpService("https://rinkeby.infura.io/v3/e344d511c77a4f78af0880dc3e90ca7b")) | ||
|
||
// setupBouncyCastle() | ||
|
||
// this is the pathname for the file that will be created and stores the wallet details | ||
val Edtpath = findViewById<EditText>(R.id.walletpath) | ||
val etheriumwalletPath = Edtpath.text.toString() | ||
val Edtpassword = findViewById<EditText>(R.id.password) | ||
val txtbalance = findViewById<TextView>(R.id.text_balance) | ||
val btncnt = findViewById<Button>(R.id.buttonsconnect) | ||
val btnblnc = findViewById<Button>(R.id.buttonbalance) | ||
val creatbtnb = findViewById<Button>(R.id.create_button) | ||
val sendethbtn = findViewById<Button>(R.id.sendEth) | ||
val Edtvalue = findViewById<EditText>(R.id.ethvalue) | ||
|
||
file = File(filesDir.toString() + etheriumwalletPath) // the etherium wallet location | ||
|
||
//create the directory if it does not exist | ||
if (!file!!.mkdirs()) { | ||
file!!.mkdirs() | ||
} else { | ||
Toast.makeText( | ||
applicationContext, "Directory already created", | ||
Toast.LENGTH_LONG | ||
).show() | ||
} | ||
|
||
main.setupBouncyCastle() | ||
main.getbalance.observe(this, Observer { | ||
txtbalance.text = it | ||
}) | ||
btncnt.setOnClickListener { | ||
// connect to the etheruem network | ||
main.connectToEthNetwork(this) | ||
} | ||
btnblnc.setOnClickListener { | ||
main.retrieveBalance(this) | ||
} | ||
creatbtnb.setOnClickListener { | ||
// Create wallet | ||
main.createWallet(Edtpassword.text.toString(), txtaddress, file, this) | ||
} | ||
sendethbtn.setOnClickListener { | ||
main.makeTransaction(Edtvalue.text.toString().toInt(), this) | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.