trustless-sidechain-8.0.0: Smart contract code used by the partner-chains project.
Safe HaskellSafe-Inferred
LanguageHaskell2010

TrustlessSidechain.Versioning

Description

Versioning module implements script versioning system. It provides VersionOraclePolicy for minting tokens that store versioned scripts, as well as VersionedOracleValidator script for storing the versioning tokens. Each versioning token stores a reference script and a datum that identifies the script and its version.

Synopsis

Documentation

mkVersionOraclePolicy :: TxOutRef -> Address -> VersionOraclePolicyRedeemer -> ScriptContext -> Bool #

Manages minting and burning of versioning tokens. (Note that these are ordinary tokens, not NFTs.) No restrictions are placed on minting initial versioning tokens during sidechain initialization, other than the usual requirement of burning a genesis UTxO.

OnChain error descriptions:

ERROR-VERSION-POLICY-01: Transaction should burn exactly one init token.

ERROR-VERSION-POLICY-02: Transaction should attach datum and reference script to output containing one versioning token.

ERROR-VERSION-POLICY-03: Transaction should attach datum and reference script to output containing one versioning token.

ERROR-VERSION-POLICY-04: Script to be invalidated should be present in exactly one transaction input.

ERROR-VERSION-POLICY-05: Transaction should be signed by the governance.

ERROR-VERSION-POLICY-06: Transaction should burn all versioning tokens in the input.

ERROR-VERSION-POLICY-07: Transaction should attach datum and reference script to output containing one versioning token.

ERROR-VERSION-POLICY-08: Script can only be used for Minting purpose.

ERROR-VERSION-POLICY-09: Transaction should be signed by the governance.

ERROR-VERSION-POLICY-10: Script purpose is not Minting.

mkVersionOraclePolicyUntyped #

Arguments

:: BuiltinData

Genesis Utxo

-> BuiltinData

Validator address

-> BuiltinData

Redeemer

-> BuiltinData

ScriptContext

-> BuiltinUnit 

mkVersionOracleValidator :: BuiltinData -> VersionOracleDatum -> VersionOracle -> ScriptContext -> Bool #

Stores VersionOraclePolicy UTxOs, acting both as an oracle of available scripts as well as a script caching system. UTxOs on the script are managed by governance authority, with VersionOraclePolicy ensuring that tokens are minted and burned correctly.

mkVersionOracleValidatorUntyped #

Arguments

:: BuiltinData

Genesis UTXO

-> BuiltinData

Datum

-> BuiltinData

Redeemer

-> BuiltinData

ScriptContext

-> BuiltinUnit 

getVersionedValidatorAddress :: VersionOracleConfig -> VersionOracle -> ScriptContext -> Address #

Searches for a specified validator script passed as a reference input. Note that if requested script ID corresponds to a minting policy this function will return a result anyway without reporting any errors.

getVersionedCurrencySymbol :: VersionOracleConfig -> VersionOracle -> ScriptContext -> CurrencySymbol #

Searches for a specified minting policy passed as a reference input. Note that if requested script ID corresponds to a validator this function will return a result anyway without reporting any errors.

approvedByGovernance :: VersionOracleConfig -> ScriptContext -> Bool #

Check whether a given transaction is approved by sidechain governance. The actual check is delegated to a governance minting policy stored in the versioning system. Caller specifies the requested governance version. The transaction must mint at least one token of the governance minting policy to signify transaction approval.

newtype VersionOracle #

Datum attached to VersionOraclePolicy tokens stored on the VersionOracleValidator script.

Constructors

VersionOracle 

Fields

data VersionOracleDatum #

Datum attached to VersionOraclePolicy tokens stored on the VersionOracleValidator script.

Constructors

VersionOracleDatum 

Fields

newtype VersionOracleConfig #

Configuration of the versioning system. Contains currency symbol of VersionOraclePolicy tokens. Required to identify versioning tokens that can be trusted.

data VersionOraclePolicyRedeemer #

Redeemer for the versioning oracle minting policy that instructs the script whether to mint or burn versioning tokens.