From eec1a6f41e0c3d8a41528608a433fd2b3322d5c2 Mon Sep 17 00:00:00 2001 From: astinz <28899947+astinz@users.noreply.github.com> Date: Fri, 9 Feb 2024 15:18:07 +0300 Subject: [PATCH] abstract intent creation... --- .../kotlin/xyz/mcxross/ksui/model/Intent.kt | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/src/commonMain/kotlin/xyz/mcxross/ksui/model/Intent.kt b/lib/src/commonMain/kotlin/xyz/mcxross/ksui/model/Intent.kt index 9ee6756b..41494f9e 100644 --- a/lib/src/commonMain/kotlin/xyz/mcxross/ksui/model/Intent.kt +++ b/lib/src/commonMain/kotlin/xyz/mcxross/ksui/model/Intent.kt @@ -29,3 +29,23 @@ enum class AppId { data class Intent(val scope: IntentScope, val version: IntentVersion, val appId: AppId) @Serializable data class IntentMessage(val intent: Intent, val message: T) + +// An intent abstraction. This is so as it is scoped, but can well be a top level function +// TODO: This is a placeholder for now, look back at this later +@Serializable +enum class IntentType { + SUI_TX { + override fun intent(scope: IntentScope, version: IntentVersion, appId: AppId): Intent = + Intent(IntentScope.TRANSACTIONDATA, IntentVersion.V0, AppId.SUI) + }, + SUI_APP { + override fun intent(scope: IntentScope, version: IntentVersion, appId: AppId): Intent = + Intent(IntentScope.TRANSACTIONEFFECTS, IntentVersion.V0, AppId.SUI) + }; + + abstract fun intent( + scope: IntentScope = IntentScope.TRANSACTIONDATA, + version: IntentVersion = IntentVersion.V0, + appId: AppId = AppId.SUI, + ): Intent +}