Skip to content

Commit 96a651d

Browse files
committed
chore: add tracing to submitIntent with intent id
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 5db5372 commit 96a651d

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

  • libs/encryption/keys/src/main/kotlin/com/getcode/solana/keys
  • services/opencode/src/main/kotlin/com/getcode/opencode/internal/network/executors

libs/encryption/keys/src/main/kotlin/com/getcode/solana/keys/Key.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ abstract class KeyType(bytes: List<Byte>) {
3030

3131
fun KeyType.base58(): String = Base58.encode(bytes.toByteArray())
3232
fun KeyType.base64(): String = bytes.toByteArray().encodeBase64()
33+
fun KeyType.base58Redacted(): String = base58().redact(visibleLength = 4)
34+
fun KeyType.base64Redacted(): String = base64().redact(visibleLength = 8)
35+
36+
fun String.redact(visibleLength: Int = 4): String {
37+
if (length <= visibleLength * 2) return this
38+
return "${take(visibleLength)}${takeLast(visibleLength)}"
39+
}
3340

3441
class Key16(bytes: List<Byte>) : KeyType(bytes) {
3542
override val size: Int get() = LENGTH_16

services/opencode/src/main/kotlin/com/getcode/opencode/internal/network/executors/IntentExecutor.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import com.getcode.opencode.solana.intents.IntentType
1414
import com.getcode.opencode.solana.intents.ServerParameter
1515
import com.getcode.services.opencode.BuildConfig
1616
import com.getcode.solana.keys.base58
17+
import com.getcode.solana.keys.redact
1718
import com.getcode.utils.TraceType
1819
import com.getcode.utils.trace
1920
import kotlinx.coroutines.CoroutineScope
@@ -99,7 +100,13 @@ class IntentExecutor(
99100
owner: KeyPair,
100101
): Result<IntentType> = openBidirectionalStreamForResult(
101102
streamRef = streamRef,
102-
apiCall = api::submitIntent,
103+
apiCall = { request ->
104+
trace(
105+
tag = "SubmitIntent",
106+
message = "submitting intent ${intent.id.base58().redact()}"
107+
)
108+
api.submitIntent(request)
109+
},
103110
initialRequest = { intent.requestToSubmitActions(owner) },
104111
responseHandler = { response, onResult, requestChannel ->
105112
when (val result = response.responseCase) {

0 commit comments

Comments
 (0)