diff --git a/lib/src/commonMain/kotlin/xyz/mcxross/kaptos/Aptos.kt b/lib/src/commonMain/kotlin/xyz/mcxross/kaptos/Aptos.kt index c3af7456..ff86401d 100644 --- a/lib/src/commonMain/kotlin/xyz/mcxross/kaptos/Aptos.kt +++ b/lib/src/commonMain/kotlin/xyz/mcxross/kaptos/Aptos.kt @@ -16,6 +16,7 @@ package xyz.mcxross.kaptos +import xyz.mcxross.kaptos.core.Application import xyz.mcxross.kaptos.model.* import xyz.mcxross.kaptos.protocol.* @@ -24,7 +25,10 @@ import xyz.mcxross.kaptos.protocol.* * * @param config [AptosConfig] to optionally configure the SDK. */ -class Aptos(override val config: AptosConfig = AptosConfig()) : +class Aptos( + override val config: AptosConfig = AptosConfig(), + graceFull: Boolean = Application.graceFull, +) : Account by xyz.mcxross.kaptos.api.Account(config), Coin by xyz.mcxross.kaptos.api.Coin(config), General by xyz.mcxross.kaptos.api.General(config), @@ -32,4 +36,18 @@ class Aptos(override val config: AptosConfig = AptosConfig()) : Staking by xyz.mcxross.kaptos.api.Staking(config), DigitalAsset by xyz.mcxross.kaptos.api.DigitalAsset(config), Faucet by xyz.mcxross.kaptos.api.Faucet(config), - Ans by xyz.mcxross.kaptos.api.Ans(config) + Ans by xyz.mcxross.kaptos.api.Ans(config) { + + init { + Application.graceFull = graceFull + } + + /** + * Returns the current graceFull setting. + * + * @return [Boolean] indicating if the SDK is in graceFull mode. + */ + fun isGraceFull(): Boolean { + return Application.graceFull + } +} diff --git a/lib/src/commonMain/kotlin/xyz/mcxross/kaptos/core/Application.kt b/lib/src/commonMain/kotlin/xyz/mcxross/kaptos/core/Application.kt new file mode 100644 index 00000000..e4265e86 --- /dev/null +++ b/lib/src/commonMain/kotlin/xyz/mcxross/kaptos/core/Application.kt @@ -0,0 +1,28 @@ +/* + * Copyright 2024 McXross + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package xyz.mcxross.kaptos.core + +import xyz.mcxross.kaptos.model.Option + +/** + * The [Application] object is used to store global state for the SDK. + * + * @property graceFull [Boolean] indicating if the SDK is in graceFull mode. This is used to + * determine if the SDK should throw exceptions or return [Option.None]. + */ +internal object Application { + var graceFull: Boolean = false +}