├── AndroidDemo
├── app
│ ├── proguard-rules.pro
│ ├── src
│ │ └── main
│ │ │ ├── assets
│ │ │ └── .gitignore
│ │ │ ├── res
│ │ │ ├── values
│ │ │ │ └── themes.xml
│ │ │ └── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── java
│ │ │ └── io
│ │ │ │ └── ton
│ │ │ │ └── walletkit
│ │ │ │ └── demo
│ │ │ │ ├── domain
│ │ │ │ └── model
│ │ │ │ │ ├── PendingWalletRecord.kt
│ │ │ │ │ ├── WalletMetadata.kt
│ │ │ │ │ ├── WalletInterfaceType.kt
│ │ │ │ │ └── TonNetworkExtensions.kt
│ │ │ │ ├── presentation
│ │ │ │ ├── model
│ │ │ │ │ ├── ConnectPermissionUi.kt
│ │ │ │ │ ├── TransactionMessageUi.kt
│ │ │ │ │ ├── SessionSummary.kt
│ │ │ │ │ ├── TransactionDetailUi.kt
│ │ │ │ │ ├── SignDataRequestUi.kt
│ │ │ │ │ ├── TransactionRequestUi.kt
│ │ │ │ │ ├── ConnectRequestUi.kt
│ │ │ │ │ └── WalletSummary.kt
│ │ │ │ ├── util
│ │ │ │ │ ├── StringExtensions.kt
│ │ │ │ │ └── UrlSanitizer.kt
│ │ │ │ ├── state
│ │ │ │ │ ├── BrowserUiState.kt
│ │ │ │ │ ├── SheetState.kt
│ │ │ │ │ └── WalletUiState.kt
│ │ │ │ ├── ui
│ │ │ │ │ ├── sections
│ │ │ │ │ │ └── EventLogSection.kt
│ │ │ │ │ ├── components
│ │ │ │ │ │ ├── CodeBlock.kt
│ │ │ │ │ │ └── NetworkBadge.kt
│ │ │ │ │ └── dialog
│ │ │ │ │ │ └── UrlPromptDialog.kt
│ │ │ │ └── viewmodel
│ │ │ │ │ ├── WalletSecurityController.kt
│ │ │ │ │ └── WalletEventLogger.kt
│ │ │ │ └── di
│ │ │ │ └── AppModule.kt
│ │ │ └── AndroidManifest.xml
│ └── build.gradle.kts
├── META-INF
│ └── MANIFEST.MF
├── gradle
│ └── wrapper
│ │ ├── META-INF
│ │ └── MANIFEST.MF
│ │ ├── gradle-cli.jar
│ │ ├── gradle-files.jar
│ │ ├── gradle-wrapper.jar
│ │ ├── gradle-functional.jar
│ │ ├── gradle-wrapper-shared.jar
│ │ ├── gradle-base-annotations.jar
│ │ ├── gradle-wrapper-classpath.properties
│ │ └── gradle-wrapper.properties
├── gradle.properties
├── .gitignore
├── gradlew.bat
├── settings.gradle
├── settings.gradle.kts
├── gradlew
└── build.gradle.kts
├── TONWalletKit-Android
├── gradle
│ ├── wrapper
│ │ ├── META-INF
│ │ │ └── MANIFEST.MF
│ │ ├── gradle-cli.jar
│ │ ├── gradle-files.jar
│ │ ├── gradle-wrapper.jar
│ │ ├── gradle-functional.jar
│ │ ├── gradle-wrapper-shared.jar
│ │ ├── gradle-base-annotations.jar
│ │ ├── gradle-wrapper-classpath.properties
│ │ └── gradle-wrapper.properties
│ └── libs.versions.toml
├── gradlew.bat
├── impl
│ ├── src
│ │ ├── main
│ │ │ ├── assets
│ │ │ │ ├── .gitignore
│ │ │ │ └── walletkit
│ │ │ │ │ └── index.html
│ │ │ ├── java
│ │ │ │ └── io
│ │ │ │ │ └── ton
│ │ │ │ │ └── walletkit
│ │ │ │ │ ├── browser
│ │ │ │ │ └── PendingRequest.kt
│ │ │ │ │ ├── internal
│ │ │ │ │ ├── constants
│ │ │ │ │ │ ├── MiscConstants.kt
│ │ │ │ │ │ ├── CryptoConstants.kt
│ │ │ │ │ │ ├── BrowserConstants.kt
│ │ │ │ │ │ ├── NetworkConstants.kt
│ │ │ │ │ │ ├── LogConstants.kt
│ │ │ │ │ │ └── ReflectionConstants.kt
│ │ │ │ │ └── util
│ │ │ │ │ │ ├── IDGenerator.kt
│ │ │ │ │ │ ├── Logger.kt
│ │ │ │ │ │ └── JsonUtils.kt
│ │ │ │ │ ├── engine
│ │ │ │ │ ├── operations
│ │ │ │ │ │ └── requests
│ │ │ │ │ │ │ ├── CryptoRequests.kt
│ │ │ │ │ │ │ ├── WalletRequests.kt
│ │ │ │ │ │ │ ├── TransactionRequests.kt
│ │ │ │ │ │ │ ├── AssetRequests.kt
│ │ │ │ │ │ │ └── TonConnectRequests.kt
│ │ │ │ │ └── infrastructure
│ │ │ │ │ │ └── BridgeSerializer.kt
│ │ │ │ │ ├── storage
│ │ │ │ │ └── BridgeStorageAdapter.kt
│ │ │ │ │ └── core
│ │ │ │ │ └── WalletKitEngineKind.kt
│ │ │ └── cpp
│ │ │ │ └── CMakeLists.txt
│ │ ├── full
│ │ │ └── java
│ │ │ │ └── io
│ │ │ │ └── ton
│ │ │ │ └── walletkit
│ │ │ │ └── presentation
│ │ │ │ └── impl
│ │ │ │ └── quickjs
│ │ │ │ ├── QuickJsException.kt
│ │ │ │ └── QuickJsNativeLoader.kt
│ │ └── test
│ │ │ └── java
│ │ │ └── io
│ │ │ └── ton
│ │ │ └── walletkit
│ │ │ ├── TestHelpers.kt
│ │ │ └── ModelTest.kt
│ └── proguard-rules.pro
├── gradle.properties
├── .gitignore
├── settings.gradle.kts
├── gradlew
└── api
│ ├── proguard-rules.pro
│ ├── src
│ └── main
│ │ └── java
│ │ └── io
│ │ └── ton
│ │ └── walletkit
│ │ ├── model
│ │ ├── SignDataResult.kt
│ │ ├── TONNFTItems.kt
│ │ ├── TONLimitRequest.kt
│ │ ├── TONTransactionWithPreview.kt
│ │ ├── TONEmulationError.kt
│ │ ├── WalletAdapterInfo.kt
│ │ ├── WalletSignerInfo.kt
│ │ ├── TONAssetType.kt
│ │ ├── SignDataRequest.kt
│ │ ├── TONJettonTransferParams.kt
│ │ ├── TONNFTTransferParamsHuman.kt
│ │ ├── TONWalletData.kt
│ │ ├── WalletAccount.kt
│ │ ├── TONJettonWallets.kt
│ │ ├── TransactionRequest.kt
│ │ ├── TransactionType.kt
│ │ ├── TONJettonVerification.kt
│ │ ├── DAppInfo.kt
│ │ ├── KeyPair.kt
│ │ ├── TONTokenInfo.kt
│ │ ├── Transaction.kt
│ │ ├── TONNFTCollection.kt
│ │ ├── WalletSession.kt
│ │ ├── TONNetwork.kt
│ │ ├── TONNFTTransferParamsRaw.kt
│ │ ├── TONTransferParams.kt
│ │ ├── TONJetton.kt
│ │ └── TONMoneyFlow.kt
│ │ ├── internal
│ │ ├── constants
│ │ │ └── JsonConsts.kt
│ │ └── TONWalletKitFactory.kt
│ │ ├── extensions
│ │ └── WalletSessionExtensions.kt
│ │ ├── request
│ │ ├── RequestHandler.kt
│ │ └── TONWalletConnectionRequest.kt
│ │ ├── event
│ │ └── BrowserEvent.kt
│ │ ├── WalletKitBridgeException.kt
│ │ ├── WalletKitConstants.kt
│ │ └── listener
│ │ └── TONBridgeEventsHandler.kt
│ └── build.gradle.kts
├── README.md
├── LICENSE
├── LICENSE_HEADER
└── .gitignore
/AndroidDemo/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Keep default rules
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/assets/.gitignore:
--------------------------------------------------------------------------------
1 | walletkit/
2 |
--------------------------------------------------------------------------------
/AndroidDemo/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Implementation-Title: Gradle
3 | Implementation-Version: 8.7
4 |
5 |
--------------------------------------------------------------------------------
/AndroidDemo/gradle/wrapper/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Implementation-Title: Gradle
3 | Implementation-Version: 8.7
4 |
5 |
--------------------------------------------------------------------------------
/AndroidDemo/gradle/wrapper/gradle-cli.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ton-connect/kit-android/main/AndroidDemo/gradle/wrapper/gradle-cli.jar
--------------------------------------------------------------------------------
/AndroidDemo/gradle/wrapper/gradle-files.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ton-connect/kit-android/main/AndroidDemo/gradle/wrapper/gradle-files.jar
--------------------------------------------------------------------------------
/AndroidDemo/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ton-connect/kit-android/main/AndroidDemo/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/TONWalletKit-Android/gradle/wrapper/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Implementation-Title: Gradle
3 | Implementation-Version: 8.7
4 |
5 |
--------------------------------------------------------------------------------
/AndroidDemo/gradle.properties:
--------------------------------------------------------------------------------
1 | android.useAndroidX=true
2 | android.enableJetifier=true
3 | org.gradle.jvmargs=-Xmx2g -Dkotlin.daemon.jvm.options=-Xmx2g
4 |
--------------------------------------------------------------------------------
/AndroidDemo/gradle/wrapper/gradle-functional.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ton-connect/kit-android/main/AndroidDemo/gradle/wrapper/gradle-functional.jar
--------------------------------------------------------------------------------
/AndroidDemo/gradle/wrapper/gradle-wrapper-shared.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ton-connect/kit-android/main/AndroidDemo/gradle/wrapper/gradle-wrapper-shared.jar
--------------------------------------------------------------------------------
/TONWalletKit-Android/gradle/wrapper/gradle-cli.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ton-connect/kit-android/main/TONWalletKit-Android/gradle/wrapper/gradle-cli.jar
--------------------------------------------------------------------------------
/TONWalletKit-Android/gradle/wrapper/gradle-files.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ton-connect/kit-android/main/TONWalletKit-Android/gradle/wrapper/gradle-files.jar
--------------------------------------------------------------------------------
/AndroidDemo/gradle/wrapper/gradle-base-annotations.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ton-connect/kit-android/main/AndroidDemo/gradle/wrapper/gradle-base-annotations.jar
--------------------------------------------------------------------------------
/TONWalletKit-Android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ton-connect/kit-android/main/TONWalletKit-Android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/TONWalletKit-Android/gradle/wrapper/gradle-functional.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ton-connect/kit-android/main/TONWalletKit-Android/gradle/wrapper/gradle-functional.jar
--------------------------------------------------------------------------------
/AndroidDemo/gradle/wrapper/gradle-wrapper-classpath.properties:
--------------------------------------------------------------------------------
1 | projects=gradle-base-annotations,gradle-cli,gradle-files,gradle-functional,gradle-wrapper-shared
2 | runtime=
3 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/gradle/wrapper/gradle-wrapper-shared.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ton-connect/kit-android/main/TONWalletKit-Android/gradle/wrapper/gradle-wrapper-shared.jar
--------------------------------------------------------------------------------
/AndroidDemo/.gitignore:
--------------------------------------------------------------------------------
1 | # Gradle and build outputs
2 | .gradle/
3 | build/
4 | app/build/
5 | .idea/
6 | local.properties
7 | *.iml
8 | .DS_Store
9 | captures/
10 | .kotlin
11 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/gradle/wrapper/gradle-base-annotations.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ton-connect/kit-android/main/TONWalletKit-Android/gradle/wrapper/gradle-base-annotations.jar
--------------------------------------------------------------------------------
/TONWalletKit-Android/gradle/wrapper/gradle-wrapper-classpath.properties:
--------------------------------------------------------------------------------
1 | projects=gradle-base-annotations,gradle-cli,gradle-files,gradle-functional,gradle-wrapper-shared
2 | runtime=
3 |
--------------------------------------------------------------------------------
/AndroidDemo/gradlew.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 | set APP_HOME=%~dp0
3 | set DEFAULT_JVM_OPTS=-Xmx64m -Xms64m
4 | set GRADLE_WRAPPER_JAR=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
5 | java -jar "%GRADLE_WRAPPER_JAR%" %*
6 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 | set APP_HOME=%~dp0
3 | set DEFAULT_JVM_OPTS=-Xmx64m -Xms64m
4 | set GRADLE_WRAPPER_JAR=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
5 | java -jar "%GRADLE_WRAPPER_JAR%" %*
6 |
--------------------------------------------------------------------------------
/AndroidDemo/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/main/assets/.gitignore:
--------------------------------------------------------------------------------
1 | # WalletKit bundles are built from monorepo and committed to git
2 | # This ensures SDK consumers don't need to build JS bundles themselves
3 | # Only ignore temporary/cache files
4 | walletkit/.vite
5 | walletkit/assets
6 | walletkit/.DS_Store
7 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/gradle.properties:
--------------------------------------------------------------------------------
1 | android.useAndroidX=true
2 | android.enableJetifier=true
3 | org.gradle.jvmargs=-Xmx2g -Dkotlin.daemon.jvm.options=-Xmx2g
4 |
5 | # Library Publishing Configuration
6 | GROUP=io.github.ton-connect
7 | VERSION_NAME=1.0.0-beta01
8 | POM_ARTIFACT_ID=tonwalletkit-android
9 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/.gitignore:
--------------------------------------------------------------------------------
1 | # Gradle and build outputs
2 | .gradle/
3 | build/
4 | app/build/
5 | .cxx/
6 | .idea/
7 | local.properties
8 | *.iml
9 | .DS_Store
10 | captures/
11 | .kotlin
12 |
13 | # QuickJS source (deprecated, not for prod - see README.md)
14 | impl/src/main/cpp/third_party/quickjs-ng/
15 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # TON WalletKit Android
2 |
3 | TON blockchain wallet SDK for Android.
4 |
5 | ## Structure
6 |
7 | - **[TONWalletKit-Android](TONWalletKit-Android/)** - SDK library (Kotlin/Java)
8 | - **[AndroidDemo](AndroidDemo/)** - Demo application
9 |
10 | ## Quick Start
11 |
12 | See [TONWalletKit-Android/README.md](TONWalletKit-Android/README.md) for SDK documentation and usage examples.
13 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/main/assets/walletkit/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | WalletKit Android Bridge
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/AndroidDemo/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | gradlePluginPortal()
4 | google()
5 | mavenCentral()
6 | }
7 | }
8 |
9 | dependencyResolutionManagement {
10 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
11 | repositories {
12 | google()
13 | mavenCentral()
14 | }
15 | }
16 |
17 | rootProject.name = "AndroidWalletKitDemo"
18 | include(":app")
19 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | gradlePluginPortal()
6 | }
7 | }
8 |
9 | dependencyResolutionManagement {
10 | @Suppress("UnstableApiUsage")
11 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
12 | @Suppress("UnstableApiUsage")
13 | repositories {
14 | google()
15 | mavenCentral()
16 | }
17 | }
18 |
19 | rootProject.name = "TONWalletKit-Android"
20 |
21 | include(":api")
22 | include(":impl")
23 |
--------------------------------------------------------------------------------
/AndroidDemo/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google {
4 | content {
5 | includeGroupByRegex("com\\.android.*")
6 | includeGroupByRegex("com\\.google.*")
7 | includeGroupByRegex("androidx.*")
8 | }
9 | }
10 | mavenCentral()
11 | gradlePluginPortal()
12 | }
13 | }
14 |
15 | rootProject.name = "AndroidDemo"
16 |
17 | include(":app")
18 |
19 | dependencyResolutionManagement {
20 | repositories {
21 | mavenLocal()
22 | google()
23 | mavenCentral()
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/AndroidDemo/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | APP_BASE_NAME=`basename "$0"`
10 | APP_HOME=`dirname "$0"`
11 |
12 | DEFAULT_JVM_OPTS="-Xmx64m -Xms64m"
13 |
14 | GRADLE_WRAPPER_JAR="$APP_HOME/gradle/wrapper/gradle-wrapper.jar"
15 | GRADLE_WRAPPER_SHARED_JAR="$APP_HOME/gradle/wrapper/gradle-wrapper-shared.jar"
16 | CLASSPATH="$GRADLE_WRAPPER_JAR:$GRADLE_WRAPPER_SHARED_JAR:$APP_HOME/gradle/wrapper/gradle-cli.jar:$APP_HOME/gradle/wrapper/gradle-files.jar:$APP_HOME/gradle/wrapper/gradle-functional.jar:$APP_HOME/gradle/wrapper/gradle-base-annotations.jar"
17 |
18 | exec java $DEFAULT_JVM_OPTS -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
19 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | APP_BASE_NAME=`basename "$0"`
10 | APP_HOME=`dirname "$0"`
11 |
12 | DEFAULT_JVM_OPTS="-Xmx64m -Xms64m"
13 |
14 | GRADLE_WRAPPER_JAR="$APP_HOME/gradle/wrapper/gradle-wrapper.jar"
15 | GRADLE_WRAPPER_SHARED_JAR="$APP_HOME/gradle/wrapper/gradle-wrapper-shared.jar"
16 | CLASSPATH="$GRADLE_WRAPPER_JAR:$GRADLE_WRAPPER_SHARED_JAR:$APP_HOME/gradle/wrapper/gradle-cli.jar:$APP_HOME/gradle/wrapper/gradle-files.jar:$APP_HOME/gradle/wrapper/gradle-functional.jar:$APP_HOME/gradle/wrapper/gradle-base-annotations.jar"
17 |
18 | exec java $DEFAULT_JVM_OPTS -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
19 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # ============================================================
2 | # TON WalletKit Android SDK - API Module ProGuard Rules
3 | # These rules are used during API module builds (debug/release)
4 | # For consumer apps, see consumer-rules.pro
5 | # ============================================================
6 |
7 | # The API module should never be obfuscated as it defines the public interface
8 | # This file is used during library builds, but the API stays readable
9 |
10 | # Keep source file names and line numbers for debugging
11 | -keepattributes SourceFile,LineNumberTable
12 |
13 | # Don't obfuscate the public API
14 | -dontobfuscate
15 |
16 | # Keep all API classes and members
17 | -keep class io.ton.walletkit.** { *; }
18 |
19 | # Keep all annotations for proper IDE support
20 | -keepattributes *Annotation*,Signature,InnerClasses,EnclosingMethod
21 |
--------------------------------------------------------------------------------
/AndroidDemo/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.androidApplication) apply false
3 | alias(libs.plugins.kotlinAndroid) apply false
4 | alias(libs.plugins.androidLibrary) apply false
5 | alias(libs.plugins.kotlinCompose) apply false
6 | alias(libs.plugins.ksp) apply false
7 | alias(libs.plugins.hiltAndroid) apply false
8 | alias(libs.plugins.spotless)
9 | }
10 |
11 | spotless {
12 | kotlin {
13 | target("**/*.kt")
14 | targetExclude("**/build/**/*.kt", "**/generated/**/*.kt")
15 | licenseHeaderFile(rootProject.file("../LICENSE_HEADER"))
16 | ktlint().editorConfigOverride(
17 | mapOf("ktlint_function_naming_ignore_when_annotated_with" to "Composable"),
18 | )
19 | }
20 | kotlinGradle {
21 | target("**/*.gradle.kts")
22 | targetExclude("**/build/**")
23 | ktlint()
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2025 TonTech
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.
22 |
--------------------------------------------------------------------------------
/LICENSE_HEADER:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build outputs (JavaScript bundles)
2 | dist-android/
3 | dist-android-quickjs/
4 |
5 | # Dependencies
6 | node_modules/
7 |
8 | # macOS
9 | .DS_Store
10 |
11 | # Turbo cache
12 | .turbo/
13 |
14 | # Local Maven repository (generated artifacts)
15 | local-maven-repo/
16 |
17 | # Android Studio / Gradle (project level)
18 | .gradle/
19 | build/
20 | .cxx/
21 | *.iml
22 | .idea/workspace.xml
23 | .idea/tasks.xml
24 | .idea/gradle.xml
25 | .idea/assetWizardSettings.xml
26 | .idea/dictionaries
27 | .idea/libraries
28 | .idea/jarRepositories.xml
29 | .idea/compiler.xml
30 | .idea/misc.xml
31 | .idea/.gitignore
32 | .idea/caches
33 | .idea/modules.xml
34 | .idea/navEditor.xml
35 | .idea/deploymentTargetDropDown.xml
36 |
37 | # Local configuration files
38 | local.properties
39 | gradle.properties
40 | # But include gradle.properties for the SDK (contains required build config)
41 | !TONWalletKit-Android/gradle.properties
42 |
43 | # AAR files in libs folders (build artifacts)
44 | **/libs/*.aar
45 | **/libs/*.jar
46 |
47 | # Temporary documentation files (can be regenerated)
48 | JITPACK_QUICKSTART.md
49 | PUBLISHING_GUIDE.md
50 | gradle.properties.template
51 |
52 | # Build logs
53 | *.log
54 | node.log
55 | build-js-bundles.sh
56 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/domain/model/PendingWalletRecord.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.domain.model
23 |
24 | data class PendingWalletRecord(
25 | val metadata: WalletMetadata,
26 | val mnemonic: List?,
27 | )
28 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
18 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/presentation/model/ConnectPermissionUi.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.presentation.model
23 |
24 | data class ConnectPermissionUi(
25 | val name: String,
26 | val title: String,
27 | val description: String,
28 | )
29 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/SignDataResult.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | /**
25 | * Result of a sign data operation.
26 | *
27 | * @property signature Base64-encoded signature
28 | */
29 | data class SignDataResult(
30 | val signature: String,
31 | )
32 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/domain/model/WalletMetadata.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.domain.model
23 |
24 | import io.ton.walletkit.model.TONNetwork
25 |
26 | data class WalletMetadata(
27 | val name: String,
28 | val network: TONNetwork,
29 | val version: String,
30 | )
31 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/presentation/model/TransactionMessageUi.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.presentation.model
23 |
24 | data class TransactionMessageUi(
25 | val to: String,
26 | val amount: String,
27 | val comment: String?,
28 | val payload: String?,
29 | val stateInit: String?,
30 | )
31 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/TONNFTItems.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | import kotlinx.serialization.Serializable
25 |
26 | /**
27 | * NFT items list.
28 | *
29 | * @property items List of NFT items
30 | */
31 | @Serializable
32 | data class TONNFTItems(
33 | val items: List,
34 | )
35 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/presentation/util/StringExtensions.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.presentation.util
23 |
24 | fun String.abbreviated(length: Int = 6): String {
25 | if (this.length <= length * 2) return this
26 | val prefix = take(length)
27 | val suffix = takeLast(length)
28 | return "$prefix…$suffix"
29 | }
30 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/full/java/io/ton/walletkit/presentation/impl/quickjs/QuickJsException.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.presentation.impl.quickjs
23 |
24 | /**
25 | * QuickJS exception.
26 | * @suppress Internal implementation class. Not part of public API.
27 | */
28 | internal class QuickJsException(message: String, cause: Throwable? = null) : RuntimeException(message, cause)
29 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/presentation/model/SessionSummary.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.presentation.model
23 |
24 | data class SessionSummary(
25 | val sessionId: String,
26 | val dAppName: String,
27 | val walletAddress: String,
28 | val dAppUrl: String?,
29 | val manifestUrl: String?,
30 | val iconUrl: String?,
31 | val createdAt: Long?,
32 | val lastActivity: Long?,
33 | )
34 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/presentation/state/BrowserUiState.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.presentation.state
23 |
24 | /**
25 | * UI state for the internal browser screen.
26 | */
27 | data class BrowserUiState(
28 | val isLoading: Boolean = false,
29 | val currentUrl: String = "",
30 | val error: String? = null,
31 | val lastRequest: String? = null,
32 | val requestCount: Int = 0,
33 | )
34 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/main/java/io/ton/walletkit/browser/PendingRequest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.browser
23 |
24 | /**
25 | * Tracks a pending request from a specific frame.
26 | * Stores the frameId so we can send responses back to the correct window/iframe.
27 | */
28 | internal data class PendingRequest(
29 | val frameId: String,
30 | val messageId: String,
31 | val method: String,
32 | val timestamp: Long,
33 | )
34 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/full/java/io/ton/walletkit/presentation/impl/quickjs/QuickJsNativeLoader.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.presentation.impl.quickjs
23 |
24 | import java.util.concurrent.atomic.AtomicBoolean
25 |
26 | internal object QuickJsNativeLoader {
27 | private val loaded = AtomicBoolean(false)
28 |
29 | fun load() {
30 | if (loaded.compareAndSet(false, true)) {
31 | System.loadLibrary("walletkitquickjs")
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/TONLimitRequest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | import kotlinx.serialization.Serializable
25 |
26 | /**
27 | * Limit and offset parameters for paginated requests.
28 | *
29 | * @property limit Maximum number of items to return
30 | * @property offset Offset from the beginning of the list
31 | */
32 | @Serializable
33 | data class TONLimitRequest(
34 | val limit: Int? = null,
35 | val offset: Int? = null,
36 | )
37 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/presentation/model/TransactionDetailUi.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.presentation.model
23 |
24 | data class TransactionDetailUi(
25 | val hash: String,
26 | val timestamp: Long,
27 | val isOutgoing: Boolean,
28 | val amount: String,
29 | val fee: String,
30 | val fromAddress: String?,
31 | val toAddress: String?,
32 | val comment: String?,
33 | val status: String,
34 | val blockSeqno: Int,
35 | val lt: String,
36 | )
37 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/TONTransactionWithPreview.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | /**
25 | * Transaction content with optional preview.
26 | *
27 | * Returned by transaction creation methods that support preview emulation.
28 | *
29 | * @property transaction Transaction content as JSON string (to be signed and sent)
30 | * @property preview Optional preview of transaction effects (if emulation succeeded)
31 | */
32 | data class TONTransactionWithPreview(
33 | val transaction: String,
34 | val preview: TONTransactionPreview? = null,
35 | )
36 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/TONEmulationError.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | import kotlinx.serialization.Serializable
25 |
26 | /**
27 | * Error from transaction emulation.
28 | *
29 | * Mirrors the shared TON Wallet Kit error contract for cross-platform consistency.
30 | *
31 | * @property name Error name/type
32 | * @property message Error message
33 | * @property cause Error cause/reason
34 | */
35 | @Serializable
36 | data class TONEmulationError(
37 | val name: String,
38 | val message: String? = null,
39 | val cause: String? = null,
40 | )
41 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/presentation/model/SignDataRequestUi.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.presentation.model
23 |
24 | import io.ton.walletkit.request.TONWalletSignDataRequest
25 | import org.json.JSONObject
26 |
27 | data class SignDataRequestUi(
28 | val id: String,
29 | val walletAddress: String,
30 | val dAppName: String? = null,
31 | val payloadType: String,
32 | val payloadContent: String,
33 | val preview: String?,
34 | val raw: JSONObject,
35 | val signDataRequest: TONWalletSignDataRequest? = null, // Request object with approve/reject helpers
36 | )
37 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/main/cpp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.22.1)
2 |
3 | project(walletkitquickjs)
4 |
5 | set(CMAKE_C_STANDARD 17)
6 | set(CMAKE_CXX_STANDARD 17)
7 | set(CMAKE_POSITION_INDEPENDENT_CODE ON)
8 |
9 | set(QUICKJS_NG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/quickjs-ng")
10 |
11 | # Check if QuickJS sources exist - if not, skip native build
12 | # This allows WebView variant to build without QuickJS sources
13 | if (NOT EXISTS "${QUICKJS_NG_DIR}/quickjs.h")
14 | message(WARNING "quickjs-ng sources are missing. Skipping native build. Run ./gradlew :bridge:prepareQuickJs to build full variant with QuickJS support.")
15 | return()
16 | endif()
17 |
18 | set(QUICKJS_NG_SOURCES
19 | ${QUICKJS_NG_DIR}/quickjs.c
20 | ${QUICKJS_NG_DIR}/libregexp.c
21 | ${QUICKJS_NG_DIR}/libunicode.c
22 | ${QUICKJS_NG_DIR}/cutils.c
23 | ${QUICKJS_NG_DIR}/xsum.c
24 | )
25 |
26 | add_library(walletkitquickjs SHARED
27 | quickjs_bridge.cpp
28 | ${QUICKJS_NG_SOURCES}
29 | )
30 |
31 | target_include_directories(walletkitquickjs
32 | PRIVATE
33 | ${QUICKJS_NG_DIR}
34 | )
35 |
36 | target_compile_definitions(walletkitquickjs
37 | PRIVATE
38 | CONFIG_VERSION="quickjs-ng v0.10.1"
39 | _GNU_SOURCE
40 | )
41 |
42 | target_compile_options(walletkitquickjs
43 | PRIVATE
44 | -Os
45 | -fvisibility=hidden
46 | -fexceptions
47 | -Wno-implicit-fallthrough
48 | -Wno-missing-field-initializers
49 | -Wno-unused-parameter
50 | )
51 |
52 | target_link_libraries(walletkitquickjs
53 | log
54 | )
55 |
56 | target_link_options(walletkitquickjs
57 | PRIVATE
58 | -Wl,-z,max-page-size=16384
59 | -Wl,-z,common-page-size=4096
60 | -Wl,--hash-style=both
61 | )
62 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/WalletAdapterInfo.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | /**
25 | * Represents a wallet adapter created from a signer.
26 | *
27 | * This is the result of step 2 in the wallet creation pattern:
28 | * ```kotlin
29 | * val adapter = walletKit.createV5R1Adapter(signer)
30 | * ```
31 | *
32 | * @property adapterId Internal ID used to reference this adapter
33 | * @property address The wallet address that will be created when this adapter is added
34 | */
35 | data class WalletAdapterInfo(
36 | val adapterId: String,
37 | val address: String,
38 | )
39 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/presentation/model/TransactionRequestUi.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.presentation.model
23 |
24 | import io.ton.walletkit.request.TONWalletTransactionRequest
25 | import org.json.JSONObject
26 |
27 | data class TransactionRequestUi(
28 | val id: String,
29 | val walletAddress: String,
30 | val dAppName: String,
31 | val validUntil: Long?,
32 | val messages: List,
33 | val preview: String?,
34 | val raw: JSONObject,
35 | val transactionRequest: TONWalletTransactionRequest? = null, // Request object with approve/reject helpers
36 | )
37 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/WalletSignerInfo.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | /**
25 | * Represents a wallet signer created from mnemonic or private key.
26 | *
27 | * This is the result of step 1 in the wallet creation pattern:
28 | * ```kotlin
29 | * val signer = walletKit.createSignerFromMnemonic(mnemonic)
30 | * ```
31 | *
32 | * @property signerId Internal ID used to reference this signer
33 | * @property publicKey Hex-encoded public key derived from the mnemonic/private key
34 | */
35 | data class WalletSignerInfo(
36 | val signerId: String,
37 | val publicKey: String,
38 | )
39 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/TONAssetType.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | import io.ton.walletkit.internal.constants.JsonConsts
25 | import kotlinx.serialization.SerialName
26 | import kotlinx.serialization.Serializable
27 |
28 | /**
29 | * Type of TON asset.
30 | *
31 | * Mirrors the shared TON Wallet Kit model for cross-platform consistency.
32 | */
33 | @Serializable
34 | enum class TONAssetType {
35 | /** Native TON currency */
36 | @SerialName(JsonConsts.VALUE_ASSET_TON)
37 | TON,
38 |
39 | /** Jetton token */
40 | @SerialName(JsonConsts.VALUE_ASSET_JETTON)
41 | JETTON,
42 | }
43 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/presentation/model/ConnectRequestUi.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.presentation.model
23 |
24 | import io.ton.walletkit.request.TONWalletConnectionRequest
25 | import org.json.JSONObject
26 |
27 | data class ConnectRequestUi(
28 | val id: String,
29 | val dAppName: String,
30 | val dAppUrl: String,
31 | val manifestUrl: String,
32 | val iconUrl: String?,
33 | val permissions: List,
34 | val requestedItems: List,
35 | val raw: JSONObject,
36 | val connectRequest: TONWalletConnectionRequest? = null, // Request object with approve/reject helpers
37 | )
38 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/SignDataRequest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | /**
25 | * Represents a request from a dApp to sign arbitrary data.
26 | *
27 | * This is used for scenarios where a dApp needs cryptographic proof
28 | * of wallet ownership or wants to sign a message without creating
29 | * a blockchain transaction.
30 | *
31 | * @property payload The data to be signed, typically encoded as base64 or hex
32 | * @property schema Optional identifier for the data schema/format (e.g., "ton-proof-item-v2")
33 | */
34 | data class SignDataRequest(
35 | val payload: String,
36 | val schema: String? = null,
37 | )
38 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/TONJettonTransferParams.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | import kotlinx.serialization.Serializable
25 |
26 | /**
27 | * Parameters for transferring jettons.
28 | *
29 | * @property toAddress Recipient wallet address
30 | * @property jettonAddress Jetton master contract address
31 | * @property amount Amount of jettons to transfer (in jetton units, not considering decimals)
32 | * @property comment Optional comment/memo for the transfer
33 | */
34 | @Serializable
35 | data class TONJettonTransferParams(
36 | val toAddress: String,
37 | val jettonAddress: String,
38 | val amount: String,
39 | val comment: String? = null,
40 | )
41 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/TONNFTTransferParamsHuman.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | import kotlinx.serialization.Serializable
25 |
26 | /**
27 | * Human-friendly NFT transfer parameters.
28 | *
29 | * @property nftAddress NFT contract address to transfer
30 | * @property transferAmount Amount of TON to attach to the transfer (for gas fees)
31 | * @property toAddress Recipient wallet address
32 | * @property comment Optional comment/memo for the transfer
33 | */
34 | @Serializable
35 | data class TONNFTTransferParamsHuman(
36 | val nftAddress: String,
37 | val transferAmount: String,
38 | val toAddress: String,
39 | val comment: String? = null,
40 | )
41 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/internal/constants/JsonConsts.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.internal.constants
23 |
24 | /**
25 | * JSON constants used for @SerialName annotations in the API module.
26 | * These must match the values in impl module's JsonConstants.
27 | */
28 | internal object JsonConsts {
29 | const val KEY_VALID_UNTIL = "valid_until"
30 | const val VALUE_SIGN_DATA_TEXT = "text"
31 | const val VALUE_SIGN_DATA_BINARY = "binary"
32 | const val VALUE_SIGN_DATA_CELL = "cell"
33 | const val VALUE_ASSET_TON = "ton"
34 | const val VALUE_ASSET_JETTON = "jetton"
35 | const val VALUE_PREVIEW_ERROR = "error"
36 | const val VALUE_PREVIEW_SUCCESS = "success"
37 | }
38 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/presentation/util/UrlSanitizer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.presentation.util
23 |
24 | /**
25 | * Utility for sanitizing and validating URLs.
26 | */
27 | object UrlSanitizer {
28 |
29 | /**
30 | * Sanitize a URL by removing invalid or placeholder values.
31 | *
32 | * Returns null if:
33 | * - Value is null or blank
34 | * - Value is the string "null" (case-insensitive)
35 | *
36 | * Otherwise returns the trimmed URL.
37 | */
38 | fun sanitize(value: String?): String? {
39 | if (value.isNullOrBlank()) return null
40 | if (value.equals("null", ignoreCase = true)) return null
41 | return value.trim()
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/test/java/io/ton/walletkit/TestHelpers.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit
23 |
24 | import io.ton.walletkit.event.TONWalletKitEvent
25 | import io.ton.walletkit.listener.TONBridgeEventsHandler
26 | import java.util.concurrent.CopyOnWriteArrayList
27 |
28 | val NoopEventsHandler: TONBridgeEventsHandler =
29 | object : TONBridgeEventsHandler {
30 | override fun handle(event: TONWalletKitEvent) = Unit
31 | }
32 |
33 | class RecordingEventsHandler : TONBridgeEventsHandler {
34 | private val _events = CopyOnWriteArrayList()
35 | val events: List
36 | get() = _events
37 |
38 | override fun handle(event: TONWalletKitEvent) {
39 | _events += event
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/TONWalletData.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | import kotlinx.serialization.Serializable
25 |
26 | /**
27 | * Data required to create a new wallet.
28 | *
29 | * Mirrors the shared TON Wallet Kit data contract for cross-platform consistency.
30 | *
31 | * @property mnemonic Mnemonic phrase words (12 or 24 words)
32 | * @property name User-assigned wallet name
33 | * @property network Network to create wallet on
34 | * @property version Wallet contract version (e.g., "v5r1", "v4r2")
35 | */
36 | @Serializable
37 | data class TONWalletData(
38 | val mnemonic: List,
39 | val name: String,
40 | val network: TONNetwork = TONNetwork.MAINNET,
41 | val version: String = "v5r1",
42 | )
43 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/main/java/io/ton/walletkit/internal/constants/MiscConstants.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.internal.constants
23 |
24 | /**
25 | * Miscellaneous string constants used throughout the WalletKit SDK.
26 | * Contains various literals that don't fit into other constant categories.
27 | *
28 | * @suppress Internal implementation constants. Not part of public API.
29 | */
30 | internal object MiscConstants {
31 | // String Delimiters and Separators
32 | const val SPACE_DELIMITER = " "
33 | const val EMPTY_STRING = ""
34 |
35 | // URL Schemes
36 | const val SCHEME_HTTPS = "https://"
37 | const val SCHEME_HTTP = "http://"
38 |
39 | // Numeric Constants
40 | const val BRIDGE_STORAGE_KEYS_COUNT_SUFFIX = " bridge storage keys"
41 | }
42 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/extensions/WalletSessionExtensions.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.extensions
23 |
24 | import io.ton.walletkit.ITONWalletKit
25 | import io.ton.walletkit.WalletKitBridgeException
26 | import io.ton.walletkit.model.WalletSession
27 |
28 | /**
29 | * Convenience extension on WalletSession to disconnect itself via the kit.
30 | * This keeps the session model as a simple data object and provides an
31 | * ergonomic helper for callers.
32 | *
33 | * @param kit The ITONWalletKit instance to use for disconnection
34 | */
35 | suspend fun WalletSession.disconnect(kit: ITONWalletKit) {
36 | if (sessionId.isBlank()) {
37 | throw WalletKitBridgeException("Session ID is empty")
38 | }
39 | kit.disconnectSession(sessionId)
40 | }
41 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/WalletAccount.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | /**
25 | * Represents a wallet account managed by WalletKit.
26 | *
27 | * @property address Wallet address
28 | * @property publicKey Public key of the wallet (nullable if not available)
29 | * @property name User-assigned name for the wallet (nullable)
30 | * @property version Wallet version (e.g., "v5r1", "v4r2")
31 | * @property network Network the wallet operates on (e.g., "mainnet", "testnet")
32 | * @property index Wallet derivation index
33 | */
34 | data class WalletAccount(
35 | val address: String,
36 | val publicKey: String?,
37 | val name: String? = null,
38 | val version: String,
39 | val network: String,
40 | val index: Int,
41 | )
42 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.androidLibrary)
3 | alias(libs.plugins.kotlinAndroid)
4 | alias(libs.plugins.kotlinSerialization)
5 | }
6 |
7 | android {
8 | namespace = "io.ton.walletkit"
9 | compileSdk = 36
10 |
11 | defaultConfig {
12 | minSdk = 24
13 | consumerProguardFiles("consumer-rules.pro")
14 | }
15 |
16 | buildTypes {
17 | release {
18 | isMinifyEnabled = false
19 | // API module doesn't need obfuscation - it's the public interface
20 | // Consumer rules will keep everything public
21 | }
22 | }
23 |
24 | // Enable generation of BuildConfig (needed for sources JAR task)
25 | buildFeatures {
26 | buildConfig = true
27 | }
28 |
29 | compileOptions {
30 | sourceCompatibility = JavaVersion.VERSION_17
31 | targetCompatibility = JavaVersion.VERSION_17
32 | }
33 | }
34 |
35 | kotlin {
36 | compilerOptions {
37 | jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
38 | }
39 | }
40 |
41 | // Generate sources JAR with KDocs for better IDE experience
42 | val sourcesJar =
43 | tasks.register("sourcesJar") {
44 | archiveClassifier.set("sources")
45 | from(android.sourceSets["main"].java.srcDirs)
46 | // Include all Kotlin source files with KDocs
47 | include("**/*.kt")
48 | include("**/*.java")
49 | // Exclude internal implementation details
50 | exclude("**/internal/**")
51 | }
52 |
53 | // Attach sources JAR to artifacts (for Maven publishing)
54 | artifacts {
55 | archives(sourcesJar)
56 | }
57 |
58 | dependencies {
59 | // Minimal dependencies - only what public API needs
60 | api(libs.kotlinxSerializationJson)
61 | api(libs.kotlinxCoroutinesAndroid)
62 |
63 | // Test dependencies
64 | testImplementation(libs.junit)
65 | testImplementation(libs.kotlinxCoroutinesTest)
66 | }
67 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/TONJettonWallets.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | import kotlinx.serialization.SerialName
25 | import kotlinx.serialization.Serializable
26 |
27 | /**
28 | * Jetton wallets list with metadata.
29 | *
30 | * Response from fetching jettons by owner address.
31 | *
32 | * @property items List of jetton wallets
33 | * @property addressBook Address book for user-friendly addresses
34 | * @property metadata Additional metadata for addresses
35 | */
36 | @Serializable
37 | data class TONJettonWallets(
38 | @SerialName("jettons")
39 | val items: List,
40 | @SerialName("address_book")
41 | val addressBook: Map? = null,
42 | val metadata: Map? = null,
43 | )
44 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/main/java/io/ton/walletkit/internal/constants/CryptoConstants.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.internal.constants
23 |
24 | /**
25 | * Constants for cryptographic operations and Android KeyStore.
26 | * Defines algorithm specifications, key sizes, and keystore parameters.
27 | *
28 | * @suppress Internal implementation constants. Not part of public API.
29 | */
30 | internal object CryptoConstants {
31 | // Keystore and Cipher
32 | const val ANDROID_KEYSTORE = "AndroidKeyStore"
33 | const val DEFAULT_KEYSTORE_ALIAS = "walletkit_master_key"
34 | const val CIPHER_TRANSFORMATION = "AES/GCM/NoPadding"
35 |
36 | // Key Sizes
37 | const val AES_KEY_SIZE = 256
38 | const val GCM_IV_SIZE = 12 // 96 bits recommended for GCM
39 |
40 | // Log Tags
41 | const val TAG_CRYPTO_MANAGER = "CryptoManager"
42 | }
43 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/domain/model/WalletInterfaceType.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.domain.model
23 |
24 | /**
25 | * Wallet interface type determines how the wallet handles signing operations.
26 | */
27 | enum class WalletInterfaceType(val value: String) {
28 | /**
29 | * Standard mnemonic-based wallet that automatically handles signing.
30 | */
31 | MNEMONIC("mnemonic"),
32 |
33 | /**
34 | * Secret key (private key) based wallet that automatically handles signing.
35 | */
36 | SECRET_KEY("secretKey"),
37 |
38 | /**
39 | * Custom signer wallet that requires user confirmation for each signing operation.
40 | */
41 | SIGNER("signer"),
42 | ;
43 |
44 | companion object {
45 | fun fromValue(value: String): WalletInterfaceType = entries.find { it.value == value } ?: MNEMONIC
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/main/java/io/ton/walletkit/engine/operations/requests/CryptoRequests.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.engine.operations.requests
23 |
24 | import kotlinx.serialization.Serializable
25 |
26 | /**
27 | * Internal bridge request models for cryptographic operations.
28 | * These DTOs represent the exact JSON structure sent to the JavaScript bridge.
29 | *
30 | * @suppress Internal bridge communication only.
31 | */
32 |
33 | @Serializable
34 | internal data class CreateMnemonicRequest(
35 | val count: Int,
36 | )
37 |
38 | @Serializable
39 | internal data class MnemonicToKeyPairRequest(
40 | val mnemonic: List,
41 | val mnemonicType: String = "ton",
42 | )
43 |
44 | @Serializable
45 | internal data class SignRequest(
46 | // ByteArray as List for JSON serialization
47 | val data: List,
48 | val secretKey: List,
49 | )
50 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/TransactionRequest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | /**
25 | * Represents a transaction request initiated by a dApp.
26 | *
27 | * This model contains all the necessary information to construct and send
28 | * a blockchain transaction. It's typically received from a dApp through
29 | * the TON Connect protocol.
30 | *
31 | * @property recipient The destination wallet address on the TON blockchain
32 | * @property amount Transaction amount in nanoTON (1 TON = 1,000,000,000 nanoTON)
33 | * @property comment Optional text comment/memo attached to the transaction
34 | * @property payload Optional raw cell payload for complex contract interactions
35 | */
36 | data class TransactionRequest(
37 | val recipient: String,
38 | val amount: String,
39 | val comment: String? = null,
40 | val payload: String? = null,
41 | )
42 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/request/RequestHandler.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.request
23 |
24 | import io.ton.walletkit.event.ConnectRequestEvent
25 | import io.ton.walletkit.event.SignDataRequestEvent
26 | import io.ton.walletkit.event.TransactionRequestEvent
27 |
28 | /**
29 | * Internal interface for handling request approvals/rejections.
30 | * Implementation provided by the bridge module.
31 | * @suppress
32 | */
33 | interface RequestHandler {
34 | suspend fun approveConnect(event: ConnectRequestEvent)
35 | suspend fun rejectConnect(event: ConnectRequestEvent, reason: String?)
36 |
37 | suspend fun approveTransaction(event: TransactionRequestEvent)
38 | suspend fun rejectTransaction(event: TransactionRequestEvent, reason: String?)
39 |
40 | suspend fun approveSignData(event: SignDataRequestEvent)
41 | suspend fun rejectSignData(event: SignDataRequestEvent, reason: String?)
42 | }
43 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/presentation/model/WalletSummary.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.presentation.model
23 |
24 | import io.ton.walletkit.demo.domain.model.WalletInterfaceType
25 | import io.ton.walletkit.model.TONNetwork
26 | import io.ton.walletkit.model.Transaction
27 |
28 | data class WalletSummary(
29 | val address: String,
30 | val name: String,
31 | val network: TONNetwork,
32 | val version: String,
33 | val publicKey: String?,
34 | val balanceNano: String?,
35 | val balance: String?,
36 | val transactions: List?,
37 | val lastUpdated: Long?,
38 | val connectedSessions: List = emptyList(), // Sessions connected to this wallet
39 | val createdAt: Long? = null, // Unix timestamp in milliseconds when wallet was created/imported
40 | val interfaceType: WalletInterfaceType = WalletInterfaceType.MNEMONIC, // Wallet interface type
41 | )
42 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/TransactionType.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | /**
25 | * Categorizes the direction and nature of a blockchain transaction.
26 | *
27 | * This enum helps determine how a transaction should be displayed
28 | * in the user interface and how amounts should be formatted.
29 | */
30 | enum class TransactionType {
31 | /**
32 | * Transaction where the wallet receives funds from another address.
33 | * Amount should typically be displayed with a positive indicator.
34 | */
35 | INCOMING,
36 |
37 | /**
38 | * Transaction where the wallet sends funds to another address.
39 | * Amount should typically be displayed with a negative indicator.
40 | */
41 | OUTGOING,
42 |
43 | /**
44 | * Transaction type could not be determined.
45 | * This may occur for complex contract interactions or parsing errors.
46 | */
47 | UNKNOWN,
48 | }
49 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/TONJettonVerification.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | import kotlinx.serialization.Serializable
25 |
26 | /**
27 | * Jetton verification information.
28 | *
29 | * @property verified Whether the jetton is verified
30 | * @property source Verification source
31 | * @property warnings List of warnings about the jetton
32 | */
33 | @Serializable
34 | data class TONJettonVerification(
35 | val verified: Boolean? = null,
36 | val source: Source? = null,
37 | val warnings: List? = null,
38 | ) {
39 | /**
40 | * Verification source types.
41 | */
42 | @Serializable
43 | enum class Source {
44 | @kotlinx.serialization.SerialName("toncenter")
45 | TONCENTER,
46 |
47 | @kotlinx.serialization.SerialName("community")
48 | COMMUNITY,
49 |
50 | @kotlinx.serialization.SerialName("manual")
51 | MANUAL,
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/event/BrowserEvent.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.event
23 |
24 | /**
25 | * Events emitted by the internal browser.
26 | */
27 | sealed class BrowserEvent {
28 | /**
29 | * Page started loading.
30 | */
31 | data class PageStarted(val url: String) : BrowserEvent()
32 |
33 | /**
34 | * Page finished loading.
35 | */
36 | data class PageFinished(val url: String) : BrowserEvent()
37 |
38 | /**
39 | * Error occurred.
40 | */
41 | data class Error(val message: String) : BrowserEvent()
42 |
43 | /**
44 | * Bridge request received from dApp (connect, send transaction, etc.).
45 | * The SDK automatically forwards this to WalletKit engine for processing.
46 | * This event is for UI updates (showing notifications, etc.).
47 | */
48 | data class BridgeRequest(
49 | val messageId: String,
50 | val method: String,
51 | val request: String,
52 | ) : BrowserEvent()
53 | }
54 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/main/java/io/ton/walletkit/engine/infrastructure/BridgeSerializer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.engine.infrastructure
23 |
24 | import kotlinx.serialization.json.Json
25 | import org.json.JSONObject
26 |
27 | /**
28 | * Bridge serialization utilities for converting Kotlin data classes to JSONObject
29 | * instances used by the JavaScript bridge RPC layer.
30 | *
31 | * This centralizes the conversion pattern and ensures type-safe bridge communication.
32 | *
33 | * @suppress Internal utility for bridge operations.
34 | */
35 |
36 | /**
37 | * Serialize any @Serializable value to JSONObject for bridge communication.
38 | *
39 | * This replaces manual JSONObject().apply { put(...) } patterns with type-safe
40 | * data class serialization.
41 | *
42 | * @param value The @Serializable value to encode
43 | * @return JSONObject ready for bridge RPC calls
44 | */
45 | internal inline fun Json.toJSONObject(value: T): JSONObject {
46 | return JSONObject(encodeToString(value))
47 | }
48 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/domain/model/TonNetworkExtensions.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.domain.model
23 |
24 | import io.ton.walletkit.model.TONNetwork
25 |
26 | private const val BRIDGE_MAINNET = "-239"
27 | private const val BRIDGE_TESTNET = "-3"
28 |
29 | /**
30 | * Convert SDK network enum to the string value we persist in demo storage.
31 | */
32 | fun TONNetwork.toBridgeValue(): String = when (this) {
33 | TONNetwork.MAINNET -> BRIDGE_MAINNET
34 | TONNetwork.TESTNET -> BRIDGE_TESTNET
35 | }
36 |
37 | /**
38 | * Parse a persisted network string (bridge manifest style or chain id) into SDK enum.
39 | */
40 | fun String?.toTonNetwork(fallback: TONNetwork = TONNetwork.MAINNET): TONNetwork {
41 | val normalized = this?.trim()?.lowercase()
42 | return when (normalized) {
43 | BRIDGE_MAINNET -> TONNetwork.MAINNET
44 | BRIDGE_TESTNET -> TONNetwork.TESTNET
45 | null, "" -> fallback
46 | else -> TONNetwork.fromString(normalized) ?: fallback
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/DAppInfo.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | import kotlinx.serialization.Serializable
25 |
26 | /**
27 | * Information about a decentralized application (dApp) requesting wallet interaction.
28 | *
29 | * This model represents metadata about a dApp that is initiating a connection,
30 | * transaction, or data signing request with the wallet. It's used throughout
31 | * the SDK to provide context about which application is making requests.
32 | *
33 | * @property name Display name of the dApp (e.g., "TON Wallet")
34 | * @property url Main URL of the dApp (e.g., "https://wallet.ton.org")
35 | * @property iconUrl Optional URL to the dApp's icon/logo for display purposes
36 | * @property manifestUrl Optional URL to the TON Connect manifest file containing dApp metadata
37 | */
38 | @Serializable
39 | data class DAppInfo(
40 | val name: String,
41 | val url: String,
42 | val iconUrl: String? = null,
43 | val manifestUrl: String? = null,
44 | )
45 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/KeyPair.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | /**
25 | * Represents an Ed25519 key pair consisting of a public and secret key.
26 | *
27 | * @property publicKey The public key as a byte array (32 bytes)
28 | * @property secretKey The secret (private) key as a byte array (64 bytes for Ed25519)
29 | */
30 | data class KeyPair(
31 | val publicKey: ByteArray,
32 | val secretKey: ByteArray,
33 | ) {
34 | override fun equals(other: Any?): Boolean {
35 | if (this === other) return true
36 | if (javaClass != other?.javaClass) return false
37 |
38 | other as KeyPair
39 |
40 | if (!publicKey.contentEquals(other.publicKey)) return false
41 | if (!secretKey.contentEquals(other.secretKey)) return false
42 |
43 | return true
44 | }
45 |
46 | override fun hashCode(): Int {
47 | // SECURITY: Only hash public key to prevent information leakage.
48 | return publicKey.contentHashCode()
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/TONTokenInfo.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | import kotlinx.serialization.Serializable
25 | import kotlinx.serialization.json.JsonObject
26 |
27 | /**
28 | * Token metadata information.
29 | *
30 | * @property description Token or NFT description
31 | * @property image Image URL
32 | * @property name Token or NFT name
33 | * @property nftIndex NFT index in collection (for NFTs)
34 | * @property symbol Token symbol
35 | * @property type Token type
36 | * @property valid Whether the metadata is valid
37 | * @property extra Extra metadata fields (e.g., _image_medium, _image_big, _image_small, uri, etc.)
38 | */
39 | @Serializable
40 | data class TONTokenInfo(
41 | val description: String? = null,
42 | val image: String? = null,
43 | val name: String? = null,
44 | val nftIndex: String? = null,
45 | val symbol: String? = null,
46 | val type: String? = null,
47 | val valid: Boolean? = null,
48 | val extra: JsonObject? = null,
49 | )
50 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/WalletKitBridgeException.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit
23 |
24 | /**
25 | * Exception thrown when an error occurs during WalletKit bridge operations.
26 | *
27 | * This exception is thrown when the JavaScript bridge encounters issues such as:
28 | * - Bridge initialization failures
29 | * - Invalid responses from the JavaScript layer
30 | * - Communication errors between Kotlin and JavaScript
31 | * - JavaScript runtime exceptions that propagate to the native layer
32 | * - Timeout errors when waiting for bridge responses
33 | *
34 | * Example scenarios:
35 | * ```
36 | * // Bridge not initialized
37 | * throw WalletKitBridgeException("Bridge not initialized")
38 | *
39 | * // Invalid JSON response
40 | * throw WalletKitBridgeException("Failed to parse bridge response: $jsonString")
41 | *
42 | * // JavaScript error
43 | * throw WalletKitBridgeException("JavaScript error: ${error.message}")
44 | * ```
45 | *
46 | * @property message A descriptive error message explaining what went wrong
47 | * @see io.ton.walletkit.presentation.WalletKitEngine
48 | */
49 | class WalletKitBridgeException(message: String) : Exception(message)
50 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/main/java/io/ton/walletkit/engine/operations/requests/WalletRequests.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.engine.operations.requests
23 |
24 | import kotlinx.serialization.Serializable
25 |
26 | /**
27 | * Internal bridge request models for wallet operations.
28 | * These DTOs represent the exact JSON structure sent to the JavaScript bridge.
29 | *
30 | * @suppress Internal bridge communication only.
31 | */
32 |
33 | @Serializable
34 | internal data class CreateSignerRequest(
35 | val mnemonic: List? = null,
36 | val secretKey: String? = null,
37 | val mnemonicType: String = "ton",
38 | )
39 |
40 | @Serializable
41 | internal data class CreateAdapterRequest(
42 | val signerId: String,
43 | val walletVersion: String,
44 | val network: String? = null,
45 | val workchain: Int = 0,
46 | val walletId: Long,
47 | // Public key as hex string (for custom signers)
48 | val publicKey: String? = null,
49 | val isCustom: Boolean = false,
50 | )
51 |
52 | @Serializable
53 | internal data class AddWalletRequest(
54 | val adapterId: String,
55 | )
56 |
57 | @Serializable
58 | internal data class AddressRequest(
59 | val address: String,
60 | )
61 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/main/java/io/ton/walletkit/internal/constants/BrowserConstants.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.internal.constants
23 |
24 | /**
25 | * Constants for the internal browser and TonConnect bridge.
26 | */
27 | internal object BrowserConstants {
28 |
29 | // JavaScript Interface
30 | const val JS_INTERFACE_NAME = "AndroidTonConnect"
31 |
32 | // Message Types
33 | const val MESSAGE_TYPE_BRIDGE_REQUEST = "TONCONNECT_BRIDGE_REQUEST"
34 | const val MESSAGE_TYPE_BRIDGE_RESPONSE = "TONCONNECT_BRIDGE_RESPONSE"
35 | const val MESSAGE_TYPE_BRIDGE_EVENT = "TONCONNECT_BRIDGE_EVENT"
36 |
37 | // JSON Keys
38 | const val KEY_TYPE = "type"
39 | const val KEY_FRAME_ID = "frameId"
40 | const val KEY_MESSAGE_ID = "messageId"
41 | const val KEY_METHOD = "method"
42 | const val KEY_EVENT = "event"
43 | const val KEY_SUCCESS = "success"
44 | const val KEY_PAYLOAD = "payload"
45 | const val KEY_REQUEST = "request"
46 |
47 | // Default Values
48 | const val DEFAULT_FRAME_ID = "main"
49 | const val DEFAULT_METHOD = "unknown"
50 | const val EVENT_CONNECT = "connect"
51 |
52 | // Asset Paths
53 | const val INJECT_SCRIPT_PATH = "walletkit/inject.mjs"
54 | }
55 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/test/java/io/ton/walletkit/ModelTest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit
23 |
24 | import io.ton.walletkit.model.*
25 | import org.junit.Test
26 | import kotlin.test.assertEquals
27 | import kotlin.test.assertNull
28 |
29 | class ModelTest {
30 |
31 | @Test
32 | fun testWalletAccountHasRequiredFields() {
33 | val wallet = WalletAccount(
34 | address = "EQDexample",
35 | publicKey = "pubkey",
36 | name = "My Wallet",
37 | version = "v5r1",
38 | network = "mainnet",
39 | index = 0,
40 | )
41 | assertEquals("EQDexample", wallet.address)
42 | assertEquals("v5r1", wallet.version)
43 | }
44 |
45 | @Test
46 | fun testTransactionHasRequiredFields() {
47 | val tx = Transaction(
48 | hash = "hash123",
49 | timestamp = 1000L,
50 | amount = "100000000",
51 | type = TransactionType.INCOMING,
52 | )
53 | assertEquals("hash123", tx.hash)
54 | assertNull(tx.fee)
55 | }
56 |
57 | @Test
58 | fun testTONNetworkValues() {
59 | assertEquals("-239", TONNetwork.MAINNET.value)
60 | assertEquals("-3", TONNetwork.TESTNET.value)
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/Transaction.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | /**
25 | * Represents a blockchain transaction.
26 | *
27 | * @property hash Unique transaction hash
28 | * @property timestamp Transaction timestamp in milliseconds
29 | * @property amount Transaction amount in nanoTON
30 | * @property fee Transaction fee in nanoTON (nullable if not yet confirmed)
31 | * @property comment Optional comment/message attached to the transaction
32 | * @property sender Sender address (nullable for outgoing transactions)
33 | * @property recipient Recipient address (nullable for incoming transactions)
34 | * @property type Type of transaction (incoming, outgoing, or unknown)
35 | * @property lt Logical time - transaction ordering in the blockchain
36 | * @property blockSeqno Block sequence number where transaction was included
37 | */
38 | data class Transaction(
39 | val hash: String,
40 | val timestamp: Long,
41 | val amount: String,
42 | val fee: String? = null,
43 | val comment: String? = null,
44 | val sender: String? = null,
45 | val recipient: String? = null,
46 | val type: TransactionType = TransactionType.UNKNOWN,
47 | val lt: String? = null,
48 | val blockSeqno: Int? = null,
49 | )
50 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/main/java/io/ton/walletkit/internal/util/IDGenerator.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.internal.util
23 |
24 | import java.util.UUID
25 |
26 | /**
27 | * Unique identifier generation utilities for internal bridge operations.
28 | *
29 | * Provides cryptographically secure ID generation using UUID.
30 | * Replaces Date.now() + Math.random() pattern from JavaScript bridge.
31 | *
32 | * @suppress Internal utility for bridge operations.
33 | */
34 | internal object IDGenerator {
35 | /**
36 | * Generates a unique signer ID.
37 | *
38 | * @return Signer ID in format "signer_UUID"
39 | */
40 | fun generateSignerId(): String {
41 | return "signer_${UUID.randomUUID()}"
42 | }
43 |
44 | /**
45 | * Generates a unique adapter ID.
46 | *
47 | * @return Adapter ID in format "adapter_UUID"
48 | */
49 | fun generateAdapterId(): String {
50 | return "adapter_${UUID.randomUUID()}"
51 | }
52 |
53 | /**
54 | * Generates a unique ID with a custom prefix.
55 | *
56 | * @param prefix The prefix for the ID
57 | * @return ID in format "prefix_UUID"
58 | */
59 | fun generateId(prefix: String): String {
60 | return "${prefix}_${UUID.randomUUID()}"
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/TONNFTCollection.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | import kotlinx.serialization.Serializable
25 |
26 | /**
27 | * NFT collection information.
28 | *
29 | * @property address Collection contract address (user-friendly format: UQ... or EQ...)
30 | * @property codeHash Code hash of the collection contract (hex string with 0x prefix)
31 | * @property dataHash Data hash of the collection contract (hex string with 0x prefix)
32 | * @property lastTransactionLt Last transaction logical time
33 | * @property nextItemIndex Next item index in the collection
34 | * @property ownerAddress Collection owner address (user-friendly format)
35 | */
36 | @Serializable
37 | data class TONNFTCollection(
38 | /** Collection contract address (user-friendly format: UQ... or EQ...) */
39 | val address: String,
40 | /** Code hash of the collection contract (hex string with 0x prefix) */
41 | val codeHash: String? = null,
42 | /** Data hash of the collection contract (hex string with 0x prefix) */
43 | val dataHash: String? = null,
44 | val lastTransactionLt: String? = null,
45 | val nextItemIndex: String,
46 | /** Collection owner address (user-friendly format) */
47 | val ownerAddress: String? = null,
48 | )
49 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/presentation/ui/sections/EventLogSection.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.presentation.ui.sections
23 |
24 | import androidx.compose.foundation.layout.Arrangement
25 | import androidx.compose.foundation.layout.Column
26 | import androidx.compose.material3.HorizontalDivider
27 | import androidx.compose.material3.MaterialTheme
28 | import androidx.compose.material3.Text
29 | import androidx.compose.runtime.Composable
30 | import androidx.compose.ui.res.stringResource
31 | import androidx.compose.ui.tooling.preview.Preview
32 | import androidx.compose.ui.unit.dp
33 | import io.ton.walletkit.demo.R
34 |
35 | @Composable
36 | fun EventLogSection(events: List) {
37 | Column(verticalArrangement = Arrangement.spacedBy(EVENT_SECTION_SPACING)) {
38 | Text(stringResource(R.string.events_recent_title), style = MaterialTheme.typography.titleMedium)
39 | events.forEach { event ->
40 | HorizontalDivider()
41 | Text(event, style = MaterialTheme.typography.bodySmall)
42 | }
43 | }
44 | }
45 | private val EVENT_SECTION_SPACING = 8.dp
46 |
47 | @Preview(showBackground = true)
48 | @Composable
49 | private fun EventLogSectionPreview() {
50 | EventLogSection(events = listOf("Handled TON Connect URL", "Approved transaction"))
51 | }
52 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/WalletSession.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | /**
25 | * Represents an active TON Connect session between a wallet and a dApp.
26 | *
27 | * A session is established when a user connects their wallet to a decentralized application.
28 | * It persists across app restarts and allows the dApp to request transactions and signatures
29 | * without requiring the user to reconnect.
30 | *
31 | * @property sessionId Unique identifier for this session
32 | * @property dAppName Display name of the connected dApp
33 | * @property walletAddress The wallet address used for this session
34 | * @property dAppUrl Optional URL of the dApp's website
35 | * @property manifestUrl Optional URL to the dApp's TON Connect manifest
36 | * @property iconUrl Optional URL to the dApp's icon/logo
37 | * @property createdAtIso ISO 8601 timestamp when the session was created (nullable if unknown)
38 | * @property lastActivityIso ISO 8601 timestamp of the last activity on this session (nullable if unknown)
39 | */
40 | data class WalletSession(
41 | val sessionId: String,
42 | val dAppName: String,
43 | val walletAddress: String,
44 | val dAppUrl: String?,
45 | val manifestUrl: String?,
46 | val iconUrl: String?,
47 | val createdAtIso: String?,
48 | val lastActivityIso: String?,
49 | )
50 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/TONNetwork.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | import kotlinx.serialization.Serializable
25 |
26 | /**
27 | * TON blockchain network.
28 | *
29 | * Mirrors the shared TON Wallet Kit model for cross-platform consistency.
30 | *
31 | * @property value Network chain ID
32 | */
33 | @Serializable
34 | enum class TONNetwork(val value: String) {
35 | /** Mainnet (chain ID: -239) */
36 | MAINNET("-239"),
37 |
38 | /** Testnet (chain ID: -3) */
39 | TESTNET("-3"),
40 | ;
41 |
42 | companion object {
43 | private const val CHAIN_ID_MAINNET = "-239"
44 | private const val CHAIN_ID_TESTNET = "-3"
45 | private const val NAME_MAINNET = "mainnet"
46 | private const val NAME_TESTNET = "testnet"
47 |
48 | /**
49 | * Parse network from string value.
50 | * Accepts both chain IDs ("-239", "-3") and names ("mainnet", "testnet").
51 | *
52 | * @param value String representation of network
53 | * @return TONNetwork enum or null if invalid
54 | */
55 | fun fromString(value: String): TONNetwork? = when (value.lowercase()) {
56 | CHAIN_ID_MAINNET, NAME_MAINNET -> MAINNET
57 | CHAIN_ID_TESTNET, NAME_TESTNET -> TESTNET
58 | else -> null
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/presentation/state/SheetState.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.presentation.state
23 |
24 | import io.ton.walletkit.demo.presentation.model.ConnectRequestUi
25 | import io.ton.walletkit.demo.presentation.model.JettonDetails
26 | import io.ton.walletkit.demo.presentation.model.SignDataRequestUi
27 | import io.ton.walletkit.demo.presentation.model.TransactionDetailUi
28 | import io.ton.walletkit.demo.presentation.model.TransactionRequestUi
29 | import io.ton.walletkit.demo.presentation.model.WalletSummary
30 |
31 | sealed interface SheetState {
32 | data object None : SheetState
33 | data object AddWallet : SheetState
34 | data class Connect(val request: ConnectRequestUi) : SheetState
35 | data class Transaction(val request: TransactionRequestUi) : SheetState
36 | data class SignData(val request: SignDataRequestUi) : SheetState
37 | data class WalletDetails(val wallet: WalletSummary) : SheetState
38 | data class SendTransaction(val wallet: WalletSummary) : SheetState
39 | data class TransactionDetail(val transaction: TransactionDetailUi) : SheetState
40 | data class Browser(val url: String) : SheetState
41 | data class JettonDetails(val jetton: io.ton.walletkit.demo.presentation.model.JettonDetails) : SheetState
42 | data class TransferJetton(val jetton: io.ton.walletkit.demo.presentation.model.JettonDetails) : SheetState
43 | }
44 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | agp = "8.13.1"
3 | kotlin = "2.2.21"
4 | spotless = "8.0.0"
5 | mavenPublish = "0.35.0"
6 | androidxCoreKtx = "1.17.0"
7 | lifecycle = "2.9.4"
8 | coroutinesAndroid = "1.10.2"
9 | kotlinxSerialization = "1.9.0"
10 | webkit = "1.14.0"
11 | datastorePreferences = "1.1.7"
12 | securityCrypto = "1.1.0"
13 | okhttp = "5.3.1"
14 | junit = "4.13.2"
15 | androidxTestExt = "1.3.0"
16 | androidxTestRunner = "1.7.0"
17 | mockk = "1.14.6"
18 | androidxTestCore = "1.7.0"
19 | robolectric = "4.16"
20 | coroutinesTest = "1.10.2"
21 |
22 | [libraries]
23 | androidxCoreKtx = { module = "androidx.core:core-ktx", version.ref = "androidxCoreKtx" }
24 | androidxLifecycleRuntimeKtx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle" }
25 | kotlinxCoroutinesAndroid = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutinesAndroid" }
26 | kotlinxSerializationJson = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerialization" }
27 | androidxWebkit = { module = "androidx.webkit:webkit", version.ref = "webkit" }
28 | androidxDatastorePreferences = { module = "androidx.datastore:datastore-preferences", version.ref = "datastorePreferences" }
29 | androidxSecurityCrypto = { module = "androidx.security:security-crypto", version.ref = "securityCrypto" }
30 | okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
31 | junit = { module = "junit:junit", version.ref = "junit" }
32 | androidxTestExt = { module = "androidx.test.ext:junit", version.ref = "androidxTestExt" }
33 | androidxTestRunner = { module = "androidx.test:runner", version.ref = "androidxTestRunner" }
34 | mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
35 | androidxTestCore = { module = "androidx.test:core-ktx", version.ref = "androidxTestCore" }
36 | robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }
37 | shadowsFramework = { module = "org.robolectric:shadows-framework", version.ref = "robolectric" }
38 | kotlinxCoroutinesTest = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutinesTest" }
39 |
40 | [plugins]
41 | androidLibrary = { id = "com.android.library", version.ref = "agp" }
42 | kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
43 | kotlinSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
44 | spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
45 | mavenPublish = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublish" }
46 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/main/java/io/ton/walletkit/engine/operations/requests/TransactionRequests.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.engine.operations.requests
23 |
24 | import io.ton.walletkit.model.TONTransferParams
25 | import kotlinx.serialization.Serializable
26 |
27 | /**
28 | * Internal bridge request models for transaction operations.
29 | * These DTOs represent the exact JSON structure sent to the JavaScript bridge.
30 | *
31 | * @suppress Internal bridge communication only.
32 | */
33 |
34 | @Serializable
35 | internal data class CreateTransferTonRequest(
36 | val walletAddress: String,
37 | val toAddress: String,
38 | val amount: String,
39 | val comment: String? = null,
40 | val body: String? = null,
41 | val stateInit: String? = null,
42 | )
43 |
44 | @Serializable
45 | internal data class CreateTransferMultiTonRequest(
46 | val address: String,
47 | val messages: List,
48 | )
49 |
50 | @Serializable
51 | internal data class HandleNewTransactionRequest(
52 | val walletAddress: String,
53 | val transactionContent: String,
54 | )
55 |
56 | @Serializable
57 | internal data class SendTransactionRequest(
58 | val walletAddress: String,
59 | val transactionContent: String,
60 | )
61 |
62 | @Serializable
63 | internal data class GetTransactionPreviewRequest(
64 | val address: String,
65 | // JSON string
66 | val transactionContent: String,
67 | )
68 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/presentation/ui/components/CodeBlock.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.presentation.ui.components
23 |
24 | import androidx.compose.foundation.layout.fillMaxWidth
25 | import androidx.compose.foundation.layout.padding
26 | import androidx.compose.foundation.shape.RoundedCornerShape
27 | import androidx.compose.material3.MaterialTheme
28 | import androidx.compose.material3.Surface
29 | import androidx.compose.material3.Text
30 | import androidx.compose.runtime.Composable
31 | import androidx.compose.ui.Modifier
32 | import androidx.compose.ui.tooling.preview.Preview
33 | import androidx.compose.ui.unit.dp
34 |
35 | @Composable
36 | fun CodeBlock(content: String) {
37 | Surface(
38 | shape = RoundedCornerShape(CODE_BLOCK_CORNER_RADIUS),
39 | color = MaterialTheme.colorScheme.surfaceVariant,
40 | modifier = Modifier.fillMaxWidth(),
41 | ) {
42 | Text(
43 | text = content,
44 | modifier = Modifier.padding(CODE_BLOCK_PADDING),
45 | style = MaterialTheme.typography.bodySmall,
46 | color = MaterialTheme.colorScheme.onSurfaceVariant,
47 | )
48 | }
49 | }
50 |
51 | private val CODE_BLOCK_CORNER_RADIUS = 12.dp
52 | private val CODE_BLOCK_PADDING = 16.dp
53 |
54 | @Preview(showBackground = true)
55 | @Composable
56 | private fun CodeBlockPreview() {
57 | CodeBlock(content = "{\n \"message\": \"Hello\"\n}")
58 | }
59 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/WalletKitConstants.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit
23 |
24 | /**
25 | * Constants used throughout the WalletKit SDK.
26 | *
27 | * Matches the constants from the JavaScript @ton/walletkit library.
28 | */
29 | object WalletKitConstants {
30 | /**
31 | * Default wallet ID for V5R1 wallets.
32 | *
33 | * This value is used to make wallet addresses unique when creating multiple
34 | * wallets from the same mnemonic or private key. The wallet ID is part of
35 | * the smart contract initialization data.
36 | *
37 | * Corresponds to `defaultWalletIdV5R1` in @ton/walletkit.
38 | */
39 | const val DEFAULT_WALLET_ID_V5R1: Long = 2147483409L
40 |
41 | /**
42 | * Default wallet ID for V4R2 wallets.
43 | *
44 | * This value is used to make wallet addresses unique when creating multiple
45 | * wallets from the same mnemonic or private key. The wallet ID is part of
46 | * the smart contract initialization data.
47 | *
48 | * Corresponds to `defaultWalletIdV4R2` in @ton/walletkit.
49 | */
50 | const val DEFAULT_WALLET_ID_V4R2: Long = 698983191L
51 |
52 | /**
53 | * Default workchain for wallet contracts.
54 | *
55 | * - 0: Basechain (default, recommended for most use cases)
56 | * - -1: Masterchain (requires more fees, used for validators)
57 | */
58 | const val DEFAULT_WORKCHAIN: Int = 0
59 | }
60 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/TONNFTTransferParamsRaw.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | import kotlinx.serialization.Serializable
25 |
26 | /**
27 | * Low-level NFT transfer message.
28 | *
29 | * @property queryId Query ID for the transfer
30 | * @property newOwner New owner address
31 | * @property responseDestination Response destination address (for excess funds)
32 | * @property customPayload Custom payload (optional)
33 | * @property forwardAmount Amount to forward to the new owner
34 | * @property forwardPayload Forward payload (optional)
35 | */
36 | @Serializable
37 | data class TONNFTTransferMessageDTO(
38 | val queryId: String,
39 | val newOwner: String,
40 | val responseDestination: String? = null,
41 | val customPayload: String? = null,
42 | val forwardAmount: String,
43 | val forwardPayload: String? = null,
44 | )
45 |
46 | /**
47 | * Raw (advanced) NFT transfer parameters.
48 | *
49 | * Matches the shared TONNFTTransferParamsRaw structure for cross-platform consistency.
50 | *
51 | * @property nftAddress NFT contract address to transfer
52 | * @property transferAmount Amount of TON to attach to the transfer (for gas fees)
53 | * @property transferMessage Detailed transfer message with all parameters
54 | */
55 | @Serializable
56 | data class TONNFTTransferParamsRaw(
57 | val nftAddress: String,
58 | val transferAmount: String,
59 | val transferMessage: TONNFTTransferMessageDTO,
60 | )
61 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/main/java/io/ton/walletkit/internal/util/Logger.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.internal.util
23 |
24 | import android.util.Log
25 | import io.ton.walletkit.bridge.BuildConfig
26 |
27 | /**
28 | * Internal logger for TON WalletKit SDK.
29 | * Logs are automatically disabled in release builds.
30 | */
31 | internal object Logger {
32 |
33 | private val ENABLE_LOGGING = BuildConfig.LOG_LEVEL != "OFF"
34 |
35 | fun v(tag: String, message: String) {
36 | if (ENABLE_LOGGING) {
37 | Log.v(tag, message)
38 | }
39 | }
40 |
41 | fun d(tag: String, message: String) {
42 | if (ENABLE_LOGGING) {
43 | Log.d(tag, message)
44 | }
45 | }
46 |
47 | fun i(tag: String, message: String) {
48 | if (ENABLE_LOGGING) {
49 | Log.i(tag, message)
50 | }
51 | }
52 |
53 | fun w(tag: String, message: String) {
54 | if (ENABLE_LOGGING) {
55 | Log.w(tag, message)
56 | }
57 | }
58 |
59 | fun w(tag: String, message: String, throwable: Throwable) {
60 | if (ENABLE_LOGGING) {
61 | Log.w(tag, message, throwable)
62 | }
63 | }
64 |
65 | // Keep errors always - critical for debugging production issues
66 | fun e(tag: String, message: String) {
67 | Log.e(tag, message)
68 | }
69 |
70 | fun e(tag: String, message: String, throwable: Throwable) {
71 | Log.e(tag, message, throwable)
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/TONTransferParams.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | import kotlinx.serialization.Serializable
25 |
26 | /**
27 | * Parameters for creating a TON transfer transaction.
28 | *
29 | * Matches the TypeScript TonTransferParams interface from the JS WalletKit API:
30 | * ```typescript
31 | * type TonTransferParams = {
32 | * toAddress: string;
33 | * amount: string;
34 | * body?: string; // base64 BOC
35 | * comment?: string;
36 | * stateInit?: string; // base64 BOC
37 | * extraCurrency?: ConnectExtraCurrency;
38 | * mode?: SendMode;
39 | * }
40 | * ```
41 | *
42 | * @property toAddress Recipient address
43 | * @property amount Amount in nanoTON as a string
44 | * @property comment Optional comment/memo text (mutually exclusive with body)
45 | * @property body Optional raw cell payload as base64 BOC (mutually exclusive with comment)
46 | * @property stateInit Optional state init as base64 BOC
47 | */
48 | @Serializable
49 | data class TONTransferParams(
50 | val toAddress: String,
51 | val amount: String,
52 | val comment: String? = null,
53 | val body: String? = null,
54 | val stateInit: String? = null,
55 | ) {
56 | init {
57 | require(toAddress.isNotBlank()) { "toAddress cannot be blank" }
58 | require(amount.isNotBlank()) { "amount cannot be blank" }
59 | // Ensure only one of comment or body is set
60 | require(comment == null || body == null) {
61 | "Only one of 'comment' or 'body' can be specified, not both"
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/presentation/viewmodel/WalletSecurityController.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.presentation.viewmodel
23 |
24 | import io.ton.walletkit.demo.data.storage.DemoAppStorage
25 | import kotlinx.coroutines.flow.MutableStateFlow
26 | import kotlinx.coroutines.flow.StateFlow
27 | import kotlinx.coroutines.flow.asStateFlow
28 |
29 | /**
30 | * Handles password and unlock state, providing reactive signals for the UI layer.
31 | */
32 | class WalletSecurityController(
33 | private val storage: DemoAppStorage,
34 | ) {
35 |
36 | private val _isPasswordSet = MutableStateFlow(storage.isPasswordSet())
37 | val isPasswordSet: StateFlow = _isPasswordSet.asStateFlow()
38 |
39 | private val _isUnlocked = MutableStateFlow(storage.isUnlocked())
40 | val isUnlocked: StateFlow = _isUnlocked.asStateFlow()
41 |
42 | fun setPassword(password: String) {
43 | storage.setPassword(password)
44 | storage.setUnlocked(true)
45 | _isPasswordSet.value = true
46 | _isUnlocked.value = true
47 | }
48 |
49 | fun verifyPassword(password: String): Boolean {
50 | val verified = storage.verifyPassword(password)
51 | if (verified) {
52 | storage.setUnlocked(true)
53 | _isUnlocked.value = true
54 | }
55 | return verified
56 | }
57 |
58 | fun lock() {
59 | _isUnlocked.value = false
60 | storage.setUnlocked(false)
61 | }
62 |
63 | fun reset() {
64 | _isPasswordSet.value = false
65 | _isUnlocked.value = false
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/main/java/io/ton/walletkit/storage/BridgeStorageAdapter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.storage
23 |
24 | /**
25 | * Storage adapter interface for the WalletKit bridge to persist data between app restarts.
26 | * This enables the JavaScript bundle to use Android secure storage instead of ephemeral
27 | * WebView LocalStorage or memory storage.
28 | *
29 | * The bridge calls these methods via JavascriptInterface to persist:
30 | * - Wallet metadata (addresses, public keys, versions)
31 | * - Session data (session IDs, dApp info, private keys)
32 | * - User preferences (active wallet, network settings)
33 | *
34 | * Implementations should use secure storage (e.g., EncryptedSharedPreferences) for
35 | * sensitive data like session private keys.
36 | *
37 | * @suppress This is an internal interface. Partners should not implement or use this directly.
38 | */
39 | internal interface BridgeStorageAdapter {
40 | /**
41 | * Get a value from storage by key.
42 | * @param key The storage key
43 | * @return The stored value as a JSON string, or null if not found
44 | */
45 | suspend fun get(key: String): String?
46 |
47 | /**
48 | * Set a value in storage.
49 | * @param key The storage key
50 | * @param value The value to store as a JSON string
51 | */
52 | suspend fun set(key: String, value: String)
53 |
54 | /**
55 | * Remove a value from storage.
56 | * @param key The storage key to remove
57 | */
58 | suspend fun remove(key: String)
59 |
60 | /**
61 | * Clear all storage data.
62 | */
63 | suspend fun clear()
64 | }
65 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/presentation/state/WalletUiState.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.presentation.state
23 |
24 | import io.ton.walletkit.demo.presentation.model.JettonSummary
25 | import io.ton.walletkit.demo.presentation.model.SessionSummary
26 | import io.ton.walletkit.demo.presentation.model.SignDataRequestUi
27 | import io.ton.walletkit.demo.presentation.model.WalletSummary
28 |
29 | data class WalletUiState(
30 | val initialized: Boolean = false,
31 | val status: String = "",
32 | val wallets: List = emptyList(),
33 | val activeWalletAddress: String? = null,
34 | val sessions: List = emptyList(),
35 | val sheetState: SheetState = SheetState.None,
36 | val previousSheet: SheetState? = null, // Used to restore sheet after modal interactions
37 | val isUrlPromptVisible: Boolean = false,
38 | val isWalletSwitcherExpanded: Boolean = false,
39 | val isLoadingWallets: Boolean = false,
40 | val isLoadingSessions: Boolean = false,
41 | val isLoadingTransactions: Boolean = false,
42 | val isSendingTransaction: Boolean = false,
43 | val isGeneratingMnemonic: Boolean = false,
44 | val error: String? = null,
45 | val events: List = emptyList(),
46 | val lastUpdated: Long? = null,
47 | val clipboardContent: String? = null,
48 | val pendingSignerConfirmation: SignDataRequestUi? = null, // Request awaiting signer confirmation
49 | val jettons: List = emptyList(),
50 | val isLoadingJettons: Boolean = false,
51 | val jettonsError: String? = null,
52 | val canLoadMoreJettons: Boolean = false,
53 | )
54 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/request/TONWalletConnectionRequest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.request
23 |
24 | import io.ton.walletkit.event.ConnectRequestEvent
25 | import io.ton.walletkit.model.DAppInfo
26 |
27 | /**
28 | * Represents a connection request from a dApp.
29 | *
30 | * Aligns with the shared TON Wallet Kit API contract for cross-platform consistency.
31 | *
32 | * Handle this request by calling [approve] with a wallet address
33 | * or [reject] to deny the connection.
34 | *
35 | * @property dAppInfo Information about the requesting dApp
36 | * @property permissions List of requested permissions
37 | */
38 | class TONWalletConnectionRequest(
39 | val dAppInfo: DAppInfo?,
40 | val permissions: List,
41 | private val event: ConnectRequestEvent,
42 | private val handler: RequestHandler,
43 | ) {
44 | /**
45 | * Approve this connection request with the specified wallet.
46 | *
47 | * @param walletAddress Address of the wallet to connect with
48 | * @throws io.ton.walletkit.WalletKitBridgeException if approval fails
49 | */
50 | suspend fun approve(walletAddress: String) {
51 | val eventWithWallet = event.copy(walletAddress = walletAddress)
52 | handler.approveConnect(eventWithWallet)
53 | }
54 |
55 | /**
56 | * Reject this connection request.
57 | *
58 | * @param reason Optional reason for rejection
59 | * @throws io.ton.walletkit.WalletKitBridgeException if rejection fails
60 | */
61 | suspend fun reject(reason: String? = null) {
62 | handler.rejectConnect(event, reason)
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/TONJetton.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | import kotlinx.serialization.SerialName
25 | import kotlinx.serialization.Serializable
26 | import kotlinx.serialization.json.JsonElement
27 |
28 | /**
29 | * Jetton (fungible token) information.
30 | *
31 | * Represents the metadata and configuration of a Jetton master contract.
32 | *
33 | * @property address Jetton master contract address (user-friendly format: UQ... or EQ...)
34 | * @property name Jetton name (e.g., "Tether USD")
35 | * @property symbol Jetton symbol (e.g., "USDT")
36 | * @property description Jetton description
37 | * @property decimals Number of decimal places (typically 9)
38 | * @property totalSupply Total supply of the jetton
39 | * @property image URL to jetton image/logo
40 | * @property imageData Base64-encoded image data
41 | * @property uri URI to jetton metadata
42 | * @property verification Verification status
43 | * @property metadata Additional metadata as key-value pairs
44 | */
45 | @Serializable
46 | data class TONJetton(
47 | /** Jetton master contract address (user-friendly format: UQ... or EQ...) */
48 | val address: String? = null,
49 | val name: String? = null,
50 | val symbol: String? = null,
51 | val description: String? = null,
52 | val decimals: Int? = null,
53 | @SerialName("total_supply")
54 | val totalSupply: String? = null,
55 | val image: String? = null,
56 | @SerialName("image_data")
57 | val imageData: String? = null,
58 | val uri: String? = null,
59 | val verification: TONJettonVerification? = null,
60 | val metadata: Map? = null,
61 | )
62 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/listener/TONBridgeEventsHandler.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.listener
23 |
24 | import io.ton.walletkit.event.TONWalletKitEvent
25 |
26 | /**
27 | * Handler for TON Wallet Kit events.
28 | *
29 | * Mirrors the canonical TON Wallet Kit protocol for cross-platform consistency.
30 | *
31 | * Implement this interface to receive events from the wallet kit
32 | * such as connection requests, transaction requests, and sign data requests.
33 | *
34 | * Example:
35 | * ```kotlin
36 | * class MyEventsHandler : TONBridgeEventsHandler {
37 | * override fun handle(event: TONWalletKitEvent) {
38 | * when (event) {
39 | * is TONWalletKitEvent.ConnectRequest -> {
40 | * // Handle connection request
41 | * event.request.approve(walletAddress)
42 | * }
43 | * is TONWalletKitEvent.TransactionRequest -> {
44 | * // Handle transaction request
45 | * event.request.approve()
46 | * }
47 | * is TONWalletKitEvent.SignDataRequest -> {
48 | * // Handle sign data request
49 | * event.request.approve()
50 | * }
51 | * is TONWalletKitEvent.Disconnect -> {
52 | * // Handle disconnect
53 | * }
54 | * }
55 | * }
56 | * }
57 | * ```
58 | */
59 | interface TONBridgeEventsHandler {
60 | /**
61 | * Handle a wallet kit event.
62 | *
63 | * Use when() expression for exhaustive handling of all event types.
64 | *
65 | * @param event The event to handle
66 | */
67 | fun handle(event: TONWalletKitEvent)
68 | }
69 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/main/java/io/ton/walletkit/internal/constants/NetworkConstants.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.internal.constants
23 |
24 | /**
25 | * Constants for TON network configuration and endpoints.
26 | *
27 | * These constants define the available networks and their default API endpoints
28 | * used throughout the SDK.
29 | *
30 | * @suppress Internal implementation constants. Not part of public API.
31 | */
32 | internal object NetworkConstants {
33 | /**
34 | * Mainnet network identifier.
35 | */
36 | const val NETWORK_MAINNET = "mainnet"
37 |
38 | /**
39 | * Testnet network identifier (default for development).
40 | */
41 | const val NETWORK_TESTNET = "testnet"
42 |
43 | /**
44 | * Default network used by the SDK.
45 | */
46 | const val DEFAULT_NETWORK = NETWORK_TESTNET
47 |
48 | /**
49 | * Default TON API URL for testnet.
50 | */
51 | const val DEFAULT_TESTNET_API_URL = "https://testnet.tonapi.io"
52 |
53 | /**
54 | * Default TON API URL for mainnet.
55 | */
56 | const val DEFAULT_MAINNET_API_URL = "https://tonapi.io"
57 |
58 | /**
59 | * Default wallet image URL.
60 | */
61 | const val DEFAULT_WALLET_IMAGE_URL = "https://wallet.ton.org/assets/ui/qr-logo.png"
62 |
63 | /**
64 | * Default wallet about URL.
65 | */
66 | const val DEFAULT_WALLET_ABOUT_URL = "https://wallet.ton.org"
67 |
68 | /**
69 | * Default app version when unable to retrieve from package manager.
70 | */
71 | const val DEFAULT_APP_VERSION = "1.0.0"
72 |
73 | /**
74 | * Maximum protocol version supported by the SDK.
75 | */
76 | const val MAX_PROTOCOL_VERSION = 2
77 | }
78 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/presentation/viewmodel/WalletEventLogger.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.presentation.viewmodel
23 |
24 | import androidx.annotation.StringRes
25 | import io.ton.walletkit.demo.presentation.state.WalletUiState
26 | import kotlinx.coroutines.CoroutineScope
27 | import kotlinx.coroutines.delay
28 | import kotlinx.coroutines.flow.MutableStateFlow
29 | import kotlinx.coroutines.flow.update
30 | import kotlinx.coroutines.launch
31 |
32 | /**
33 | * Maintains the rolling event log and temporary status messages.
34 | */
35 | class WalletEventLogger(
36 | private val state: MutableStateFlow,
37 | private val scope: CoroutineScope,
38 | private val maxEvents: Int,
39 | private val hideDelayMillis: Long,
40 | private val defaultStatusProvider: () -> String,
41 | private val stringProvider: (Int, Array) -> String,
42 | ) {
43 |
44 | fun log(@StringRes resId: Int, vararg args: Any) {
45 | log(stringProvider(resId, args))
46 | }
47 |
48 | fun log(message: String) {
49 | state.update {
50 | val events = listOf(message) + it.events
51 | it.copy(events = events.take(maxEvents))
52 | }
53 | }
54 |
55 | fun showTemporaryStatus(message: String) {
56 | state.update { it.copy(status = message, error = null) }
57 | scope.launch {
58 | delay(hideDelayMillis)
59 | state.update { current ->
60 | if (current.status == message) {
61 | current.copy(status = defaultStatusProvider())
62 | } else {
63 | current
64 | }
65 | }
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/di/AppModule.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.di
23 |
24 | import android.app.Application
25 | import android.content.Context
26 | import dagger.Module
27 | import dagger.Provides
28 | import dagger.hilt.InstallIn
29 | import dagger.hilt.android.qualifiers.ApplicationContext
30 | import dagger.hilt.components.SingletonComponent
31 | import io.ton.walletkit.demo.core.WalletKitDemoApp
32 | import io.ton.walletkit.demo.data.storage.DemoAppStorage
33 | import io.ton.walletkit.demo.data.storage.SecureDemoAppStorage
34 | import io.ton.walletkit.event.TONWalletKitEvent
35 | import kotlinx.coroutines.flow.SharedFlow
36 | import javax.inject.Singleton
37 |
38 | /**
39 | * Hilt module providing app-level dependencies.
40 | */
41 | @Module
42 | @InstallIn(SingletonComponent::class)
43 | object AppModule {
44 |
45 | @Provides
46 | @Singleton
47 | fun provideApplication(
48 | @ApplicationContext context: Context,
49 | ): Application = context.applicationContext as Application
50 |
51 | @Provides
52 | @Singleton
53 | fun provideWalletKitDemoApp(
54 | @ApplicationContext context: Context,
55 | ): WalletKitDemoApp = context.applicationContext as WalletKitDemoApp
56 |
57 | @Provides
58 | @Singleton
59 | fun provideDemoAppStorage(
60 | @ApplicationContext context: Context,
61 | ): DemoAppStorage = SecureDemoAppStorage(context)
62 |
63 | @Provides
64 | @Singleton
65 | fun provideSdkEvents(app: WalletKitDemoApp): @JvmSuppressWildcards SharedFlow = app.sdkEvents
66 |
67 | @Provides
68 | @Singleton
69 | fun provideSdkInitialized(app: WalletKitDemoApp): @JvmSuppressWildcards SharedFlow = app.sdkInitialized
70 | }
71 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/main/java/io/ton/walletkit/core/WalletKitEngineKind.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.core
23 |
24 | /**
25 | * Identifies which JavaScript runtime engine implementation is being used by the SDK.
26 | *
27 | * Internal implementation detail. SDK always uses WebView engine.
28 | *
29 | * @suppress
30 | */
31 | internal enum class WalletKitEngineKind {
32 | /**
33 | * WebView-based JavaScript engine (recommended for all use cases).
34 | *
35 | * This engine uses Android's WebView component to execute the WalletKit
36 | * JavaScript bundle. It provides:
37 | * - 2x faster performance compared to QuickJS
38 | * - Active maintenance and updates
39 | * - Production-ready stability
40 | * - Available in all SDK variants (webview-only and full)
41 | */
42 | WEBVIEW,
43 |
44 | /**
45 | * QuickJS-based JavaScript engine (deprecated).
46 | *
47 | * This engine uses a native QuickJS runtime compiled for Android.
48 | * **Note:** This option is deprecated and should not be used for new projects.
49 | *
50 | * Limitations:
51 | * - 2x slower than WebView
52 | * - No longer actively maintained
53 | * - Only available in the 'full' SDK variant
54 | * - Larger AAR size due to native libraries
55 | *
56 | * @deprecated QuickJS is deprecated due to performance and maintenance concerns.
57 | * Use [WEBVIEW] instead. See QUICKJS_DEPRECATION.md for migration guide.
58 | */
59 | @Deprecated(
60 | message = "QuickJS is deprecated. Use WEBVIEW instead for 2x better performance.",
61 | replaceWith = ReplaceWith("WalletKitEngineKind.WEBVIEW"),
62 | level = DeprecationLevel.WARNING,
63 | )
64 | QUICKJS,
65 | }
66 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/presentation/ui/components/NetworkBadge.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.presentation.ui.components
23 |
24 | import androidx.compose.foundation.layout.padding
25 | import androidx.compose.material3.MaterialTheme
26 | import androidx.compose.material3.Surface
27 | import androidx.compose.material3.Text
28 | import androidx.compose.runtime.Composable
29 | import androidx.compose.ui.Modifier
30 | import androidx.compose.ui.graphics.Color
31 | import androidx.compose.ui.res.stringResource
32 | import androidx.compose.ui.tooling.preview.Preview
33 | import androidx.compose.ui.unit.dp
34 | import io.ton.walletkit.demo.R
35 | import io.ton.walletkit.model.TONNetwork
36 |
37 | @Composable
38 | fun NetworkBadge(network: TONNetwork) {
39 | val color = when (network) {
40 | TONNetwork.MAINNET -> MAINNET_COLOR
41 | TONNetwork.TESTNET -> TESTNET_COLOR
42 | }
43 | val label = when (network) {
44 | TONNetwork.MAINNET -> stringResource(R.string.network_mainnet)
45 | TONNetwork.TESTNET -> stringResource(R.string.network_testnet)
46 | }
47 | Surface(shape = MaterialTheme.shapes.medium, color = color.copy(alpha = 0.12f)) {
48 | Text(
49 | text = label,
50 | modifier = Modifier.padding(horizontal = BADGE_HORIZONTAL_PADDING, vertical = BADGE_VERTICAL_PADDING),
51 | color = color,
52 | style = MaterialTheme.typography.labelMedium,
53 | )
54 | }
55 | }
56 |
57 | private val BADGE_HORIZONTAL_PADDING = 10.dp
58 | private val BADGE_VERTICAL_PADDING = 4.dp
59 | private val MAINNET_COLOR = Color(0xFF2E7D32)
60 | private val TESTNET_COLOR = Color(0xFFF57C00)
61 |
62 | @Preview
63 | @Composable
64 | private fun NetworkBadgePreview() {
65 | NetworkBadge(network = TONNetwork.MAINNET)
66 | }
67 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # ============================================================
2 | # TON WalletKit Android SDK - Library Development ProGuard Rules
3 | # These rules are used during library module builds (debug/release)
4 | # For consumer apps, see consumer-rules.pro
5 | # ============================================================
6 |
7 | # Add project specific ProGuard rules here.
8 | # By default, the flags in this file are appended to flags specified
9 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
10 | # You can edit the include path and order by changing the proguardFiles
11 | # directive in build.gradle.kts.
12 |
13 | # For more details, see:
14 | # http://developer.android.com/guide/developing/tools/proguard.html
15 |
16 | # ------------------------------------------------------------
17 | # Development Rules
18 | # ------------------------------------------------------------
19 |
20 | # Keep source file names and line numbers for debugging during development
21 | -keepattributes SourceFile,LineNumberTable
22 |
23 | # Don't obfuscate during library development for easier debugging
24 | # (Only applies to library module builds, not consumer apps)
25 | -dontobfuscate
26 |
27 | # Keep all implementation classes readable during development
28 | -keep class io.ton.walletkit.bridge.** { *; }
29 |
30 | # If you want to enable obfuscation during library builds, comment out
31 | # the -dontobfuscate line above and the -keep rule, then uncomment below:
32 | #
33 | # -keepattributes *Annotation*,Signature,InnerClasses,EnclosingMethod
34 | #
35 | # -keepclassmembers class * {
36 | # @android.webkit.JavascriptInterface ;
37 | # }
38 | #
39 | # -keepclasseswithmembernames class ** {
40 | # native ;
41 | # }
42 |
43 | # ------------------------------------------------------------
44 | # Remove Logging in Release Builds
45 | # ------------------------------------------------------------
46 |
47 | # Remove all Log.v (VERBOSE) calls
48 | -assumenosideeffects class android.util.Log {
49 | public static *** v(...);
50 | }
51 |
52 | # Remove all Log.d (DEBUG) calls
53 | -assumenosideeffects class android.util.Log {
54 | public static *** d(...);
55 | }
56 |
57 | # Remove all Log.i (INFO) calls
58 | -assumenosideeffects class android.util.Log {
59 | public static *** i(...);
60 | }
61 |
62 | # Keep Log.w (WARNING) and Log.e (ERROR) for important messages
63 | # Uncomment below to also remove warnings and errors:
64 | # -assumenosideeffects class android.util.Log {
65 | # public static *** w(...);
66 | # public static *** e(...);
67 | # }
68 |
69 | # Remove println statements
70 | -assumenosideeffects class java.io.PrintStream {
71 | public void println(%);
72 | public void println(**);
73 | }
74 |
75 | # Remove System.out and System.err print statements
76 | -assumenosideeffects class java.lang.System {
77 | public static java.io.PrintStream out;
78 | public static java.io.PrintStream err;
79 | }
80 |
81 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/main/java/io/ton/walletkit/internal/util/JsonUtils.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.internal.util
23 |
24 | import io.ton.walletkit.WalletKitBridgeException
25 | import org.json.JSONArray
26 | import org.json.JSONObject
27 |
28 | /**
29 | * Utility functions for JSON processing in the bridge layer.
30 | *
31 | * @suppress Internal utilities for bridge operations.
32 | */
33 | internal object JsonUtils {
34 |
35 | /**
36 | * Convert JavaScript Uint8Array (serialized as either JSONArray or JSONObject with indexed keys)
37 | * to ByteArray.
38 | *
39 | * JavaScript Uint8Arrays can be serialized as:
40 | * - JSONArray: [167, 80, 160, ...]
41 | * - JSONObject with numeric keys: {"0": 167, "1": 80, "2": 160, ...}
42 | *
43 | * This function handles both formats.
44 | *
45 | * @param json The JSON data to convert (JSONArray or JSONObject)
46 | * @param fieldName Name of the field being converted (for error messages)
47 | * @return ByteArray containing the data
48 | * @throws WalletKitBridgeException if the format is invalid
49 | */
50 | fun jsonToByteArray(json: Any?, fieldName: String): ByteArray {
51 | return when (json) {
52 | is JSONArray -> {
53 | // Standard array format: [167, 80, 160, ...]
54 | ByteArray(json.length()) { i -> json.optInt(i).toByte() }
55 | }
56 | is JSONObject -> {
57 | // Object with indexed keys: {"0": 167, "1": 80, ...}
58 | val length = json.length()
59 | ByteArray(length) { i ->
60 | json.optInt(i.toString(), 0).toByte()
61 | }
62 | }
63 | else -> throw WalletKitBridgeException("Invalid $fieldName format in response: expected array or object")
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/AndroidDemo/app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2 |
3 | plugins {
4 | alias(libs.plugins.androidApplication)
5 | alias(libs.plugins.kotlinAndroid)
6 | alias(libs.plugins.kotlinCompose)
7 | alias(libs.plugins.ksp)
8 | alias(libs.plugins.hiltAndroid)
9 | }
10 |
11 | android {
12 | namespace = "io.ton.walletkit.demo"
13 | compileSdk = 36
14 |
15 | defaultConfig {
16 | applicationId = "io.ton.walletkit.demo"
17 | minSdk = 24
18 | targetSdk = 36
19 | versionCode = 1
20 | versionName = "1.0"
21 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
22 | }
23 |
24 | buildTypes {
25 | release {
26 | isMinifyEnabled = false
27 | proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
28 | }
29 | }
30 |
31 | compileOptions {
32 | sourceCompatibility = JavaVersion.VERSION_17
33 | targetCompatibility = JavaVersion.VERSION_17
34 | }
35 | buildFeatures {
36 | compose = true
37 | }
38 | }
39 |
40 | kotlin {
41 | compilerOptions {
42 | jvmTarget.set(JvmTarget.JVM_17)
43 | }
44 | }
45 |
46 | dependencies {
47 | implementation(libs.androidxCoreKtx)
48 | implementation(libs.androidxAppcompat)
49 | implementation(libs.googleMaterial)
50 | implementation(libs.androidxActivityKtx)
51 | implementation(libs.androidxConstraintLayout)
52 | implementation(libs.androidxActivityCompose)
53 | implementation(platform(libs.androidxComposeBom))
54 | implementation(libs.androidxComposeUi)
55 | implementation(libs.androidxComposeMaterial3)
56 | implementation(libs.androidxComposeMaterialIconsExtended)
57 | implementation(libs.androidxComposeUiToolingPreview)
58 | debugImplementation(libs.androidxComposeUiTooling)
59 | implementation(libs.androidxLifecycleRuntimeKtx)
60 | implementation(libs.androidxLifecycleViewmodelCompose)
61 | implementation(libs.kotlinxCoroutinesAndroid)
62 | implementation(libs.androidxSecurityCrypto)
63 | implementation(libs.coilCompose)
64 | implementation(libs.coilNetwork)
65 |
66 | // Hilt dependency injection
67 | implementation(libs.hiltAndroid)
68 | ksp(libs.hiltCompiler)
69 |
70 | // TONWalletKit SDK - Use local AAR file
71 | // Build and copy with: cd ../TONWalletKit-Android && ./gradlew buildAndCopyWebviewToDemo
72 | implementation(files("libs/tonwalletkit-release.aar"))
73 | // Required transitive dependencies when using AAR:
74 | implementation(libs.androidxWebkit)
75 | implementation(libs.androidxDatastorePreferences)
76 | implementation(libs.kotlinxSerializationJson)
77 |
78 | // Alternative: Use Maven Local for testing published artifact (currently not working - Gradle ignores mavenLocal())
79 | // Publish to local maven with: cd ../TONWalletKit-Android && ./gradlew publishToMavenLocal
80 | // implementation("io.github.ton-connect:tonwalletkit-android:1.0.0-alpha01")
81 |
82 | debugImplementation(libs.leakcanaryAndroid)
83 | }
84 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/main/java/io/ton/walletkit/internal/constants/LogConstants.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.internal.constants
23 |
24 | /**
25 | * Constants for logging tags used throughout the SDK.
26 | *
27 | * These constants provide consistent logging tags for different components,
28 | * making it easier to filter and search logs during development and debugging.
29 | *
30 | * @suppress Internal implementation constants. Not part of public API.
31 | */
32 | internal object LogConstants {
33 | /**
34 | * Log tag for SecureWalletKitStorage class.
35 | */
36 | const val TAG_SECURE_STORAGE = "SecureWalletKitStorage"
37 |
38 | /**
39 | * Log tag for SecureBridgeStorageAdapter class.
40 | */
41 | const val TAG_BRIDGE_STORAGE = "SecureBridgeStorageAdapter"
42 |
43 | /**
44 | * Log tag for WebViewWalletKitEngine class.
45 | */
46 | const val TAG_WEBVIEW_ENGINE = "WebViewWalletKitEngine"
47 |
48 | // Log messages
49 | /**
50 | * Log message prefix for malformed payload from JavaScript.
51 | */
52 | const val MSG_MALFORMED_PAYLOAD = "Malformed payload from JS"
53 |
54 | /**
55 | * Error message prefix for malformed payloads.
56 | */
57 | const val ERROR_MALFORMED_PAYLOAD_PREFIX = "Malformed payload: "
58 |
59 | /**
60 | * Log message prefix for storage get failures.
61 | */
62 | const val MSG_STORAGE_GET_FAILED = "Storage get failed for key: "
63 |
64 | /**
65 | * Log message prefix for storage set failures.
66 | */
67 | const val MSG_STORAGE_SET_FAILED = "Storage set failed for key: "
68 |
69 | /**
70 | * Log message prefix for storage remove failures.
71 | */
72 | const val MSG_STORAGE_REMOVE_FAILED = "Storage remove failed for key: "
73 |
74 | /**
75 | * Log message for storage clear failures.
76 | */
77 | const val MSG_STORAGE_CLEAR_FAILED = "Storage clear failed"
78 | }
79 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/main/java/io/ton/walletkit/internal/constants/ReflectionConstants.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.internal.constants
23 |
24 | /**
25 | * Constants for reflection-based class loading.
26 | *
27 | * These constants define fully qualified class names used for reflective
28 | * instantiation of engine implementations, particularly for QuickJS support
29 | * in the full variant.
30 | *
31 | * @suppress Internal implementation constants. Not part of public API.
32 | */
33 | internal object ReflectionConstants {
34 | /**
35 | * Fully qualified class name for QuickJsWalletKitEngine.
36 | *
37 | * Used for reflection-based loading in full variant AAR.
38 | */
39 | const val CLASS_QUICKJS_ENGINE = "io.ton.walletkit.presentation.impl.QuickJsWalletKitEngine"
40 |
41 | /**
42 | * Fully qualified class name for OkHttpClient.
43 | *
44 | * Used for reflection-based constructor parameter type matching.
45 | */
46 | const val CLASS_OKHTTP_CLIENT = "okhttp3.OkHttpClient"
47 |
48 | /**
49 | * Fully qualified class name for TONWalletKitConfiguration.
50 | *
51 | * Used for reflection-based constructor parameter type matching.
52 | */
53 | const val CLASS_TON_WALLET_KIT_CONFIGURATION = "io.ton.walletkit.config.TONWalletKitConfiguration"
54 |
55 | /**
56 | * Fully qualified class name for TONBridgeEventsHandler.
57 | *
58 | * Used for reflection-based constructor parameter type matching.
59 | */
60 | const val CLASS_TON_BRIDGE_EVENTS_HANDLER = "io.ton.walletkit.presentation.listener.TONBridgeEventsHandler"
61 |
62 | /**
63 | * Error message when QuickJS engine is not available.
64 | */
65 | const val ERROR_QUICKJS_NOT_AVAILABLE =
66 | "QuickJS engine is not available in this SDK variant. " +
67 | "Use the 'full' variant AAR to access QuickJS, or use WalletKitEngineKind.WEBVIEW instead."
68 | }
69 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/internal/TONWalletKitFactory.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.internal
23 |
24 | import android.content.Context
25 | import io.ton.walletkit.ITONWalletKit
26 | import io.ton.walletkit.config.TONWalletKitConfiguration
27 | import kotlinx.coroutines.suspendCancellableCoroutine
28 |
29 | /**
30 | * Internal factory for creating ITONWalletKit instances.
31 | * Uses reflection to load the implementation without compile-time dependency.
32 | *
33 | * @hide This is internal implementation detail and should not be used directly.
34 | */
35 | @PublishedApi
36 | internal object TONWalletKitFactory {
37 | @Suppress("UNCHECKED_CAST")
38 | suspend fun create(
39 | context: Context,
40 | config: TONWalletKitConfiguration,
41 | ): ITONWalletKit {
42 | // Load the implementation class via reflection to avoid compile-time dependency
43 | val implClass = Class.forName("io.ton.walletkit.core.TONWalletKit")
44 |
45 | // Get the Companion object
46 | val companionField = implClass.getDeclaredField("Companion")
47 | companionField.isAccessible = true
48 | val companion = companionField.get(null)
49 |
50 | // Get the initialize method from the Companion class
51 | val companionClass = companion.javaClass
52 | val method = companionClass.getDeclaredMethod(
53 | "initialize",
54 | Context::class.java,
55 | TONWalletKitConfiguration::class.java,
56 | kotlin.coroutines.Continuation::class.java,
57 | )
58 | method.isAccessible = true
59 |
60 | // Call as suspend function
61 | return suspendCancellableCoroutine { continuation ->
62 | try {
63 | method.invoke(companion, context, config, continuation)
64 | } catch (e: Exception) {
65 | continuation.resumeWith(Result.failure(e))
66 | }
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/AndroidDemo/app/src/main/java/io/ton/walletkit/demo/presentation/ui/dialog/UrlPromptDialog.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.demo.presentation.ui.dialog
23 |
24 | import androidx.compose.material3.AlertDialog
25 | import androidx.compose.material3.Button
26 | import androidx.compose.material3.Text
27 | import androidx.compose.material3.TextButton
28 | import androidx.compose.material3.TextField
29 | import androidx.compose.runtime.Composable
30 | import androidx.compose.runtime.getValue
31 | import androidx.compose.runtime.mutableStateOf
32 | import androidx.compose.runtime.saveable.rememberSaveable
33 | import androidx.compose.runtime.setValue
34 | import androidx.compose.ui.res.stringResource
35 | import androidx.compose.ui.tooling.preview.Preview
36 | import io.ton.walletkit.demo.R
37 |
38 | @Composable
39 | fun UrlPromptDialog(onDismiss: () -> Unit, onConfirm: (String) -> Unit) {
40 | var url by rememberSaveable { mutableStateOf("") }
41 |
42 | AlertDialog(
43 | onDismissRequest = onDismiss,
44 | confirmButton = {
45 | Button(
46 | onClick = {
47 | onConfirm(url)
48 | url = ""
49 | },
50 | enabled = url.isNotBlank(),
51 | ) { Text(stringResource(R.string.action_handle_url)) }
52 | },
53 | dismissButton = { TextButton(onClick = onDismiss) { Text(stringResource(R.string.action_cancel)) } },
54 | title = { Text(stringResource(R.string.url_prompt_title)) },
55 | text = {
56 | TextField(
57 | value = url,
58 | onValueChange = { url = it },
59 | placeholder = { Text(stringResource(R.string.url_prompt_placeholder)) },
60 | singleLine = true,
61 | )
62 | },
63 | )
64 | }
65 |
66 | @Preview(showBackground = true)
67 | @Composable
68 | private fun UrlPromptDialogPreview() {
69 | UrlPromptDialog(onDismiss = {}, onConfirm = {})
70 | }
71 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/main/java/io/ton/walletkit/engine/operations/requests/AssetRequests.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.engine.operations.requests
23 |
24 | import kotlinx.serialization.Serializable
25 |
26 | /**
27 | * Internal bridge request models for asset operations (NFTs and Jettons).
28 | * These DTOs represent the exact JSON structure sent to the JavaScript bridge.
29 | *
30 | * @suppress Internal bridge communication only.
31 | */
32 |
33 | @Serializable
34 | internal data class GetNftsRequest(
35 | val address: String,
36 | val limit: Int,
37 | val offset: Int,
38 | )
39 |
40 | @Serializable
41 | internal data class GetNftRequest(
42 | val address: String,
43 | )
44 |
45 | @Serializable
46 | internal data class CreateTransferNftRequest(
47 | val address: String,
48 | val nftAddress: String,
49 | val transferAmount: String,
50 | val toAddress: String,
51 | val comment: String? = null,
52 | )
53 |
54 | @Serializable
55 | internal data class CreateTransferNftRawRequest(
56 | val address: String,
57 | val nftAddress: String,
58 | val transferAmount: String,
59 | val transferMessage: TONNFTTransferMessageDTO,
60 | )
61 |
62 | // Re-use public model
63 | typealias TONNFTTransferMessageDTO = io.ton.walletkit.model.TONNFTTransferMessageDTO
64 |
65 | @Serializable
66 | internal data class GetJettonsRequest(
67 | val address: String,
68 | val limit: Int,
69 | val offset: Int,
70 | )
71 |
72 | @Serializable
73 | internal data class CreateTransferJettonRequest(
74 | val address: String,
75 | val toAddress: String,
76 | val jettonAddress: String,
77 | val amount: String,
78 | val comment: String? = null,
79 | )
80 |
81 | @Serializable
82 | internal data class GetJettonBalanceRequest(
83 | val address: String,
84 | val jettonAddress: String,
85 | )
86 |
87 | @Serializable
88 | internal data class GetJettonWalletAddressRequest(
89 | val address: String,
90 | val jettonAddress: String,
91 | )
92 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/api/src/main/java/io/ton/walletkit/model/TONMoneyFlow.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.model
23 |
24 | import kotlinx.serialization.Serializable
25 |
26 | /**
27 | * Represents a single money transfer row in a transaction.
28 | *
29 | * Mirrors the shared TON Wallet Kit model for cross-platform consistency.
30 | *
31 | * @property type Asset type (TON or Jetton)
32 | * @property jetton Jetton address if type is JETTON
33 | * @property from Sender address
34 | * @property to Recipient address
35 | * @property amount Transfer amount
36 | */
37 | @Serializable
38 | data class TONMoneyFlowRow(
39 | val type: TONAssetType,
40 | val jetton: String? = null,
41 | val from: String? = null,
42 | val to: String? = null,
43 | val amount: String? = null,
44 | )
45 |
46 | /**
47 | * Represents a transfer involving the wallet owner.
48 | *
49 | * Mirrors the shared TON Wallet Kit model for cross-platform consistency.
50 | *
51 | * @property type Asset type (TON or Jetton)
52 | * @property jetton Jetton address if type is JETTON
53 | * @property amount Transfer amount
54 | */
55 | @Serializable
56 | data class TONMoneyFlowSelf(
57 | val type: TONAssetType,
58 | val jetton: String? = null,
59 | val amount: String,
60 | )
61 |
62 | /**
63 | * Analysis of money flow in a transaction.
64 | *
65 | * Mirrors the shared TON Wallet Kit model for cross-platform consistency.
66 | *
67 | * @property outputs Total outgoing amount in nanoTON
68 | * @property inputs Total incoming amount in nanoTON
69 | * @property allJettonTransfers All jetton transfers in transaction
70 | * @property ourTransfers Transfers involving our wallet
71 | * @property ourAddress Our wallet address
72 | */
73 | @Serializable
74 | data class TONMoneyFlow(
75 | val outputs: String? = null,
76 | val inputs: String? = null,
77 | val allJettonTransfers: List? = null,
78 | val ourTransfers: List? = null,
79 | val ourAddress: String? = null,
80 | )
81 |
--------------------------------------------------------------------------------
/TONWalletKit-Android/impl/src/main/java/io/ton/walletkit/engine/operations/requests/TonConnectRequests.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 TonTech
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 | package io.ton.walletkit.engine.operations.requests
23 |
24 | import io.ton.walletkit.event.ConnectRequestEvent
25 | import io.ton.walletkit.event.SignDataRequestEvent
26 | import io.ton.walletkit.event.TransactionRequestEvent
27 | import kotlinx.serialization.Serializable
28 | import kotlinx.serialization.json.JsonElement
29 |
30 | /**
31 | * Internal bridge request models for TonConnect operations.
32 | * These DTOs represent the exact JSON structure sent to the JavaScript bridge.
33 | *
34 | * @suppress Internal bridge communication only.
35 | */
36 |
37 | @Serializable
38 | internal data class HandleTonConnectUrlRequest(
39 | val url: String,
40 | )
41 |
42 | @Serializable
43 | internal data class ProcessInternalBrowserRequest(
44 | val messageId: String,
45 | val method: String,
46 | // Raw JSON (can be array or object)
47 | val params: JsonElement? = null,
48 | val url: String? = null,
49 | )
50 |
51 | @Serializable
52 | internal data class ApproveConnectRequest(
53 | val event: ConnectRequestEvent,
54 | val walletAddress: String,
55 | )
56 |
57 | @Serializable
58 | internal data class RejectConnectRequest(
59 | val event: ConnectRequestEvent,
60 | val reason: String? = null,
61 | )
62 |
63 | @Serializable
64 | internal data class ApproveTransactionRequest(
65 | val event: TransactionRequestEvent,
66 | )
67 |
68 | @Serializable
69 | internal data class RejectTransactionRequest(
70 | val event: TransactionRequestEvent,
71 | val reason: String? = null,
72 | )
73 |
74 | @Serializable
75 | internal data class ApproveSignDataRequest(
76 | val event: SignDataRequestEvent,
77 | )
78 |
79 | @Serializable
80 | internal data class RejectSignDataRequest(
81 | val event: SignDataRequestEvent,
82 | val reason: String? = null,
83 | )
84 |
85 | @Serializable
86 | internal data class DisconnectSessionRequest(
87 | val sessionId: String? = null,
88 | )
89 |
--------------------------------------------------------------------------------