All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tech.pylons.lib.core.IEngine.kt Maven / Gradle / Ivy

package tech.pylons.lib.core

import tech.pylons.lib.types.*
import tech.pylons.lib.types.credentials.ICredentials
import tech.pylons.lib.types.tx.Coin
import tech.pylons.lib.types.tx.Trade
import tech.pylons.lib.types.tx.item.Item
import tech.pylons.lib.types.tx.recipe.*
import tech.pylons.lib.types.tx.trade.TradeItemInput

/***
 * Generic interface for transaction-handling layers.
 * Engine provides a suite of basic functionality that WalletCore as a whole
 * can use to handle transactions at a high level; individual TXHandler implementations
 * will do the dirty work of binding that functionality to low-level blockchain
 * systems, in effect acting as "drivers."
 */
interface IEngine {
    /**
     * Identifier string, unique per Engine implementation.
     * Used to identify the engine type associated with a given dataset
     * when we dump the datastore to XML.
     */
    val prefix : String

    /** Identifies whether or not we're using BIP44 mnemonics when doing keygen. */
    val usesMnemonic : Boolean

    /** The current CryptoHandler instance associated with this engine */
    var cryptoHandler : ICryptoHandler

    /** Enable-recipe message */
    fun enableRecipe(id : String) : Transaction

    /** Batch enable-recipe message */
    fun enableRecipes(recipes : List) : List

    /** Disable-recipe message */
    fun disableRecipe(id : String) : Transaction

    /** Batch enable-recipe message */
    fun disableRecipes(recipes : List) : List

    /** Execute-recipe message */
    fun applyRecipe(id : String, itemIds : List, paymentId:String="") : Transaction

    /** Check-execution message */
    fun checkExecution(id : String, payForCompletion : Boolean) : Transaction

    /** Create-trade message */
    fun createTrade(coinInputs: List, itemInputs: List,
                    coinOutputs : List, itemOutputs : List,
                    ExtraInfo : String) : Transaction

    /** Create-recipe message */
    fun createRecipe(name : String, cookbookId : String, description: String, blockInterval : Long,
                     coinInputs : List, itemInputs : List, entries : EntriesList,
                     outputs : List, extraInfo: String) : Transaction

    /** Batch create-recipe message */
    fun createRecipes(names : List, cookbookIds : List, descriptions: List,
                      blockIntervals : List, coinInputs : List>,
                      itemInputs : List>, entries : List,
                      outputs: List>, extraInfos: List) : List

    /** Create-cookbook message */
    fun createCookbook (id : String, name : String, developer : String, description : String, version : String,
                                 supportEmail : String, costPerBlock : Long) : Transaction

    /** Batch create-cookbook message */
    fun createCookbooks(ids : List, names : List, developers: List, descriptions: List,
                        versions : List, supportEmails: List,
                        costsPerBlock : List) : List

    /**
     * Copies some data from profile's credentials object to userdata
     * for serialization.
     *  TODO: why does this actually exist?
     */
    fun dumpCredentials (credentials: ICredentials)

    fun fulfillTrade (tradeId : String, itemIds : List, paymentId: String = "") : Transaction

    fun cancelTrade (tradeId : String) : Transaction
    /**
     * Generates a new Credentials object appropriate for our engine
     * type from the given mnemonic.
     */
    fun generateCredentialsFromMnemonic (mnemonic : String, passphrase : String) : ICredentials

    /**
     * Generates a new Credentials object appropriate for our engine
     * type from keys in userdata.
     */
    fun generateCredentialsFromKeys () : ICredentials

    /**
     * Creates new, default Credentials object appropriate for engine
     * type.
     */
    fun getNewCredentials () : ICredentials

    fun getProfileState (addr : String) : Profile?

    /** Get the balances of the user account. */
    fun getMyProfileState () : MyProfile?

    fun getCompletedExecutions() : List

    fun getPendingExecutions () : List

    /** Get a new instance of a CryptoHandler object appropriate for engine type. */
    fun getNewCryptoHandler() : ICryptoHandler

    /** Get the current status block. (Status block is returned w/ all IPC calls) */
    fun getStatusBlock() : StatusBlock

    /**
     * Retrieves transaction w/ the given ID.
     * (In an engine built to implement Cosmos functionality, this is the txhash)
     */
    fun getTransaction (id : String) : Transaction

    /** Registers a new profile under given name. */
    fun registerNewProfile (name : String, kp : PylonsSECP256K1.KeyPair?) : Transaction

    fun createChainAccount () : Transaction

    /** Calls non-IAP get pylons endpoint. Shouldn't work against production nodes. */
    fun getPylons (q : Long) : Transaction

    /** Calls Google IAP get pylons endpoint. */
    fun googleIapGetPylons(productId: String, purchaseToken: String, receiptData: String, signature: String): Transaction

    fun checkGoogleIapOrder(purchaseToken: String) : Boolean

    /** Gets initial userdata tables for the engine type. */
    fun getInitialDataSets () : MutableMap>

    /** Calls send pylons endpoint. */
    fun sendCoins (coins : List, receiver : String) : Transaction

    /** Update-cookbook message */
    fun updateCookbook (id : String, developer : String, description : String, version : String,
                                 supportEmail : String) : Transaction

    /** Batch update-cookbook message */
    fun updateCookbooks(ids : List, names : List, developers: List, descriptions: List,
                        versions : List, supportEmails: List) : List

    /** Update-recipe message */
    fun updateRecipe(id : String, name : String, cookbookId : String, description: String, blockInterval : Long,
                              coinInputs : List, itemInputs : List, entries : EntriesList, outputs: List, extraInfo: String) : Transaction

    /** Batch update-recipe message */
    fun updateRecipes (ids: List, names : List, cookbookIds : List, descriptions: List,
                       blockIntervals : List, coinInputs : List>, itemInputs : List>,
                       entries : List, outputs: List>, extraInfos: List) : List

    /** List recipes query */
    fun listRecipes () : List

    /** List cookbooks query */
    fun listCookbooks () : List

    fun setItemFieldString (itemId : String, field : String, value : String) : Transaction

    fun listTrades () : List

    fun sendItems(receiver: String, itemIds: List) : Transaction

    fun getLockedCoins () : LockedCoin

    fun getLockedCoinDetails () : LockedCoinDetails

    fun listRecipesBySender() : List

    fun getRecipe(recipeId: String) : Recipe?

    fun listRecipesByCookbookId(cookbookId: String) : List

    fun getTrade(tradeId: String) : Trade?

    fun getItem(itemId: String): Item?

    fun listItems() : List

    fun listItemsBySender(sender: String?) : List

    fun listItemsByCookbookId(cookbookId: String?): List

    fun getCookbook(cookbookId: String): Cookbook?

    fun getExecution(executionId: String): Execution?

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy