From cca4f1862b8322e3a917555a87c20f308e302126 Mon Sep 17 00:00:00 2001 From: chenchan09 <71864661+chenchan09@users.noreply.github.com> Date: Mon, 5 Jan 2026 11:19:42 +0800 Subject: [PATCH 1/5] init fix --- .../java/com/altude/core/config/SdkConfig.kt | 3 ++- .../java/com/altude/core/data/SwapRequest.kt | 6 ++--- .../core/model/AltudeTransactionBuilder.kt | 2 +- gasstation/build.gradle.kts | 3 +++ .../gasstation/ExampleInstrumentedTest.kt | 7 +++--- .../com/altude/gasstation/GaslessManager.kt | 25 ++++++++++--------- smart-account/build.gradle.kts | 2 +- 7 files changed, 26 insertions(+), 22 deletions(-) diff --git a/core/src/main/java/com/altude/core/config/SdkConfig.kt b/core/src/main/java/com/altude/core/config/SdkConfig.kt index bbd6648..0716119 100644 --- a/core/src/main/java/com/altude/core/config/SdkConfig.kt +++ b/core/src/main/java/com/altude/core/config/SdkConfig.kt @@ -6,6 +6,7 @@ import com.altude.core.api.ConfigResponse import com.altude.core.api.TransactionService import com.altude.core.service.StorageService import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory +import com.solana.transaction.MessageSerializer import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.json.Json import okhttp3.Interceptor @@ -32,7 +33,7 @@ object SdkConfig { private var baseUrl: String = "https://api.altude.so" //"http://10.0.2.2:5000/"// var apiKey: String = "" //lateinit var ownerKeyPair: Keypair - var isDevnet: Boolean = true + var isDevnet: Boolean = false @OptIn(ExperimentalTime::class) var apiConfig = ConfigResponse() diff --git a/core/src/main/java/com/altude/core/data/SwapRequest.kt b/core/src/main/java/com/altude/core/data/SwapRequest.kt index 00890b2..d424aaa 100644 --- a/core/src/main/java/com/altude/core/data/SwapRequest.kt +++ b/core/src/main/java/com/altude/core/data/SwapRequest.kt @@ -146,13 +146,13 @@ data class RoutePlan( @Serializable data class SwapInfo( val ammKey: String, - val label: String, + val label: String? = null, val inputMint: String, val outputMint: String, val inAmount: String, val outAmount: String, - val feeAmount: String, - val feeMint: String + val feeAmount: String? = null, + val feeMint: String? = null ) @Serializable diff --git a/core/src/main/java/com/altude/core/model/AltudeTransactionBuilder.kt b/core/src/main/java/com/altude/core/model/AltudeTransactionBuilder.kt index acb27d6..694784d 100644 --- a/core/src/main/java/com/altude/core/model/AltudeTransactionBuilder.kt +++ b/core/src/main/java/com/altude/core/model/AltudeTransactionBuilder.kt @@ -671,7 +671,7 @@ class VersionedSolanaTransaction ( instruction.accountIndices.forEach { keyIndex -> require(keyIndex >= 0) } } // 4. Return Message - return (when (transactionVersion) { + return (when (transacionVersion) { TransactionVersion.V0 -> VersionedMessage( version = VERSION_BIT.toByte(), signatureCount = numRequiredSignatures.toUByte(), diff --git a/gasstation/build.gradle.kts b/gasstation/build.gradle.kts index ef67829..7797083 100644 --- a/gasstation/build.gradle.kts +++ b/gasstation/build.gradle.kts @@ -58,6 +58,9 @@ dependencies { implementation(libs.serialization.json) { exclude(group = "com.ditchoom") } +// implementation("com.solanamobile:web3-solana:0.2.5") { +// exclude(group = "com.ditchoom.buffer") +// } } diff --git a/gasstation/src/androidTest/java/com/altude/gasstation/ExampleInstrumentedTest.kt b/gasstation/src/androidTest/java/com/altude/gasstation/ExampleInstrumentedTest.kt index 0b42f1a..fc0f368 100644 --- a/gasstation/src/androidTest/java/com/altude/gasstation/ExampleInstrumentedTest.kt +++ b/gasstation/src/androidTest/java/com/altude/gasstation/ExampleInstrumentedTest.kt @@ -40,7 +40,7 @@ class ExampleInstrumentedTest { @Before fun setup()=runBlocking{ context = InstrumentationRegistry.getInstrumentation().targetContext//ApplicationProvider.getApplicationContext() - Altude.setApiKey(context,"") + Altude.setApiKey(context,"ak_f8AEgOp8_hLocOBr6S4m6d8xo7T0QKHKB4s2BiamaDc") } // @Test @@ -281,8 +281,7 @@ class ExampleInstrumentedTest { @Test fun testSwap() = runBlocking { //Altude.savePrivateKey(accountPrivateKey ) - val testMnemonic = System.getProperty("TEST_MNEMONIC") ?: "" - Altude.saveMnemonic(testMnemonic) + Altude.saveMnemonic("pause trial leisure wife deliver save crack sniff exact village claim upset") val option = SwapOption( account = "BG8ttfjfSdUVxJB5saKq59gfFdtpvDBeVTwg1X3ZBUyS", inputMint = Token.SOL.mint(), @@ -293,7 +292,7 @@ class ExampleInstrumentedTest { ) // Wrap the callback in a suspendable way (like a suspendCoroutine) - val result = Altude.swap(option) + val result = Altude.swap2(option) result .onSuccess { println("✅ Sent: ${it.Signature}") } .onFailure { diff --git a/gasstation/src/main/java/com/altude/gasstation/GaslessManager.kt b/gasstation/src/main/java/com/altude/gasstation/GaslessManager.kt index cf20c8e..77698b8 100644 --- a/gasstation/src/main/java/com/altude/gasstation/GaslessManager.kt +++ b/gasstation/src/main/java/com/altude/gasstation/GaslessManager.kt @@ -283,19 +283,20 @@ object GaslessManager { if (ataInfo != null) { val parsed = ataInfo.data?.parsed?.info val balance = parsed?.tokenAmount?.uiAmount ?: 0.0 - - if (parsed?.closeAuthority == feePayerPubKey.toBase58() || defaultWallet == null) - authorized = feePayerPubKey - else { - authorized = defaultWallet.publicKey - isOwnerRequiredSignature = true + if(balance == 0.0 || token == Token.SOL.mint()){ + if (parsed?.closeAuthority == feePayerPubKey.toBase58() || defaultWallet == null) + authorized = feePayerPubKey + else { + authorized = defaultWallet.publicKey + isOwnerRequiredSignature = true + } + val instruction = TokenProgram.closeAtaAccount( + ata = ata, + destination = authorized, + authority = authorized + ) + txInstructions.add(instruction) } - val instruction = TokenProgram.closeAtaAccount( - ata = ata, - destination = authorized, - authority = authorized - ) - txInstructions.add(instruction) } diff --git a/smart-account/build.gradle.kts b/smart-account/build.gradle.kts index 622a13a..2a9ae53 100644 --- a/smart-account/build.gradle.kts +++ b/smart-account/build.gradle.kts @@ -51,7 +51,7 @@ dependencies { // //implementation("com.ditchoom:buffer-android:1.4.2") // // testImplementation(platform("org.junit:junit-bom:5.13.4")) -// testImplementation("org.junit.jupiter:junit-jupiter") +// testImplementation("org.junit.swap:junit-swap") // testRuntimeOnly("org.junit.platform:junit-platform-launcher") implementation("foundation.metaplex:solana:0.2.10"){ From d616c3b9e3f92186edb96cbdb506722c5a26266f Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 5 Jan 2026 17:43:16 -0600 Subject: [PATCH 2/5] Update core/src/main/java/com/altude/core/model/AltudeTransactionBuilder.kt Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../main/java/com/altude/core/model/AltudeTransactionBuilder.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/com/altude/core/model/AltudeTransactionBuilder.kt b/core/src/main/java/com/altude/core/model/AltudeTransactionBuilder.kt index 694784d..acb27d6 100644 --- a/core/src/main/java/com/altude/core/model/AltudeTransactionBuilder.kt +++ b/core/src/main/java/com/altude/core/model/AltudeTransactionBuilder.kt @@ -671,7 +671,7 @@ class VersionedSolanaTransaction ( instruction.accountIndices.forEach { keyIndex -> require(keyIndex >= 0) } } // 4. Return Message - return (when (transacionVersion) { + return (when (transactionVersion) { TransactionVersion.V0 -> VersionedMessage( version = VERSION_BIT.toByte(), signatureCount = numRequiredSignatures.toUByte(), From 955a1d83ff6ee945c4434e50c1e3feee792ffa07 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 23:44:02 +0000 Subject: [PATCH 3/5] Initial plan From 10655fd692dede9846b945c1f28fb5a8037f7caa Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 23:47:47 +0000 Subject: [PATCH 4/5] Remove hardcoded API key from test file, restore empty string Co-authored-by: mocolicious <6373607+mocolicious@users.noreply.github.com> --- .../java/com/altude/gasstation/ExampleInstrumentedTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gasstation/src/androidTest/java/com/altude/gasstation/ExampleInstrumentedTest.kt b/gasstation/src/androidTest/java/com/altude/gasstation/ExampleInstrumentedTest.kt index fc0f368..f907e26 100644 --- a/gasstation/src/androidTest/java/com/altude/gasstation/ExampleInstrumentedTest.kt +++ b/gasstation/src/androidTest/java/com/altude/gasstation/ExampleInstrumentedTest.kt @@ -40,7 +40,7 @@ class ExampleInstrumentedTest { @Before fun setup()=runBlocking{ context = InstrumentationRegistry.getInstrumentation().targetContext//ApplicationProvider.getApplicationContext() - Altude.setApiKey(context,"ak_f8AEgOp8_hLocOBr6S4m6d8xo7T0QKHKB4s2BiamaDc") + Altude.setApiKey(context,"") } // @Test From 549c41047c67b5b52d192844277c8a201a763e91 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 5 Jan 2026 19:00:46 -0600 Subject: [PATCH 5/5] Update core/src/main/java/com/altude/core/config/SdkConfig.kt Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- core/src/main/java/com/altude/core/config/SdkConfig.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/main/java/com/altude/core/config/SdkConfig.kt b/core/src/main/java/com/altude/core/config/SdkConfig.kt index 0716119..c97cfac 100644 --- a/core/src/main/java/com/altude/core/config/SdkConfig.kt +++ b/core/src/main/java/com/altude/core/config/SdkConfig.kt @@ -6,7 +6,6 @@ import com.altude.core.api.ConfigResponse import com.altude.core.api.TransactionService import com.altude.core.service.StorageService import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory -import com.solana.transaction.MessageSerializer import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.json.Json import okhttp3.Interceptor