├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── example ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── mysite │ │ └── mywavesapplication │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── mysite │ │ │ └── mywavesapplication │ │ │ ├── MainActivity.kt │ │ │ ├── app │ │ │ └── App.kt │ │ │ ├── keeper │ │ │ ├── ExampleTransaction.kt │ │ │ └── KeeperFragment.kt │ │ │ ├── sdk │ │ │ └── SdkFragment.kt │ │ │ └── utils │ │ │ └── AppExtentions.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── ic_keeper.xml │ │ ├── ic_launcher_background.xml │ │ ├── ic_sdk.xml │ │ └── shape_rect_outline_basic300_transparent.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── fragment_keeper.xml │ │ └── fragment_sdk.xml │ │ ├── menu │ │ ├── menu_bottom_navigation.xml │ │ └── menu_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── mysite │ └── mywavesapplication │ └── ExampleUnitTest.kt ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── ktlint.gradle ├── settings.gradle └── wavesplatform ├── .gitignore ├── build.gradle ├── gradle.properties ├── maven-push.gradle ├── proguard-rules.pro └── src ├── androidTest ├── AndroidManifest.xml └── java │ └── com │ └── wavesplatform │ └── sdk │ └── net │ └── service │ └── WavesServiceTest.kt ├── main ├── AndroidManifest.xml ├── assets │ ├── environment_mainnet.json │ ├── environment_stagenet.json │ └── environment_testnet.json ├── java │ └── com │ │ └── wavesplatform │ │ └── sdk │ │ ├── WavesSdk.kt │ │ ├── crypto │ │ ├── AESUtil.kt │ │ ├── Base58.kt │ │ ├── CryptoProvider.kt │ │ ├── Hash.kt │ │ ├── PrivateKeyAccount.kt │ │ ├── PublicKeyAccount.kt │ │ ├── WalletManager.kt │ │ ├── WavesCrypto.kt │ │ ├── Words.kt │ │ └── hash │ │ │ ├── Blake2b.java │ │ │ ├── Digest.java │ │ │ ├── DigestEngine.java │ │ │ ├── Keccak256.java │ │ │ └── KeccakCore.java │ │ ├── keeper │ │ ├── KeeperKeys.kt │ │ ├── WavesKeeper.kt │ │ ├── interfaces │ │ │ ├── BaseTransactionParcelable.kt │ │ │ ├── Keeper.kt │ │ │ ├── KeeperCallback.kt │ │ │ ├── KeeperTransaction.kt │ │ │ └── KeeperTransactionResponse.kt │ │ └── model │ │ │ ├── DApp.kt │ │ │ ├── KeeperActionType.kt │ │ │ ├── KeeperDataHolder.kt │ │ │ ├── KeeperIntentResult.kt │ │ │ ├── KeeperProcessData.kt │ │ │ └── KeeperResult.kt │ │ ├── model │ │ ├── request │ │ │ ├── data │ │ │ │ ├── AssetsRequest.kt │ │ │ │ ├── PairRatesRequest.kt │ │ │ │ └── PairRequest.kt │ │ │ ├── matcher │ │ │ │ ├── CancelAllOrderRequest.kt │ │ │ │ ├── CancelOrderRequest.kt │ │ │ │ └── CreateOrderRequest.kt │ │ │ └── node │ │ │ │ ├── AliasTransaction.kt │ │ │ │ ├── BaseTransaction.kt │ │ │ │ ├── BurnTransaction.kt │ │ │ │ ├── DataTransaction.kt │ │ │ │ ├── ExchangeTransaction.kt │ │ │ │ ├── InvokeScriptTransaction.kt │ │ │ │ ├── IssueTransaction.kt │ │ │ │ ├── LeaseCancelTransaction.kt │ │ │ │ ├── LeaseTransaction.kt │ │ │ │ ├── MassTransferTransaction.kt │ │ │ │ ├── ReissueTransaction.kt │ │ │ │ ├── SetAssetScriptTransaction.kt │ │ │ │ ├── SetScriptTransaction.kt │ │ │ │ ├── SponsorshipTransaction.kt │ │ │ │ └── TransferTransaction.kt │ │ └── response │ │ │ ├── ErrorResponse.kt │ │ │ ├── data │ │ │ ├── AliasDataResponse.kt │ │ │ ├── AliasesResponse.kt │ │ │ ├── AssetsInfoResponse.kt │ │ │ ├── CandlesResponse.kt │ │ │ ├── DataServiceMassTransferTransactionResponse.kt │ │ │ ├── LastTradesResponseDataList.kt │ │ │ ├── PairResponse.kt │ │ │ ├── PairsRatesResponse.kt │ │ │ ├── SearchPairResponse.kt │ │ │ └── transaction │ │ │ │ ├── BaseDataListTransactionsResponse.kt │ │ │ │ ├── BaseDataTransactionResponse.kt │ │ │ │ ├── DataMassTransferTransactionResponse.kt │ │ │ │ └── DataMassTransferTransactionResponseWrapperList.kt │ │ │ ├── local │ │ │ └── ServersConfigurationResponse.kt │ │ │ ├── matcher │ │ │ ├── AssetPairOrderResponse.kt │ │ │ ├── CreateOrderResponse.kt │ │ │ ├── MarketResponse.kt │ │ │ ├── MarketsResponse.kt │ │ │ ├── MatcherSettingsResponse.kt │ │ │ └── OrderBookResponse.kt │ │ │ └── node │ │ │ ├── AddressAssetBalanceResponse.kt │ │ │ ├── AssetBalanceResponse.kt │ │ │ ├── AssetsDetailsResponse.kt │ │ │ ├── BlockChainData.kt │ │ │ ├── HeightResponse.kt │ │ │ ├── HistoryTransactionResponse.kt │ │ │ ├── ScriptInfoResponse.kt │ │ │ ├── UtilsTimeResponse.kt │ │ │ ├── WavesBalanceResponse.kt │ │ │ └── transaction │ │ │ ├── AliasTransactionResponse.kt │ │ │ ├── BaseTransactionResponse.kt │ │ │ ├── BurnTransactionResponse.kt │ │ │ ├── DataTransactionResponse.kt │ │ │ ├── ExchangeTransactionResponse.kt │ │ │ ├── InvokeScriptTransactionResponse.kt │ │ │ ├── IssueTransactionResponse.kt │ │ │ ├── LeaseCancelTransactionResponse.kt │ │ │ ├── LeaseTransactionResponse.kt │ │ │ ├── MassTransferTransactionResponse.kt │ │ │ ├── ReissueTransactionResponse.kt │ │ │ ├── SetAssetScriptTransactionResponse.kt │ │ │ ├── SetScriptTransactionResponse.kt │ │ │ ├── SponsorshipTransactionResponse.kt │ │ │ └── TransferTransactionResponse.kt │ │ ├── net │ │ ├── CallAdapterFactory.kt │ │ ├── NetworkException.kt │ │ ├── OnErrorListener.kt │ │ ├── WavesService.kt │ │ └── service │ │ │ ├── DataService.kt │ │ │ ├── MatcherService.kt │ │ │ └── NodeService.kt │ │ └── utils │ │ ├── ActivityExtentions.kt │ │ ├── AddressExtensions.kt │ │ ├── Environment.kt │ │ ├── Extensions.kt │ │ ├── Identicon.kt │ │ ├── KeeperExtentions.kt │ │ ├── MoneyUtil.kt │ │ ├── RootUtil.kt │ │ ├── RxUtil.kt │ │ ├── SignUtil.kt │ │ ├── ThrowableExtensions.kt │ │ ├── WavesConstants.kt │ │ ├── _NumberExt.kt │ │ └── inline │ │ ├── ActivityResult.kt │ │ ├── ActivityResultFragment.kt │ │ └── InlineActivityResult.kt └── res │ └── values │ └── strings.xml └── test ├── java └── com │ └── wavesplatform │ └── sdk │ └── crypto │ └── WavesCryptoTest.kt └── resources └── robolectric.properties /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | 19 | # Android Studio 20 | .idea/ 21 | *.iml 22 | 23 | # Local configuration file (sdk path, etc) 24 | local.properties 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Mac OS X clutter 30 | *.DS_Store 31 | 32 | # Firebase config 33 | google-services.json 34 | 35 | # Maven 36 | target/ 37 | pom.xml.tag 38 | pom.xml.releaseBackup 39 | pom.xml.versionsBackup 40 | pom.xml.next 41 | release.properties 42 | mvnrepository.properties 43 | *.pom -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 WavesPlatform 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext.kotlin_version = '1.4.10' 5 | ext.coroutinesVersion = "1.4.1" 6 | repositories { 7 | google() 8 | maven { url "https://jitpack.io" } 9 | maven { url 'http://dl.bintray.com/dev-fingerlinks/maven' } 10 | maven { url "http://dl.bintray.com/novoda/maven" } 11 | maven { url "https://plugins.gradle.org/m2/" } 12 | } 13 | dependencies { 14 | classpath 'com.android.tools.build:gradle:3.5.4' 15 | classpath 'com.dicedmelon.gradle:jacoco-android:0.1.1' 16 | classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.4.0' 17 | classpath 'com.google.gms:google-services:4.3.2' 18 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 19 | } 20 | } 21 | 22 | allprojects { 23 | repositories { 24 | google() 25 | maven { url "https://jitpack.io" } 26 | maven { url 'http://dl.bintray.com/dev-fingerlinks/maven' } 27 | maven { url "https://plugins.gradle.org/m2/" } 28 | } 29 | } 30 | 31 | task clean(type: Delete) { 32 | delete rootProject.buildDir 33 | } -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | 19 | # Android Studio 20 | .idea/ 21 | *.iml 22 | 23 | # Local configuration file (sdk path, etc) 24 | local.properties 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Mac OS X clutter 30 | *.DS_Store 31 | 32 | # Firebase config 33 | google-services.json -------------------------------------------------------------------------------- /example/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | apply from: "$rootDir/ktlint.gradle" 5 | 6 | android { 7 | compileSdkVersion 28 8 | defaultConfig { 9 | applicationId "com.mysite.mywavesapplication" 10 | minSdkVersion 21 11 | targetSdkVersion 28 12 | versionCode 1 13 | versionName "1.0" 14 | vectorDrawables.useSupportLibrary = true 15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | implementation project(':wavesplatform') 27 | implementation 'io.reactivex.rxjava2:rxjava:2.2.10' 28 | 29 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 30 | implementation 'androidx.appcompat:appcompat:1.1.0' 31 | implementation 'com.google.android.material:material:1.0.0' 32 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' 33 | implementation 'com.google.code.gson:gson:2.8.5' 34 | testImplementation 'junit:junit:4.12' 35 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 36 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' 37 | } 38 | -------------------------------------------------------------------------------- /example/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /example/src/androidTest/java/com/mysite/mywavesapplication/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.mysite.mywavesapplication 2 | 3 | import androidx.test.ext.junit.runners.AndroidJUnit4 4 | import androidx.test.platform.app.InstrumentationRegistry 5 | import org.junit.Assert.assertEquals 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | /** 10 | * Instrumented test, which will execute on an Android device. 11 | * 12 | * See [testing documentation](http://d.android.com/tools/testing). 13 | */ 14 | @RunWith(AndroidJUnit4::class) 15 | class ExampleInstrumentedTest { 16 | @Test 17 | fun useAppContext() { 18 | // Context of the app under test. 19 | val appContext = InstrumentationRegistry.getInstrumentation().context 20 | assertEquals("com.mysite.mywavesapplication", appContext.packageName) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /example/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 15 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/src/main/java/com/mysite/mywavesapplication/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.mysite.mywavesapplication 2 | 3 | import android.os.Bundle 4 | import android.view.Menu 5 | import android.view.MenuItem 6 | import androidx.appcompat.app.AppCompatActivity 7 | import com.mysite.mywavesapplication.keeper.KeeperFragment 8 | import com.mysite.mywavesapplication.sdk.SdkFragment 9 | import com.wavesplatform.sdk.WavesSdk 10 | import com.wavesplatform.sdk.utils.Environment 11 | import kotlinx.android.synthetic.main.activity_main.* 12 | 13 | class MainActivity : AppCompatActivity() { 14 | 15 | private val fragments = arrayListOf( 16 | R.string.bottom_navigation_sdk_title to SdkFragment.newInstance(), 17 | R.string.bottom_navigation_keeper_title to KeeperFragment.newInstance() 18 | ) 19 | 20 | private var currentFragment = fragments.first().second 21 | 22 | override fun onCreate(savedInstanceState: Bundle?) { 23 | super.onCreate(savedInstanceState) 24 | setContentView(R.layout.activity_main) 25 | setSupportActionBar(toolbar) 26 | 27 | setupBottomNavigation() 28 | } 29 | 30 | private fun setupBottomNavigation() { 31 | bottom_navigation.setOnNavigationItemSelectedListener { item -> 32 | when (item.itemId) { 33 | R.id.action_keeper -> { 34 | showFragment(fragments[KEEPER_POSITION]) 35 | } 36 | R.id.action_sdk -> { 37 | showFragment(fragments[SDK_POSITION]) 38 | } 39 | else -> { 40 | showFragment(fragments[SDK_POSITION]) 41 | } 42 | } 43 | return@setOnNavigationItemSelectedListener true 44 | } 45 | 46 | showFragment(fragments[SDK_POSITION]) 47 | } 48 | 49 | private fun showFragment(pair: Pair) { 50 | val (title, fragment) = pair 51 | val fragmentTitle = getString(title) 52 | 53 | toolbar.title = fragmentTitle 54 | 55 | if (supportFragmentManager.findFragmentByTag(fragmentTitle) == null) { 56 | supportFragmentManager.beginTransaction() 57 | .hide(currentFragment) 58 | .add(R.id.frame_fragment_container, fragment, fragmentTitle) 59 | .show(fragment) 60 | .commitAllowingStateLoss() 61 | } else { 62 | supportFragmentManager.beginTransaction() 63 | .hide(currentFragment) 64 | .show(fragment) 65 | .commitAllowingStateLoss() 66 | } 67 | currentFragment = fragment 68 | } 69 | 70 | override fun onCreateOptionsMenu(menu: Menu): Boolean { 71 | menuInflater.inflate(R.menu.menu_main, menu) 72 | 73 | menu.findItem(R.id.action_change_environment).title = 74 | when (WavesSdk.getEnvironment()) { 75 | Environment.MAIN_NET -> { 76 | getString(R.string.environment_main) 77 | } 78 | Environment.TEST_NET -> { 79 | getString(R.string.environment_test) 80 | } 81 | Environment.STAGE_NET -> { 82 | getString(R.string.environment_stage) 83 | } 84 | else -> { 85 | getString(R.string.environment_custom) 86 | } 87 | } 88 | 89 | return true 90 | } 91 | 92 | override fun onOptionsItemSelected(item: MenuItem): Boolean { 93 | return when (item.itemId) { 94 | R.id.action_change_environment -> { 95 | when (item.title) { 96 | getString(R.string.environment_main) -> { 97 | item.title = getString(R.string.environment_test) 98 | WavesSdk.setEnvironment(Environment.TEST_NET) 99 | } 100 | getString(R.string.environment_test) -> { 101 | item.title = getString(R.string.environment_stage) 102 | WavesSdk.setEnvironment(Environment.STAGE_NET) 103 | } 104 | getString(R.string.environment_stage) -> { 105 | item.title = getString(R.string.environment_main) 106 | WavesSdk.setEnvironment(Environment.MAIN_NET) 107 | } 108 | else -> { 109 | item.title = getString(R.string.environment_test) 110 | WavesSdk.setEnvironment(Environment.TEST_NET) 111 | } 112 | } 113 | 114 | return true 115 | } 116 | else -> super.onOptionsItemSelected(item) 117 | } 118 | } 119 | 120 | companion object { 121 | const val SDK_POSITION = 0 122 | const val KEEPER_POSITION = 1 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /example/src/main/java/com/mysite/mywavesapplication/app/App.kt: -------------------------------------------------------------------------------- 1 | package com.mysite.mywavesapplication.app 2 | 3 | import android.app.Application 4 | import com.wavesplatform.sdk.WavesSdk 5 | import com.wavesplatform.sdk.utils.Environment 6 | 7 | class App : Application() { 8 | 9 | override fun onCreate() { 10 | super.onCreate() 11 | 12 | WavesSdk.init(this, Environment.TEST_NET) 13 | 14 | // or use Environment.TEST_NET for switch to Test-Net 15 | // WavesSdk.init(this, Environment.TEST_NET) 16 | 17 | // You must configure dApp if you want to use Waves Keeper 18 | WavesSdk.keeper().configureDApp( 19 | this, 20 | "My Waves DApp", 21 | "https://avatars2.githubusercontent.com/u/18295288" 22 | ) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /example/src/main/java/com/mysite/mywavesapplication/sdk/SdkFragment.kt: -------------------------------------------------------------------------------- 1 | package com.mysite.mywavesapplication.sdk 2 | 3 | import android.annotation.SuppressLint 4 | import android.os.Bundle 5 | import android.util.Log 6 | import android.view.LayoutInflater 7 | import android.view.View 8 | import android.view.ViewGroup 9 | import android.widget.Toast 10 | import androidx.core.text.HtmlCompat 11 | import androidx.fragment.app.Fragment 12 | import com.mysite.mywavesapplication.R 13 | import com.mysite.mywavesapplication.utils.copyToClipboard 14 | import com.wavesplatform.sdk.WavesSdk 15 | import com.wavesplatform.sdk.crypto.WavesCrypto 16 | import com.wavesplatform.sdk.net.NetworkException 17 | import com.wavesplatform.sdk.net.OnErrorListener 18 | import com.wavesplatform.sdk.utils.RxUtil 19 | import com.wavesplatform.sdk.utils.getScaledAmount 20 | import io.reactivex.disposables.CompositeDisposable 21 | import kotlinx.android.synthetic.main.fragment_sdk.* 22 | 23 | /** 24 | * A simple [Fragment] subclass. 25 | */ 26 | @SuppressLint("SetTextI18n") 27 | class SdkFragment : androidx.fragment.app.Fragment() { 28 | 29 | // For Activity or Fragment add Observables in CompositeDisposable 30 | private val compositeDisposable = CompositeDisposable() 31 | 32 | override fun onCreateView( 33 | inflater: LayoutInflater, 34 | container: ViewGroup?, 35 | savedInstanceState: Bundle? 36 | ): View = inflater.inflate(R.layout.fragment_sdk, container, false) 37 | 38 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 39 | super.onViewCreated(view, savedInstanceState) 40 | 41 | /** 42 | * First you must init() WavesSdk in [App] and add Internet permission 43 | * Put your seed in const [MainActivity.Companion.SEED] from https://testnet.wavesplatform.com 44 | * or https://client.wavesplatform.com 45 | */ 46 | 47 | button_generate_seed.setOnClickListener { 48 | // Generate or add your seed 49 | val newSeed = WavesCrypto.randomSeed() 50 | text_seed.text = HtmlCompat.fromHtml( 51 | "New seed is: $newSeed\"", 52 | HtmlCompat.FROM_HTML_MODE_LEGACY 53 | ) 54 | } 55 | 56 | button_load_balance.setOnClickListener { 57 | val address = 58 | WavesCrypto.addressBySeed( 59 | SEED, // load with hardcoded seed 60 | WavesSdk.getEnvironment().chainId.toString() 61 | ) 62 | // Create request to Node service about address balance 63 | getWavesBalance(address) 64 | // Examples of transactions available in [WavesServiceTest] 65 | } 66 | 67 | text_seed.setOnClickListener { 68 | activity?.copyToClipboard(text_seed.text.toString()) 69 | } 70 | 71 | handleServiceErrors() 72 | } 73 | 74 | private fun handleServiceErrors() { 75 | WavesSdk.service().addOnErrorListener(object : OnErrorListener { 76 | override fun onError(exception: NetworkException) { 77 | // Handle NetworkException here 78 | } 79 | }) 80 | } 81 | 82 | private fun getWavesBalance(address: String) { 83 | compositeDisposable.add( 84 | WavesSdk.service() 85 | .getNode() // You can choose different Waves services: node, matcher and data service 86 | .addressesBalance(address) // Here methods of service 87 | .compose(RxUtil.applyObservableDefaultSchedulers()) 88 | .subscribe( 89 | { wavesBalance -> 90 | // Do something on success, now we have wavesBalance.balance in satoshi in Long 91 | Toast.makeText( 92 | requireActivity(), 93 | "Balance is : ${getScaledAmount(wavesBalance.balance, 8)} Waves", 94 | Toast.LENGTH_SHORT 95 | ) 96 | .show() 97 | }, 98 | { error -> 99 | // Do something on fail 100 | val errorMessage = "Can't get addressesBalance! + ${error.message}" 101 | Log.e("MainActivity", errorMessage) 102 | error.printStackTrace() 103 | Toast.makeText(requireActivity(), errorMessage, Toast.LENGTH_SHORT).show() 104 | } 105 | ) 106 | ) 107 | } 108 | 109 | // Unsubscribe after destroy 110 | override fun onDestroy() { 111 | super.onDestroy() 112 | compositeDisposable.clear() 113 | } 114 | 115 | companion object { 116 | const val SEED = "" 117 | 118 | fun newInstance(): SdkFragment { 119 | return SdkFragment() 120 | } 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /example/src/main/java/com/mysite/mywavesapplication/utils/AppExtentions.kt: -------------------------------------------------------------------------------- 1 | package com.mysite.mywavesapplication.utils 2 | 3 | import android.content.ClipData 4 | import android.content.ClipboardManager 5 | import android.content.Context 6 | import android.widget.Toast 7 | 8 | fun Context.copyToClipboard(text: String) { 9 | val clipboard = 10 | getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager? 11 | val clip = ClipData.newPlainText("seed", text) 12 | clipboard?.primaryClip = clip 13 | 14 | Toast.makeText(this, "Text is copied to the clipboard", Toast.LENGTH_SHORT) 15 | .show() 16 | } 17 | -------------------------------------------------------------------------------- /example/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /example/src/main/res/drawable/ic_keeper.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /example/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 64 | 66 | 68 | 70 | 72 | 74 | 75 | -------------------------------------------------------------------------------- /example/src/main/res/drawable/ic_sdk.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /example/src/main/res/drawable/shape_rect_outline_basic300_transparent.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 11 | -------------------------------------------------------------------------------- /example/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 20 | 21 | 22 | 23 | 29 | 30 | 37 | -------------------------------------------------------------------------------- /example/src/main/res/layout/fragment_keeper.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 20 | 21 | 28 | 29 | 36 | 37 | 38 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 60 | 61 |