├── .gitignore ├── LICENSE.txt ├── README.md ├── app ├── .gitignore ├── build.gradle.kts ├── google-services.json ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── particle │ │ └── demo │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── network │ │ │ └── particle │ │ │ └── demo │ │ │ ├── App.kt │ │ │ ├── ui │ │ │ ├── ApiDemoActivity.kt │ │ │ ├── AuthDemoActivity.kt │ │ │ ├── MainActivity.kt │ │ │ ├── ParticleWalletLoginDemoActivity.kt │ │ │ ├── SettingActivity.kt │ │ │ ├── WalletDemoActivity.kt │ │ │ ├── adapter │ │ │ │ ├── BannerAdapter.kt │ │ │ │ ├── ChainInfoChoiceListAdapter.kt │ │ │ │ └── ConnectChoiceListAdapter.kt │ │ │ └── base │ │ │ │ └── DemoBaseActivity.kt │ │ │ └── utils │ │ │ ├── DemoChainUtils.kt │ │ │ ├── ParticleInitUtils.kt │ │ │ ├── StreamUtils.kt │ │ │ ├── TestAccount.kt │ │ │ └── TransactionMock.kt │ └── res │ │ ├── anim │ │ ├── push_bottom_in.xml │ │ ├── push_bottom_out.xml │ │ └── rotate_loading.xml │ │ ├── drawable-xxxhdpi │ │ ├── bg_login.webp │ │ ├── ic_launcher_round.png │ │ ├── page1.png │ │ ├── page2.png │ │ ├── page3.png │ │ └── page4.png │ │ ├── drawable │ │ ├── bg_login_item.xml │ │ ├── bg_login_item_press.xml │ │ ├── bg_login_item_selector.xml │ │ ├── ic_bg.png │ │ ├── ic_logo.png │ │ ├── twotone_arrow_back_24.xml │ │ └── twotone_settings_24.xml │ │ ├── layout │ │ ├── activity_api_demo.xml │ │ ├── activity_api_ref_list.xml │ │ ├── activity_auth_demo.xml │ │ ├── activity_main.xml │ │ ├── activity_particle_wallet_demo.xml │ │ ├── activity_setting.xml │ │ ├── activity_wallet_demo.xml │ │ ├── banner_item.xml │ │ └── item_chain_choice.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_background.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_background.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_background.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_background.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_background.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── raw │ │ └── typed_data.json │ │ ├── values-night │ │ └── themes.xml │ │ └── values │ │ ├── colors.xml │ │ ├── ic_launcher_background.xml │ │ ├── strings.xml │ │ └── themes.xml │ └── test │ └── java │ └── com │ └── particle │ └── demo │ └── ExampleUnitTest.kt ├── build.gradle.kts ├── gradle.properties ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle.kts /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | .cxx 10 | local.properties 11 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Particle Android 2 | 3 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/network.particle/auth-service/badge.svg?style=flat)](https://search.maven.org/search?q=g:network.particle) 4 | 5 | 👉 [Download built version from Google Play](https://play.google.com/store/apps/details?id=network.particle.auth) 6 | 7 | This repository contains [Auth Service](https://docs.particle.network/auth-core-service/introduction) and [Wallet Service](https://docs.particle.network/wallet-service/introduction) sample source. It supports Solana and all EVM-compatiable chains now, more chains and more features coming soon! Learn more visit [Particle Network](https://docs.particle.network/). 8 | 9 | ## Getting Started 10 | 11 | * Clone the repo. 12 | * Add below particle sdk config to `gradle.properties`. 13 | 14 | ``` 15 | particle.network.project_client_key=xxx 16 | particle.network.project_id=xxx 17 | particle.network.app_id=xxx 18 | ``` 19 | 20 | Replace `xxx` with the new values created in the [Dashboard](https://dashboard.particle.network/#/login). 21 | 22 | ## Build 23 | 24 | ``` 25 | ./gradlew assembleDebug 26 | ``` 27 | 28 | ## Features 29 | 30 | 1. Auth login with email, phone, facebook, google, apple etc. 31 | 2. Logout. 32 | 3. Open Wallet. 33 | 4. Change Chain Id. 34 | 5. Check our official dev docs: https://docs.particle.network/ 35 | 36 | ## Docs 37 | 38 | 1. https://docs.particle.network/auth-service/sdks/android 39 | 2. https://docs.particle.network/wallet-service/sdks/android 40 | 41 | ## Give Feedback 42 | 43 | Please report bugs or issues to [particle-android/issues](https://github.com/Particle-Network/particle-android/issues) 44 | 45 | You can also join our [Discord](https://discord.gg/2y44qr6CR2). 46 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | kotlin("android") 4 | kotlin("kapt") 5 | } 6 | val sdkVersion = "2.0.11" 7 | 8 | 9 | android { 10 | 11 | compileSdk = libs.versions.compileSdk.get().toInt() 12 | defaultConfig { 13 | applicationId = "network.particle.demos" 14 | minSdk = libs.versions.minSdk.get().toInt() 15 | targetSdk = libs.versions.targetSdk.get().toInt() 16 | versionCode = 5 17 | versionName = "$sdkVersion" 18 | vectorDrawables { 19 | useSupportLibrary = true 20 | } 21 | ndk { 22 | abiFilters.add("armeabi-v7a") 23 | abiFilters.add("arm64-v8a") 24 | } 25 | 26 | manifestPlaceholders["PN_PROJECT_ID"] = "864a5dd6-9fa2-450e-88f6-0920348d069c" 27 | manifestPlaceholders["PN_PROJECT_CLIENT_KEY"] = "cVq5PW9A8D5eQmps6ugwty2nfKpG0W825ijoqXk8" 28 | manifestPlaceholders["PN_APP_ID"] = "3f574cac-267e-4ffa-aa2e-f284ab81e95e" 29 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" 30 | } 31 | 32 | buildTypes { 33 | debug { 34 | applicationIdSuffix = ".debug" 35 | isMinifyEnabled = false 36 | } 37 | 38 | release { 39 | isMinifyEnabled = true 40 | proguardFiles( 41 | getDefaultProguardFile("proguard-android-optimize.txt"), 42 | "proguard-rules.pro" 43 | ) 44 | } 45 | } 46 | compileOptions { 47 | sourceCompatibility(JavaVersion.VERSION_17) 48 | targetCompatibility(JavaVersion.VERSION_17) 49 | } 50 | kotlinOptions { 51 | jvmTarget = JavaVersion.VERSION_17.toString() 52 | } 53 | 54 | packagingOptions { 55 | resources { 56 | excludes += "/META-INF/{AL2.0,LGPL2.1}" 57 | } 58 | } 59 | 60 | dataBinding { 61 | isEnabled = true 62 | } 63 | namespace = "com.minijoy.demo" 64 | } 65 | 66 | 67 | 68 | 69 | dependencies { 70 | modules { 71 | module("org.bouncycastle:bcprov-jdk15to18") { 72 | replacedBy("org.bouncycastle:bcprov-jdk15on") 73 | } 74 | module("org.bouncycastle:bcprov-jdk18on") { 75 | replacedBy("org.bouncycastle:bcprov-jdk15on") 76 | } 77 | } 78 | implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar", "*.aar")))) 79 | implementation("network.particle:connect:$sdkVersion") 80 | implementation("network.particle:connect-kit:$sdkVersion") 81 | implementation("network.particle:connect-evm-adapter:$sdkVersion") 82 | implementation("network.particle:connect-solana-adapter:$sdkVersion") 83 | implementation("network.particle:connect-phantom-adapter:$sdkVersion") 84 | implementation("network.particle:connect-wallet-connect-adapter:$sdkVersion") 85 | implementation("network.particle:connect-auth-core-adapter:$sdkVersion") 86 | implementation("network.particle:api-service:$sdkVersion") 87 | 88 | implementation("network.particle:wallet-service:$sdkVersion") 89 | implementation("network.particle:aa-service:$sdkVersion") 90 | 91 | 92 | implementation(libs.appcompat) 93 | implementation(libs.material) 94 | implementation(libs.okhttp3.logging.interceptor) 95 | implementation(libs.utilcodex) 96 | implementation(libs.refresh.layout) 97 | 98 | implementation(libs.coil) 99 | implementation(libs.coil.svg) 100 | implementation(libs.coil.gif) 101 | implementation(libs.immersionbar) 102 | implementation(libs.bannerviewpager) 103 | 104 | 105 | } 106 | 107 | tasks.withType { 108 | useJUnitPlatform() 109 | } -------------------------------------------------------------------------------- /app/google-services.json: -------------------------------------------------------------------------------- 1 | { 2 | "project_info": { 3 | "project_number": "407535041336", 4 | "project_id": "particle-network-8578c", 5 | "storage_bucket": "particle-network-8578c.appspot.com" 6 | }, 7 | "client": [ 8 | { 9 | "client_info": { 10 | "mobilesdk_app_id": "1:407535041336:android:8ed8c8df4f5aeacf641fcd", 11 | "android_client_info": { 12 | "package_name": "com.minijoy.demo" 13 | } 14 | }, 15 | "oauth_client": [ 16 | { 17 | "client_id": "407535041336-hlabpp79u4ku93opnq19o24frta7rk8n.apps.googleusercontent.com", 18 | "client_type": 3 19 | } 20 | ], 21 | "api_key": [ 22 | { 23 | "current_key": "AIzaSyCR4t5TxMaATtApf6cWpdiWdZpF0-XEdFo" 24 | } 25 | ], 26 | "services": { 27 | "appinvite_service": { 28 | "other_platform_oauth_client": [ 29 | { 30 | "client_id": "407535041336-hlabpp79u4ku93opnq19o24frta7rk8n.apps.googleusercontent.com", 31 | "client_type": 3 32 | } 33 | ] 34 | } 35 | } 36 | }, 37 | { 38 | "client_info": { 39 | "mobilesdk_app_id": "1:407535041336:android:cc6b08addd8ea56e641fcd", 40 | "android_client_info": { 41 | "package_name": "com.particle.demo" 42 | } 43 | }, 44 | "oauth_client": [ 45 | { 46 | "client_id": "407535041336-hlabpp79u4ku93opnq19o24frta7rk8n.apps.googleusercontent.com", 47 | "client_type": 3 48 | } 49 | ], 50 | "api_key": [ 51 | { 52 | "current_key": "AIzaSyCR4t5TxMaATtApf6cWpdiWdZpF0-XEdFo" 53 | } 54 | ], 55 | "services": { 56 | "appinvite_service": { 57 | "other_platform_oauth_client": [ 58 | { 59 | "client_id": "407535041336-hlabpp79u4ku93opnq19o24frta7rk8n.apps.googleusercontent.com", 60 | "client_type": 3 61 | } 62 | ] 63 | } 64 | } 65 | } 66 | ], 67 | "configuration_version": "1" 68 | } -------------------------------------------------------------------------------- /app/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 | 23 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/particle/demo/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.particle.demo 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.particle.demo", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 25 | 26 | 27 | 28 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 83 | 84 | 87 | 88 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /app/src/main/java/network/particle/demo/App.kt: -------------------------------------------------------------------------------- 1 | package network.particle.demo 2 | 3 | import android.app.Application 4 | import com.blankj.utilcode.util.SPUtils 5 | import com.google.android.material.color.DynamicColors 6 | import com.particle.base.* 7 | import network.particle.chains.ChainInfo 8 | import network.particle.demo.utils.ParticleInitUtils 9 | 10 | 11 | class App : Application() { 12 | var isDebug = false 13 | 14 | override fun onCreate() { 15 | super.onCreate() 16 | DynamicColors.applyToActivitiesIfAvailable(this) 17 | ParticleInitUtils.initWallet(this, ChainInfo.Ethereum) 18 | } 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/network/particle/demo/ui/ApiDemoActivity.kt: -------------------------------------------------------------------------------- 1 | package network.particle.demo.ui 2 | 3 | import androidx.lifecycle.lifecycleScope 4 | import com.blankj.utilcode.util.LogUtils 5 | import com.blankj.utilcode.util.ToastUtils 6 | import com.connect.common.TransactionCallback 7 | import com.connect.common.model.ConnectError 8 | import com.gyf.immersionbar.ImmersionBar 9 | import com.minijoy.demo.R 10 | import com.minijoy.demo.databinding.ActivityApiDemoBinding 11 | import com.particle.api.evm 12 | import com.particle.api.service.data.ContractParams 13 | import com.particle.auth.AuthCore 14 | import com.particle.base.ParticleNetwork 15 | import com.particle.base.model.MobileWCWallet 16 | import com.particle.base.model.MobileWCWalletName 17 | import com.particle.connect.ParticleConnect 18 | import com.particle.gui.utils.WalletUtils 19 | import kotlinx.coroutines.launch 20 | import network.particle.demo.ui.base.DemoBaseActivity 21 | import java.math.BigDecimal 22 | import kotlin.math.pow 23 | 24 | class ApiDemoActivity : DemoBaseActivity(R.layout.activity_api_demo) { 25 | override fun initView() { 26 | super.initView() 27 | ImmersionBar.with(this).statusBarColor(android.R.color.transparent).titleBar( 28 | binding.toolbar 29 | ).init() 30 | } 31 | 32 | override fun setListeners() { 33 | super.setListeners() 34 | binding.toolbar.setNavigationOnClickListener { finish() } 35 | val contractAddress = "0x84b9B910527Ad5C03A9Ca831909E21e236EA7b06" 36 | val from = "0x4F96Fe3b7A6Cf9725f59d353F723c1bDb64CA6Aa" 37 | val to = "0x4F96Fe3b7A6Cf9725f59d353F723c1bDb64CA6Aa" 38 | val amount = BigDecimal.valueOf(0.00001 * 10.0.pow(18.0)).toPlainString() 39 | val address = if (ParticleNetwork.chainInfo.isEvmChain()) { 40 | AuthCore.evm.getAddress() 41 | } else { 42 | AuthCore.solana.getAddress() 43 | } 44 | binding.erc20Transfer.setOnClickListener { 45 | 46 | lifecycleScope.launch { 47 | try { 48 | val contractParams = ContractParams.erc20Transfer(contractAddress, to, amount) 49 | val iTxData = ParticleNetwork.evm.createTransaction( 50 | from, contractParams = contractParams 51 | ) 52 | 53 | val adapter = ParticleConnect.getAdapters() 54 | .first { it.name == MobileWCWalletName.AuthCore.name } 55 | val data = iTxData!!.serialize() 56 | adapter.signAndSendTransaction( 57 | address!!, 58 | data, 59 | object : TransactionCallback { 60 | override fun onError(error: ConnectError) { 61 | LogUtils.d("sign onError") 62 | } 63 | 64 | override fun onTransaction(transactionId: String?) { 65 | LogUtils.d("sign onTransaction") 66 | } 67 | }) 68 | 69 | // LogUtils.d(iTxData, "hexData:${iTxData?.serialize()}") 70 | // ToastUtils.showLong("hexData:${iTxData?.serialize()}") 71 | } catch (e: Exception) { 72 | e.printStackTrace() 73 | ToastUtils.showLong(e.message) 74 | } 75 | 76 | } 77 | 78 | } 79 | binding.erc20Approve.setOnClickListener { 80 | // ParticleNetwork.evm.erc20Approve() 81 | lifecycleScope.launch { 82 | try { 83 | val contractParams = ContractParams.erc20Approve(contractAddress, to, amount) 84 | val iTxData = ParticleNetwork.evm.createTransaction( 85 | address!!, 86 | to, 87 | amount, 88 | type = "0x0", 89 | contractParams = contractParams 90 | ) 91 | LogUtils.d(iTxData, "hexData:${iTxData?.serialize()}") 92 | ToastUtils.showLong("hexData:${iTxData?.serialize()}") 93 | } catch (e: Exception) { 94 | e.printStackTrace() 95 | ToastUtils.showLong(e.message) 96 | } 97 | 98 | } 99 | } 100 | binding.erc20TransferFrom.setOnClickListener { 101 | // ParticleNetwork.evm.erc20TransferFrom() 102 | lifecycleScope.launch { 103 | try { 104 | val contractParams = 105 | ContractParams.erc20TransferFrom(contractAddress, from, to, amount) 106 | val iTxData = ParticleNetwork.evm.createTransaction( 107 | from, to, amount, type = "0x0", contractParams = contractParams 108 | ) 109 | LogUtils.d(iTxData, "hexData:${iTxData?.serialize()}") 110 | ToastUtils.showLong("hexData:${iTxData?.serialize()}") 111 | } catch (e: Exception) { 112 | e.printStackTrace() 113 | ToastUtils.showLong(e.message) 114 | } 115 | 116 | } 117 | } 118 | binding.erc721SafeTransferFrom.setOnClickListener { 119 | // ParticleNetwork.evm.erc721SafeTransferFrom() 120 | // ToastUtils.showLong(getString(R.string.api_tips)) 121 | lifecycleScope.launch { 122 | try { 123 | val contractParams = 124 | ContractParams.erc721SafeTransferFrom(contractAddress, from, to, amount) 125 | val iTxData = ParticleNetwork.evm.createTransaction( 126 | from, to, amount, type = "0x0", contractParams = contractParams 127 | ) 128 | LogUtils.d(iTxData, "hexData:${iTxData?.serialize()}") 129 | ToastUtils.showLong("hexData:${iTxData?.serialize()}") 130 | } catch (e: Exception) { 131 | e.printStackTrace() 132 | ToastUtils.showLong(e.message) 133 | } 134 | } 135 | } 136 | binding.erc1155SafeTransferFrom.setOnClickListener { 137 | // ParticleNetwork.evm.erc1155SafeTransferFrom() 138 | 139 | lifecycleScope.launch { 140 | try { 141 | val id = "" 142 | val data = "0x0" 143 | val contractParams = ContractParams.erc1155SafeTransferFrom( 144 | contractAddress, from, to, id, amount, data 145 | ) 146 | val iTxData = ParticleNetwork.evm.createTransaction( 147 | address!!, 148 | to, 149 | amount, 150 | type = "0x0", 151 | contractParams = contractParams 152 | ) 153 | LogUtils.d(iTxData, "hexData:${iTxData?.serialize()}") 154 | ToastUtils.showLong("hexData:${iTxData?.serialize()}") 155 | } catch (e: Exception) { 156 | e.printStackTrace() 157 | ToastUtils.showLong(e.message) 158 | } 159 | } 160 | 161 | } 162 | binding.customAbi.setOnClickListener { 163 | ToastUtils.showLong(getString(R.string.pn_api_tips)) 164 | // ParticleNetwork.evm.erc1155SafeTransferFrom() 165 | lifecycleScope.launch { 166 | try { 167 | val contractParams = ContractParams.customAbiEncodeFunctionCall( 168 | contractAddress, "custom_revealMysteryBox", listOf(926), "" 169 | ) 170 | val iTxData = ParticleNetwork.evm.createTransaction( 171 | from, to, amount, type = "0x0", contractParams = contractParams 172 | ) 173 | LogUtils.d(iTxData, "hexData:${iTxData?.serialize()}") 174 | ToastUtils.showLong("hexData:${iTxData?.serialize()}") 175 | } catch (e: Exception) { 176 | e.printStackTrace() 177 | ToastUtils.showLong(e.message) 178 | } 179 | 180 | } 181 | } 182 | binding.rpc.setOnClickListener { 183 | lifecycleScope.launch { 184 | try { 185 | val from = address!! 186 | val to = "0xAC6d81182998EA5c196a4424EA6AB250C7eb175b" 187 | val data = "0x" 188 | // Integer block number, or the string 'latest', 'earliest' or 'pending' 189 | val quantity = "latest" 190 | val result = ParticleNetwork.evm.rpc("eth_call") 191 | ToastUtils.showLong(result.string()) 192 | } catch (e: Exception) { 193 | e.printStackTrace() 194 | ToastUtils.showLong(e.message) 195 | } 196 | 197 | } 198 | 199 | 200 | } 201 | } 202 | } -------------------------------------------------------------------------------- /app/src/main/java/network/particle/demo/ui/AuthDemoActivity.kt: -------------------------------------------------------------------------------- 1 | package network.particle.demo.ui 2 | 3 | 4 | import android.view.View 5 | import androidx.lifecycle.lifecycleScope 6 | import com.blankj.utilcode.util.GsonUtils 7 | import com.blankj.utilcode.util.LogUtils 8 | import com.blankj.utilcode.util.ToastUtils 9 | import com.google.android.material.dialog.MaterialAlertDialogBuilder 10 | import com.gyf.immersionbar.ImmersionBar 11 | import com.minijoy.demo.R 12 | import com.minijoy.demo.databinding.ActivityAuthDemoBinding 13 | import com.particle.auth.AuthCore 14 | import com.particle.auth.data.AuthCoreServiceCallback 15 | import com.particle.auth.data.AuthCoreSignCallback 16 | import com.particle.auth.data.SyncUserInfoStatus 17 | import com.particle.base.* 18 | import com.particle.base.data.ErrorInfo 19 | import com.particle.base.data.SignAllOutput 20 | import com.particle.base.data.SignOutput 21 | import com.particle.base.data.WebOutput 22 | import com.particle.base.data.WebServiceCallback 23 | import com.particle.base.model.LoginType 24 | import com.particle.base.model.ResultCallback 25 | import com.particle.base.model.SecurityAccountConfig 26 | import com.particle.base.model.SupportAuthType 27 | import com.particle.base.model.UserInfo 28 | import com.particle.base.utils.Base58Utils 29 | import com.particle.base.utils.HexUtils 30 | import com.particle.mpc.data.ServerException 31 | 32 | import kotlinx.coroutines.launch 33 | import network.particle.chains.ChainInfo 34 | import network.particle.demo.ui.adapter.ChainInfoChoiceListAdapter 35 | import network.particle.demo.ui.base.DemoBaseActivity 36 | import network.particle.demo.utils.DemoChainUtils 37 | import network.particle.demo.utils.ParticleInitUtils 38 | import network.particle.demo.utils.StreamUtils 39 | import network.particle.demo.utils.TransactionMock 40 | 41 | 42 | class AuthDemoActivity : DemoBaseActivity(R.layout.activity_auth_demo) { 43 | 44 | override fun initView() { 45 | super.initView() 46 | ImmersionBar.with(this).statusBarColor(android.R.color.transparent).titleBar( 47 | binding.toolbar 48 | ).init() 49 | } 50 | 51 | var currChainInfo: ChainInfo? = null 52 | override fun setListeners() { 53 | super.setListeners() 54 | binding.toolbar.setNavigationOnClickListener { finish() } 55 | binding.selectChain.setOnClickListener { 56 | val chainInfos = DemoChainUtils.getAllChainInfo() 57 | MaterialAlertDialogBuilder(this@AuthDemoActivity).setTitle(getString(R.string.pn_select_chain)) 58 | .setSingleChoiceItems( 59 | ChainInfoChoiceListAdapter(this@AuthDemoActivity, chainInfos), 60 | 0 61 | ) { dialog, which -> 62 | val chainInfo = chainInfos[which] 63 | currChainInfo = chainInfo 64 | ParticleNetwork.setChainInfo(currChainInfo!!) //set chain info 65 | updateChainName() 66 | updateAddress() 67 | dialog.dismiss() 68 | }.show() 69 | } 70 | binding.init.setOnClickListener { 71 | if (checkCurrChainInfo()) return@setOnClickListener 72 | ParticleInitUtils.initAuth(this@AuthDemoActivity, currChainInfo!!) 73 | } 74 | binding.login.setOnClickListener { 75 | val supportAuthTypeAll = SupportAuthType.ALL.value 76 | AuthCore.connect( 77 | LoginType.EMAIL, 78 | loginCallback = object : AuthCoreServiceCallback { 79 | override fun success(output: UserInfo) { 80 | updateAddress() 81 | } 82 | 83 | override fun failure(errMsg: ErrorInfo) { 84 | ToastUtils.showLong(errMsg.message) 85 | } 86 | }) 87 | } 88 | 89 | 90 | 91 | binding.isLogin.setOnClickListener { 92 | showMessageDialog(getString(R.string.pn_is_login), AuthCore.isConnected().toString()) 93 | } 94 | 95 | binding.isLoginAsync.setOnClickListener { 96 | lifecycleScope.launch { 97 | try { 98 | val userInfo: SyncUserInfoStatus = AuthCore.syncUserInfo() 99 | showMessageDialog( 100 | getString(R.string.pn_is_login_async), 101 | GsonUtils.toJson(userInfo) 102 | ) 103 | } catch (e: ServerException) { 104 | showMessageDialog(getString(R.string.pn_is_login_async), "User Token Expired") 105 | } 106 | 107 | } 108 | } 109 | 110 | binding.getAddress.setOnClickListener { 111 | val address = if (ParticleNetwork.chainInfo.isEvmChain()) { 112 | AuthCore.evm.getAddress() 113 | } else { 114 | AuthCore.solana.getAddress() 115 | } 116 | showMessageDialog(getString(R.string.pn_get_address), address ?: "") 117 | } 118 | 119 | binding.getUserInfo.setOnClickListener { 120 | val userInfo: UserInfo? = AuthCore.getUserInfo() 121 | showMessageDialog(getString(R.string.pn_get_userinfo), GsonUtils.toJson(userInfo)) 122 | } 123 | 124 | binding.logout.setOnClickListener { 125 | AuthCore.disconnect(object : ResultCallback { 126 | 127 | override fun failure() { 128 | ToastUtils.showLong("logout failure") 129 | } 130 | 131 | override fun success() { 132 | ToastUtils.showLong(getString(R.string.pn_logout_success)) 133 | } 134 | }) 135 | } 136 | 137 | 138 | 139 | binding.signMessage.setOnClickListener { 140 | if (checkCurrChainInfo()) return@setOnClickListener 141 | if (checkIsLogin()) return@setOnClickListener 142 | val message = "Hello Particle Network" 143 | val encodeMessage = if (currChainInfo!!.isEvmChain()) { 144 | HexUtils.encodeWithPrefix(message.toByteArray(Charsets.UTF_8)) 145 | } else { 146 | Base58Utils.encode(message.toByteArray(Charsets.UTF_8)) 147 | } 148 | if (ParticleNetwork.chainInfo.isEvmChain()) { 149 | AuthCore.evm.personalSign(encodeMessage, object : AuthCoreSignCallback { 150 | override fun success(output: SignOutput) { 151 | showMessageDialog(getString(R.string.pn_sign_message), output.signature!!) 152 | } 153 | 154 | override fun failure(errMsg: ErrorInfo) { 155 | showMessageDialog( 156 | getString(R.string.pn_sign_message), 157 | "code:${errMsg.code} \nmessage:${errMsg.message}" 158 | ) 159 | } 160 | }) 161 | } else { 162 | AuthCore.solana.signMessage( 163 | encodeMessage, 164 | object : AuthCoreSignCallback { 165 | override fun success(output: SignOutput) { 166 | showMessageDialog( 167 | getString(R.string.pn_sign_message), 168 | output.signature!! 169 | ) 170 | } 171 | 172 | override fun failure(errMsg: ErrorInfo) { 173 | showMessageDialog( 174 | getString(R.string.pn_sign_message), 175 | "code:${errMsg.code} \nmessage:${errMsg.message}" 176 | ) 177 | } 178 | }) 179 | } 180 | } 181 | 182 | binding.signTransaction.setOnClickListener { 183 | if (checkCurrChainInfo()) return@setOnClickListener 184 | if (checkIsLogin()) return@setOnClickListener 185 | if (currChainInfo!!.isEvmChain()) { 186 | ToastUtils.showLong(R.string.pn_only_solana_support) 187 | return@setOnClickListener 188 | } 189 | lifecycleScope.launch { 190 | val transaction = TransactionMock.mockSolanaTransaction() 191 | LogUtils.d("signTransaction", transaction) 192 | if (ParticleNetwork.chainInfo.isSolanaChain()) { 193 | AuthCore.solana.signTransaction( 194 | transaction, 195 | object : AuthCoreSignCallback { 196 | override fun success(output: SignOutput) { 197 | showMessageDialog( 198 | getString(R.string.pn_sign_transaction), 199 | output.signature!! 200 | ) 201 | } 202 | 203 | override fun failure(errMsg: ErrorInfo) { 204 | showMessageDialog( 205 | getString(R.string.pn_sign_transaction), 206 | "code:${errMsg.code} \nmessage:${errMsg.message}" 207 | ) 208 | } 209 | }) 210 | } 211 | } 212 | 213 | } 214 | 215 | binding.signAllTransactions.setOnClickListener { 216 | if (checkCurrChainInfo()) return@setOnClickListener 217 | if (checkIsLogin()) return@setOnClickListener 218 | if (currChainInfo!!.isEvmChain()) { 219 | ToastUtils.showLong(R.string.pn_only_solana_support) 220 | return@setOnClickListener 221 | } 222 | lifecycleScope.launch { 223 | val transactions1 = TransactionMock.mockSolanaTransaction() 224 | val transactions2 = TransactionMock.mockSolanaTransaction() 225 | AuthCore.solana.signAllTransactions( 226 | listOf(transactions1, transactions2), 227 | object : AuthCoreSignCallback { 228 | 229 | 230 | override fun failure(errMsg: ErrorInfo) { 231 | showMessageDialog( 232 | getString(R.string.pn_sign_all_transactions), 233 | "code:${errMsg.code} \nmessage:${errMsg.message}" 234 | ) 235 | } 236 | 237 | override fun success(output: SignAllOutput) { 238 | showMessageDialog( 239 | getString(R.string.pn_sign_all_transactions), 240 | output.signatures.toString() 241 | ) 242 | } 243 | }) 244 | } 245 | 246 | } 247 | 248 | binding.signSendTransaction.setOnClickListener { 249 | if (checkCurrChainInfo()) return@setOnClickListener 250 | if (checkIsLogin()) return@setOnClickListener 251 | lifecycleScope.launch { 252 | val transaction: String = if (currChainInfo!!.isSolanaChain()) { 253 | TransactionMock.mockSolanaTransaction() 254 | } else { 255 | TransactionMock.mockEvmSendNativeTransactionFast() 256 | //or you can use TransactionMock.mockEvmSendNativeTransactionCustom() 257 | } 258 | LogUtils.d("signSendTransaction", transaction) 259 | if (ParticleNetwork.chainInfo.isEvmChain()) { 260 | AuthCore.evm.sendTransaction( 261 | transaction, 262 | object : AuthCoreSignCallback { 263 | override fun success(output: SignOutput) { 264 | showMessageDialog( 265 | getString(R.string.pn_sign_send_transaction), 266 | output.signature!! 267 | ) 268 | } 269 | 270 | override fun failure(errMsg: ErrorInfo) { 271 | showMessageDialog( 272 | getString(R.string.pn_sign_send_transaction), 273 | "code:${errMsg.code} \nmessage:${errMsg.message}" 274 | ) 275 | } 276 | }) 277 | } else { 278 | AuthCore.solana.signAndSendTransaction( 279 | transaction, 280 | object : AuthCoreSignCallback { 281 | override fun success(output: SignOutput) { 282 | showMessageDialog( 283 | getString(R.string.pn_sign_send_transaction), 284 | output.signature!! 285 | ) 286 | } 287 | 288 | override fun failure(errMsg: ErrorInfo) { 289 | showMessageDialog( 290 | getString(R.string.pn_sign_send_transaction), 291 | "code:${errMsg.code} \nmessage:${errMsg.message}" 292 | ) 293 | } 294 | }) 295 | } 296 | } 297 | 298 | } 299 | 300 | binding.signTypedData.setOnClickListener { 301 | if (checkCurrChainInfo()) return@setOnClickListener 302 | if (checkIsLogin()) return@setOnClickListener 303 | if (currChainInfo!!.isSolanaChain()) { 304 | ToastUtils.showLong(R.string.pn_only_evm_support) 305 | return@setOnClickListener 306 | } 307 | val message = StreamUtils.getRawString(resources, R.raw.typed_data) 308 | val hexMessage = HexUtils.encodeWithPrefix(message.toByteArray(Charsets.UTF_8)) 309 | AuthCore.evm.signTypedData(hexMessage, object : AuthCoreSignCallback { 310 | override fun success(output: SignOutput) { 311 | showMessageDialog(getString(R.string.pn_sign_typed_data), output.signature!!) 312 | } 313 | 314 | override fun failure(errMsg: ErrorInfo) { 315 | showMessageDialog( 316 | getString(R.string.pn_sign_typed_data), 317 | "code:${errMsg.code} \nmessage:${errMsg.message}" 318 | ) 319 | } 320 | }) 321 | } 322 | 323 | // If you login to solana, you do not have an evm wallet address, you need to call this method to switch to the evm chain, this method will create an evm wallet 324 | binding.setChainInfoSync.setOnClickListener { 325 | AuthCore.switchChain(ChainInfo.EthereumSepolia, object : ResultCallback { 326 | override fun success() { 327 | showMessageDialog(getString(R.string.pn_set_chaininfo_sync), "success") 328 | } 329 | 330 | override fun failure() { 331 | showMessageDialog(getString(R.string.pn_set_chaininfo_sync), "failure") 332 | } 333 | }) 334 | } 335 | 336 | binding.getChainInfo.setOnClickListener { 337 | val chainInfo = ParticleNetwork.chainInfo 338 | val chainInfoStr = "${chainInfo.name} ${chainInfo.id}" 339 | showMessageDialog(getString(R.string.pn_get_chaininfo), chainInfoStr) 340 | } 341 | 342 | binding.openAccountSecurity.setOnClickListener { 343 | AuthCore.openAccountAndSecurity(this@AuthDemoActivity, 344 | object : WebServiceCallback { 345 | override fun success(output: WebOutput) { 346 | 347 | } 348 | 349 | override fun failure(errMsg: ErrorInfo) { 350 | if (errMsg.code == 10005 || errMsg.code == 8005) { 351 | //You've been knocked out. 352 | } 353 | } 354 | }) 355 | } 356 | 357 | binding.setSecurityAccountConfig.setOnClickListener { 358 | //0-> Do not prompt 359 | //1-> prompt once 360 | //2-> prompt every time 361 | val config = SecurityAccountConfig( 362 | promptSettingWhenSign = 1, 363 | promptMasterPasswordSettingWhenLogin = 0 364 | ) 365 | ParticleNetwork.setSecurityAccountConfig(config) 366 | } 367 | 368 | binding.setLanguage.setOnClickListener { 369 | val isRelaunchApp = true //True to relaunch app, false to recreate all activities. 370 | ParticleNetwork.setLanguage(LanguageEnum.EN, isRelaunchApp) 371 | } 372 | 373 | 374 | } 375 | 376 | private fun checkCurrChainInfo(): Boolean { 377 | if (currChainInfo == null) { 378 | ToastUtils.showLong(R.string.pn_select_chain_please) 379 | return true 380 | } 381 | return false 382 | } 383 | 384 | private fun checkIsLogin(): Boolean { 385 | if (!AuthCore.isConnected()) { 386 | ToastUtils.showLong(R.string.pn_not_login) 387 | return true 388 | } 389 | return false 390 | } 391 | 392 | fun updateAddress() { 393 | if (AuthCore.isConnected()) { 394 | binding.address.text = if (ParticleNetwork.chainInfo.isEvmChain()) { 395 | AuthCore.evm.getAddress() 396 | } else { 397 | AuthCore.solana.getAddress() 398 | } 399 | binding.address.visibility = View.VISIBLE 400 | } 401 | } 402 | 403 | private fun updateChainName() { 404 | currChainInfo?.apply { 405 | binding.chainName.text = "${name} ${fullname}(${id})" 406 | binding.chainName.visibility = View.VISIBLE 407 | } 408 | } 409 | 410 | private fun showMessageDialog(title: String, message: String) { 411 | MaterialAlertDialogBuilder(this@AuthDemoActivity).setTitle(title).setMessage(message).show() 412 | } 413 | 414 | 415 | } -------------------------------------------------------------------------------- /app/src/main/java/network/particle/demo/ui/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package network.particle.demo.ui 2 | 3 | import android.content.Intent 4 | import com.blankj.utilcode.util.ToastUtils 5 | import com.google.android.material.dialog.MaterialAlertDialogBuilder 6 | import com.gyf.immersionbar.BarHide 7 | import com.gyf.immersionbar.ImmersionBar 8 | import com.minijoy.demo.R 9 | import com.minijoy.demo.databinding.ActivityMainBinding 10 | import com.particle.base.ParticleNetwork 11 | import com.particle.connect.ParticleConnect 12 | import com.particle.gui.ParticleWallet 13 | import com.particle.gui.ParticleWallet.navigatorDAppBrowser 14 | import com.particle.gui.ParticleWallet.isWalletLogin 15 | import network.particle.demo.ui.adapter.ChainInfoChoiceListAdapter 16 | import network.particle.demo.ui.base.DemoBaseActivity 17 | import network.particle.demo.utils.DemoChainUtils 18 | 19 | 20 | class MainActivity : DemoBaseActivity(R.layout.activity_main) { 21 | override fun initView() { 22 | super.initView() 23 | ImmersionBar.with(this).transparentStatusBar().hideBar(BarHide.FLAG_HIDE_BAR).init() 24 | } 25 | 26 | override fun setListeners() { 27 | super.setListeners() 28 | binding.btAuthDemo.setOnClickListener { 29 | startActivity(Intent(this, AuthDemoActivity::class.java)) 30 | } 31 | binding.btApiDemo.setOnClickListener { 32 | startActivity(Intent(this, ApiDemoActivity::class.java)) 33 | } 34 | binding.btWalletDemo.setOnClickListener { 35 | if (!ParticleWallet.isWalletLogin()) { 36 | startActivity(Intent(this, ParticleWalletLoginDemoActivity::class.java)) 37 | return@setOnClickListener 38 | } 39 | startActivity(Intent(this, WalletDemoActivity::class.java)) 40 | 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /app/src/main/java/network/particle/demo/ui/ParticleWalletLoginDemoActivity.kt: -------------------------------------------------------------------------------- 1 | package network.particle.demo.ui 2 | 3 | import android.graphics.Color 4 | import androidx.lifecycle.lifecycleScope 5 | import androidx.viewpager2.widget.ViewPager2 6 | import com.blankj.utilcode.util.LogUtils 7 | import com.connect.common.ConnectKitCallback 8 | import com.connect.common.model.Account 9 | import com.connect.common.model.ConnectError 10 | import com.gyf.immersionbar.BarHide 11 | import com.gyf.immersionbar.ImmersionBar 12 | import com.minijoy.demo.R 13 | import com.minijoy.demo.databinding.ActivityParticleWalletDemoBinding 14 | import com.particle.connectkit.AdditionalLayoutOptions 15 | import com.particle.connectkit.ConnectKitConfig 16 | import com.particle.connectkit.ConnectOption 17 | import com.particle.connectkit.EnableSocialProvider 18 | import com.particle.connectkit.EnableWallet 19 | import com.particle.connectkit.EnableWalletLabel 20 | import com.particle.connectkit.EnableWalletProvider 21 | import com.particle.connectkit.ParticleConnectKit 22 | import com.particle.gui.ParticleWallet 23 | import network.particle.demo.ui.adapter.BannerAdapter 24 | import com.zhpan.bannerview.constants.IndicatorGravity 25 | import com.zhpan.indicator.enums.IndicatorSlideMode 26 | import com.zhpan.indicator.enums.IndicatorStyle 27 | import kotlinx.coroutines.launch 28 | import network.particle.demo.ui.base.DemoBaseActivity 29 | 30 | 31 | class ParticleWalletLoginDemoActivity : 32 | DemoBaseActivity(R.layout.activity_particle_wallet_demo) { 33 | val pageTipsStr = arrayOf( 34 | R.string.pn_page1_tips, 35 | R.string.pn_page2_tips, 36 | R.string.pn_page3_tips, 37 | R.string.pn_page4_tips 38 | ) 39 | 40 | override fun initView() { 41 | super.initView() 42 | ImmersionBar.with(this).transparentStatusBar().hideBar(BarHide.FLAG_HIDE_BAR).init() 43 | initHorizontalBanner() 44 | setObserver() 45 | } 46 | 47 | override fun setListeners() { 48 | super.setListeners() 49 | binding.rlLoginWithConnectKit.setOnClickListener { 50 | val config = ConnectKitConfig( 51 | logo = "", 52 | connectOptions = listOf( 53 | ConnectOption.EMAIL, 54 | ConnectOption.PHONE, 55 | ConnectOption.SOCIAL, 56 | ConnectOption.WALLET), 57 | socialProviders = listOf( 58 | EnableSocialProvider.GOOGLE, 59 | EnableSocialProvider.APPLE, 60 | EnableSocialProvider.DISCORD, 61 | EnableSocialProvider.TWITTER, 62 | EnableSocialProvider.FACEBOOK, 63 | EnableSocialProvider.GITHUB, 64 | EnableSocialProvider.MICROSOFT, 65 | EnableSocialProvider.TWITCH, 66 | EnableSocialProvider.LINKEDIN), 67 | walletProviders = listOf( 68 | EnableWalletProvider(EnableWallet.MetaMask, EnableWalletLabel.RECOMMENDED), 69 | EnableWalletProvider(EnableWallet.OKX), 70 | EnableWalletProvider(EnableWallet.Phantom), 71 | EnableWalletProvider(EnableWallet.Trust), 72 | EnableWalletProvider(EnableWallet.Bitget), 73 | EnableWalletProvider(EnableWallet.WalletConnect), 74 | ), 75 | additionalLayoutOptions = AdditionalLayoutOptions( 76 | isCollapseWalletList = false, 77 | isSplitEmailAndSocial = false, 78 | isSplitEmailAndPhone = false, 79 | isHideContinueButton = false 80 | ) 81 | ) 82 | ParticleConnectKit.connect(config,connectCallback = object : ConnectKitCallback { 83 | override fun onConnected(walletName: String, account: Account) { 84 | LogUtils.d("onConnected: $walletName, $account") 85 | lifecycleScope.launch { 86 | ParticleWallet.setWallet(account.publicAddress,walletName) 87 | openWallet() 88 | } 89 | } 90 | 91 | override fun onError(error: ConnectError) { 92 | } 93 | 94 | }); 95 | } 96 | 97 | 98 | } 99 | 100 | 101 | private fun initHorizontalBanner() { 102 | binding.bannerView.setScrollDuration(600).setOffScreenPageLimit(2) 103 | .setLifecycleRegistry(lifecycle).setIndicatorStyle(IndicatorStyle.CIRCLE) 104 | .setIndicatorSlideMode(IndicatorSlideMode.NORMAL).setInterval(3000) 105 | .setIndicatorGravity(IndicatorGravity.CENTER).setIndicatorSliderRadius(10) 106 | .disallowParentInterceptDownEvent(true).setIndicatorSliderColor( 107 | Color.parseColor("#4E4E50"), Color.WHITE 108 | ).setAdapter(BannerAdapter()) 109 | .registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() { 110 | override fun onPageSelected(position: Int) { 111 | binding.tvSubTitle.text = getString(pageTipsStr[position]) 112 | } 113 | }).create() 114 | binding.bannerView.refreshData( 115 | mutableListOf( 116 | R.drawable.page1, R.drawable.page2, R.drawable.page3, R.drawable.page4 117 | ) 118 | ) 119 | 120 | } 121 | 122 | private fun openWallet() { 123 | finish() 124 | } 125 | 126 | } -------------------------------------------------------------------------------- /app/src/main/java/network/particle/demo/ui/SettingActivity.kt: -------------------------------------------------------------------------------- 1 | package network.particle.demo.ui 2 | 3 | import com.minijoy.demo.R 4 | import com.minijoy.demo.databinding.ActivitySettingBinding 5 | import network.particle.demo.ui.base.DemoBaseActivity 6 | 7 | class SettingActivity : DemoBaseActivity(R.layout.activity_setting) { 8 | 9 | override fun initView() { 10 | super.initView() 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /app/src/main/java/network/particle/demo/ui/WalletDemoActivity.kt: -------------------------------------------------------------------------------- 1 | package network.particle.demo.ui 2 | 3 | import com.blankj.utilcode.util.ToastUtils 4 | import com.gyf.immersionbar.BarHide 5 | import com.gyf.immersionbar.ImmersionBar 6 | import com.minijoy.demo.R 7 | import com.minijoy.demo.databinding.ActivityWalletDemoBinding 8 | import com.particle.gui.router.PNRouter 9 | import com.particle.gui.router.RouterPath 10 | import com.particle.gui.ui.swap.SwapConfig 11 | import network.particle.demo.ui.base.DemoBaseActivity 12 | 13 | class WalletDemoActivity : DemoBaseActivity(R.layout.activity_wallet_demo) { 14 | 15 | override fun initView() { 16 | super.initView() 17 | ImmersionBar.with(this).statusBarColor(android.R.color.transparent).titleBar( 18 | binding.toolbar 19 | ).init() 20 | } 21 | 22 | override fun setListeners() { 23 | super.setListeners() 24 | binding.toolbar.setNavigationOnClickListener { finish() } 25 | binding.openWallet.setOnClickListener { 26 | PNRouter.build(RouterPath.Wallet).navigation() 27 | } 28 | 29 | binding.openSendToken.setOnClickListener { 30 | //open send token 31 | //val params = WalletSendParams(tokenAddress, toAddress?, toAmount?) 32 | //PNRouter.build(RouterPath.TokenSend, params).navigation() 33 | 34 | //open send default token by chain name 35 | PNRouter.build(RouterPath.TokenSend).navigation() 36 | } 37 | binding.openReceiveToken.setOnClickListener { 38 | PNRouter.build(RouterPath.TokenReceive).navigation() 39 | } 40 | binding.openTransactionRecords.setOnClickListener { 41 | //open token transaction records 42 | // val params = TokenTransactionRecordsParams(tokenAddress) 43 | // PNRouter.build(RouterPath.TokenTransactionRecords, params).navigation() 44 | 45 | //open default token transaction records by chain name 46 | PNRouter.build(RouterPath.TokenTransactionRecords).navigation() 47 | } 48 | binding.openNftDetails.setOnClickListener { 49 | // val params = NftDetailParams("5iNNGxfmvE98vDFUrpUiSSU2NXYFx3jLqFSeLh7J8xL4") 50 | // PNRouter.build(RouterPath.NftDetails, params).navigation() 51 | ToastUtils.showLong(getString(R.string.pn_api_tips)) 52 | } 53 | binding.openNftSend.setOnClickListener { 54 | // val params = NftDetailParams("5iNNGxfmvE98vDFUrpUiSSU2NXYFx3jLqFSeLh7J8xL4", "5iNNGxfmvE98vDFUrpUiSSU2NXYFx3jLqFSeLh7J8xL4") 55 | // PNRouter.build(RouterPath.NftDetails,params).navigation() 56 | ToastUtils.showLong(getString(R.string.pn_api_tips)) 57 | } 58 | binding.openSwap.setOnClickListener { 59 | PNRouter.navigatorSwap(SwapConfig(toTokenAddress = "0x66c3E9e7ecBCFaeB4A132cFCAdF23821a00b34e7")) 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /app/src/main/java/network/particle/demo/ui/adapter/BannerAdapter.kt: -------------------------------------------------------------------------------- 1 | package network.particle.demo.ui.adapter 2 | 3 | import android.widget.ImageView 4 | import coil.load 5 | import com.minijoy.demo.R 6 | import com.zhpan.bannerview.BaseBannerAdapter 7 | import com.zhpan.bannerview.BaseViewHolder 8 | 9 | class BannerAdapter : BaseBannerAdapter() { 10 | override fun bindData( 11 | holder: BaseViewHolder, data: Int, position: Int, 12 | pageSize: Int 13 | ) { 14 | val imageView = holder.findViewById(R.id.banner_image) 15 | imageView.load(data) 16 | } 17 | 18 | override fun getLayoutId(viewType: Int): Int { 19 | return R.layout.banner_item 20 | } 21 | 22 | 23 | } -------------------------------------------------------------------------------- /app/src/main/java/network/particle/demo/ui/adapter/ChainInfoChoiceListAdapter.kt: -------------------------------------------------------------------------------- 1 | package network.particle.demo.ui.adapter 2 | 3 | import android.content.Context 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import android.widget.BaseAdapter 8 | import android.widget.TextView 9 | import com.minijoy.demo.R 10 | import network.particle.chains.ChainInfo 11 | 12 | 13 | class ChainInfoChoiceListAdapter(private val context: Context, private val list: List) : BaseAdapter() { 14 | 15 | override fun getCount(): Int { 16 | return list.size 17 | } 18 | 19 | override fun getItem(position: Int): ChainInfo { 20 | return list[position] 21 | } 22 | 23 | override fun getItemId(position: Int): Long { 24 | return position.toLong() 25 | } 26 | 27 | override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View { 28 | var view = convertView 29 | if (view == null) { 30 | view = LayoutInflater.from(context).inflate(R.layout.item_chain_choice, parent, false) 31 | } 32 | val item = getItem(position) 33 | val titleTextView = view!!.findViewById(com.particle.gui.R.id.tvChainName) 34 | titleTextView.text = "${item.name} ${item.id}" 35 | return view 36 | } 37 | } -------------------------------------------------------------------------------- /app/src/main/java/network/particle/demo/ui/adapter/ConnectChoiceListAdapter.kt: -------------------------------------------------------------------------------- 1 | package network.particle.demo.ui.adapter 2 | 3 | import android.content.Context 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import android.widget.BaseAdapter 8 | import android.widget.TextView 9 | import com.connect.common.IConnectAdapter 10 | import com.minijoy.demo.R 11 | 12 | 13 | class ConnectChoiceListAdapter(private val context: Context, private val list: List) : BaseAdapter() { 14 | 15 | override fun getCount(): Int { 16 | return list.size 17 | } 18 | 19 | override fun getItem(position: Int): IConnectAdapter { 20 | return list[position] 21 | } 22 | 23 | override fun getItemId(position: Int): Long { 24 | return position.toLong() 25 | } 26 | 27 | override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View { 28 | var view = convertView 29 | if (view == null) { 30 | view = LayoutInflater.from(context).inflate(R.layout.item_chain_choice, parent, false) 31 | } 32 | val item = getItem(position) 33 | val titleTextView = view!!.findViewById(com.particle.gui.R.id.tvChainName) 34 | titleTextView.text = item.name 35 | return view 36 | } 37 | } -------------------------------------------------------------------------------- /app/src/main/java/network/particle/demo/ui/base/DemoBaseActivity.kt: -------------------------------------------------------------------------------- 1 | package network.particle.demo.ui.base 2 | 3 | import android.os.Bundle 4 | import androidx.annotation.LayoutRes 5 | import androidx.appcompat.app.AppCompatActivity 6 | import androidx.databinding.DataBindingUtil 7 | import androidx.databinding.ViewDataBinding 8 | 9 | open class DemoBaseActivity(@LayoutRes var contentLayoutId: Int) : 10 | AppCompatActivity() { 11 | private var _binding: DB? = null 12 | protected val binding: DB get() = _binding!! 13 | 14 | override fun onCreate(savedInstanceState: Bundle?) { 15 | super.onCreate(savedInstanceState) 16 | _binding = DataBindingUtil.setContentView(this, contentLayoutId) 17 | initView() 18 | initData() 19 | setListeners() 20 | setObserver() 21 | } 22 | 23 | override fun onStart() { 24 | super.onStart() 25 | } 26 | 27 | override fun onStop() { 28 | super.onStop() 29 | 30 | } 31 | 32 | override fun onDestroy() { 33 | super.onDestroy() 34 | _binding = null 35 | } 36 | 37 | open fun initView() { 38 | 39 | } 40 | 41 | open fun initData() { 42 | 43 | } 44 | 45 | open fun setListeners() { 46 | 47 | } 48 | 49 | open fun setObserver() { 50 | 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /app/src/main/java/network/particle/demo/utils/DemoChainUtils.kt: -------------------------------------------------------------------------------- 1 | package network.particle.demo.utils 2 | 3 | import com.particle.base.* 4 | import network.particle.chains.ChainInfo 5 | 6 | object DemoChainUtils { 7 | fun getAllChainInfo(): List { 8 | return ChainInfo.getAllChains() 9 | } 10 | 11 | } -------------------------------------------------------------------------------- /app/src/main/java/network/particle/demo/utils/ParticleInitUtils.kt: -------------------------------------------------------------------------------- 1 | package network.particle.demo.utils 2 | 3 | import android.app.Application 4 | import android.content.Context 5 | import auth.core.adapter.AuthCoreAdapter 6 | import com.evm.adapter.EVMConnectAdapter 7 | import com.particle.base.* 8 | import com.particle.base.model.DAppMetadata 9 | import com.particle.connect.ParticleConnect 10 | import com.particle.erc4337.ParticleNetworkAA.initAAMode 11 | import com.particle.erc4337.aa.BiconomyV2AAService 12 | import com.particle.gui.ParticleWallet 13 | import com.phantom.adapter.PhantomConnectAdapter 14 | import com.solana.adapter.SolanaConnectAdapter 15 | import com.wallet.connect.adapter.* 16 | import network.particle.chains.ChainInfo 17 | 18 | object ParticleInitUtils { 19 | 20 | // it is recommended to initialize it in Application. This is only used as an example. 21 | fun initAuth(context: Context, chainInfo: ChainInfo) { 22 | ParticleNetwork.init(context, Env.PRODUCTION, chainInfo) 23 | } 24 | 25 | fun initConnect(app: Application, chainInfo: ChainInfo) { 26 | val dAppMetadata = DAppMetadata( 27 | "Particle Connect", 28 | "https://connect.particle.network/icons/512.png", 29 | "https://particle.network", 30 | description = "Particle Connect is a decentralized wallet connection protocol that makes it easy for users to connect their wallets to your DApp.", 31 | ) 32 | ParticleConnect.init( 33 | app, Env.PRODUCTION, chainInfo, dAppMetadata 34 | ) { 35 | listOf( 36 | AuthCoreAdapter(), 37 | MetaMaskConnectAdapter(), 38 | RainbowConnectAdapter(), 39 | TrustConnectAdapter(), 40 | PhantomConnectAdapter(), 41 | WalletConnectAdapter(), 42 | ImTokenConnectAdapter(), 43 | BitGetConnectAdapter(), 44 | EVMConnectAdapter(), 45 | SolanaConnectAdapter(), 46 | ) 47 | } 48 | } 49 | 50 | fun initWallet(app: Application, chainInfo: ChainInfo) { 51 | initConnect(app, chainInfo) 52 | /** 53 | * supportChains is optional,, if not provided, all chains will be supported 54 | * if provided, only the chains in the list will be supported,Only the main chain is required, 55 | * if you want to support devnet, you can call showTestNetworks() to show the devnet networks 56 | */ 57 | 58 | ParticleWallet.init( 59 | app 60 | ).apply { 61 | setShowTestNetworkSetting(true) 62 | setShowManageWalletSetting(true) 63 | hideMainBackIcon() 64 | } 65 | ParticleNetwork.setLanguage(LanguageEnum.EN) 66 | //enable AA-4337 mode 67 | ParticleNetwork.initAAMode() 68 | // ParticleNetwork.setAAService(BiconomyV2AAService) 69 | // ParticleNetwork.getAAService().enableAAMode() 70 | } 71 | } -------------------------------------------------------------------------------- /app/src/main/java/network/particle/demo/utils/StreamUtils.kt: -------------------------------------------------------------------------------- 1 | package network.particle.demo.utils 2 | 3 | import android.content.res.Resources 4 | import java.io.BufferedReader 5 | import java.io.InputStreamReader 6 | 7 | 8 | object StreamUtils { 9 | 10 | fun getRawString(resource: Resources, rawId: Int): String { 11 | val stream = resource.openRawResource(rawId) 12 | try { 13 | val reader = BufferedReader(InputStreamReader(stream, "utf-8")) 14 | val sb = StringBuilder() 15 | var line: String? = null 16 | while (run { 17 | line = reader.readLine() 18 | line 19 | } != null) { 20 | sb.append(line + "\n") 21 | } 22 | return sb.toString() 23 | } catch (e: Exception) { 24 | e.printStackTrace() 25 | } finally { 26 | stream.close() 27 | } 28 | return "" 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /app/src/main/java/network/particle/demo/utils/TestAccount.kt: -------------------------------------------------------------------------------- 1 | package network.particle.demo.utils 2 | 3 | import java.math.BigInteger 4 | 5 | data class TestAccount( 6 | val privateKey: String, 7 | val mnemonic: String, 8 | val tokenContractAddress: String, 9 | val amount: Long, 10 | val nftContractAddress: String, 11 | val nftTokenId: String, 12 | val receiverAddress: String 13 | ) { 14 | companion object { 15 | fun evm(): TestAccount { 16 | return TestAccount( 17 | "eacd18277e3cfca6446801b7587c9d787d5ee5d93f6a38752f7d94eddadc469e", 18 | "hood result social fetch pet code check yard school jealous trick lazy", 19 | "0x326C977E6efc84E512bB9C30f76E30c160eD06FB", 20 | 1000000000000000, 21 | "0xD000F000Aa1F8accbd5815056Ea32A54777b2Fc4", 22 | "1412", 23 | "0xAC6d81182998EA5c196a4424EA6AB250C7eb175b" 24 | ) 25 | } 26 | 27 | fun solana(): TestAccount { 28 | return TestAccount( 29 | "5fBYPZdP5nqH5DSAjgjMi4aSf113m5PuavakojZ7C9svt1i8vyq26pXpEf1Suivg91TUAp7TX1pqK49rgXQfAAjT", 30 | "vacant focus country eye wine where lady doll boat sort ticket grab", 31 | "GobzzzFQsFAHPvmwT42rLockfUCeV3iutEkK218BxT8K", 32 | 10000000, 33 | "HLyQCnxBo5SGmYBv3aRCH9tPqT9TvexHY2JaGnqvfWuw", 34 | "", 35 | "9LR6zGAFB3UJcLg9tWBQJxEJCbZh2UTnSU14RBxsK1ZN" 36 | ); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /app/src/main/java/network/particle/demo/utils/TransactionMock.kt: -------------------------------------------------------------------------------- 1 | package network.particle.demo.utils 2 | 3 | import com.particle.api.evm 4 | import com.particle.api.infrastructure.net.data.EvmReqBodyMethod 5 | import com.particle.api.infrastructure.net.data.SerializeSOLTransReq 6 | import com.particle.api.service.EvmService 7 | import com.particle.api.solana 8 | import com.particle.auth.AuthCore 9 | import com.particle.base.ParticleNetwork 10 | import com.particle.base.model.FeeMarketEIP1559TxData 11 | import com.particle.base.model.ITxData 12 | import com.particle.base.model.TxAction 13 | import com.particle.base.model.TxData 14 | import com.particle.base.utils.gweiToHexStr 15 | import com.particle.base.utils.toHexStr 16 | import okhttp3.internal.toHexString 17 | import org.json.JSONObject 18 | 19 | object TransactionMock { 20 | 21 | suspend fun mockSolanaTransaction(): String { 22 | val req = SerializeSOLTransReq( 23 | AuthCore.solana.getAddress()!!, 24 | TestAccount.solana().receiverAddress, 25 | TestAccount.solana().amount 26 | ) 27 | val result = 28 | ParticleNetwork.solana.serializeTransaction(req).result 29 | val message = result.transaction.serialized 30 | return message 31 | } 32 | 33 | suspend fun mockEvmSendNativeTransactionFast(): String { 34 | val from: String = AuthCore.evm.getAddress()!! 35 | val to = TestAccount.evm().receiverAddress 36 | val amount = TestAccount.evm().amount.toHexString() 37 | return ParticleNetwork.evm.createTransaction(from, to, "0x$amount")!!.serialize() 38 | } 39 | 40 | suspend fun mockEvmSendNativeTransactionCustom(): String { 41 | val from: String = AuthCore.evm.getAddress()!! 42 | val to = TestAccount.evm().receiverAddress 43 | val amount = TestAccount.evm().amount.toHexString() 44 | val gasLimit = getEvmTransGasLimit(from, to) 45 | val suggestedGasFees = ParticleNetwork.evm.suggestedGasFees() 46 | val high = suggestedGasFees.result.high 47 | val transaction: ITxData 48 | if (ParticleNetwork.chainInfo.isEIP1559Supported()) { 49 | transaction = FeeMarketEIP1559TxData( 50 | high.maxPriorityFeePerGas.gweiToHexStr(), 51 | high.maxFeePerGas.gweiToHexStr(), 52 | chainId = ParticleNetwork.chainId.toString().toHexStr(), 53 | from = from, 54 | to = to, 55 | value = "0x$amount", 56 | gasLimit = gasLimit, 57 | data = "0x", 58 | nonce = "0x0", 59 | ) 60 | } else { 61 | transaction = TxData( 62 | chainId = ParticleNetwork.chainId.toString().toHexStr(), 63 | from = AuthCore.evm.getAddress()!!, 64 | to = to, 65 | value = "0x$amount", 66 | data = "0x", 67 | nonce = "0x0", 68 | gasPrice = high.maxFeePerGas.gweiToHexStr(), 69 | gasLimit = gasLimit, 70 | action = TxAction.normal.toString(), 71 | ) 72 | } 73 | return transaction.serialize() 74 | } 75 | 76 | private suspend fun getEvmTransGasLimit(from: String, to: String, value: String = "0x0", data: String = "0x"): String { 77 | val map = HashMap() 78 | map["from"] = from 79 | map["to"] = to 80 | map["value"] = value 81 | map["data"] = data 82 | val params = arrayListOf(map) 83 | val resp = ParticleNetwork.evm.rpc(EvmReqBodyMethod.ethEstimateGas.value, params) 84 | val jobj = JSONObject(resp.string()) 85 | val gasLimit = jobj.getString("result") 86 | return gasLimit 87 | } 88 | 89 | } -------------------------------------------------------------------------------- /app/src/main/res/anim/push_bottom_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/anim/push_bottom_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/anim/rotate_loading.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/bg_login.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Particle-Network/particle-android/4694eb62901203c4693a2670d11288b0a6371cee/app/src/main/res/drawable-xxxhdpi/bg_login.webp -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Particle-Network/particle-android/4694eb62901203c4693a2670d11288b0a6371cee/app/src/main/res/drawable-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/page1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Particle-Network/particle-android/4694eb62901203c4693a2670d11288b0a6371cee/app/src/main/res/drawable-xxxhdpi/page1.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/page2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Particle-Network/particle-android/4694eb62901203c4693a2670d11288b0a6371cee/app/src/main/res/drawable-xxxhdpi/page2.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/page3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Particle-Network/particle-android/4694eb62901203c4693a2670d11288b0a6371cee/app/src/main/res/drawable-xxxhdpi/page3.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/page4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Particle-Network/particle-android/4694eb62901203c4693a2670d11288b0a6371cee/app/src/main/res/drawable-xxxhdpi/page4.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_login_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_login_item_press.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_login_item_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Particle-Network/particle-android/4694eb62901203c4693a2670d11288b0a6371cee/app/src/main/res/drawable/ic_bg.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Particle-Network/particle-android/4694eb62901203c4693a2670d11288b0a6371cee/app/src/main/res/drawable/ic_logo.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/twotone_arrow_back_24.xml: -------------------------------------------------------------------------------- 1 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/twotone_settings_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_api_demo.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 23 | 24 | 36 | 37 | 38 | 39 | 40 | 46 | 47 | 52 | 53 | 63 | 64 | 65 |