| License | Apache-2.0 |
|---|---|
| Safe Haskell | None |
| Language | GHC2021 |
Singular.Registry.StateToken
Description
A registry is its state token and the release that made it. Everything a command needs — the seed, the state output and its datum, the pinned configuration, and the hashes of the six scripts the registry runs — is derived from those two and checked against the chain, refused by name when the chain disagrees with the release. Nothing is read from disk.
Reference outputs are a convenience found by hash: any live output whose reference script hashes to an expected hash serves, whoever made it. The hash is computed here from the output's own script; a hash a provider states is never read.
Synopsis
- data Release = Release {
- releaseState :: ShortByteString
- releaseRequest :: ShortByteString
- releaseCodes :: NamingCodes
- parseStateToken :: Text -> Either Text Asset
- renderStateToken :: Asset -> Text
- data ReferenceRole
- roleName :: ReferenceRole -> Text
- parseRole :: Text -> Maybe ReferenceRole
- expectedReferences :: ApplicationPin -> Release -> Asset -> Map ReferenceRole ScriptHash
- data ResolvedRegistry = ResolvedRegistry {
- resolvedToken :: Asset
- resolvedSeed :: TxIn
- resolvedCreation :: TxId
- resolvedState :: (TxIn, TxOut ConwayEra)
- resolvedDatum :: OnChainTokenState
- resolvedConfig :: CageConfig
- resolvedCodes :: NamingCodes
- resolvedExpected :: Map ReferenceRole ScriptHash
- resolvedNetwork :: Network
- data PinField
- data IdentityRefusal
- = StateTokenForeignRelease ScriptHash
- | StateTokenNotFound
- | StateTokenBurned Integer
- | StateTokenSeedMismatch TxId
- | StateOutputMissing
- | RegistryPinMismatch PinField
- | NetworkMismatch Network
- | IdentityUnreadable ReadFailure
- resolveRegistry :: Monad m => Application -> Release -> Asset -> Session w m -> m (Either IdentityRefusal ResolvedRegistry)
- findStateOutput :: Monad m => Asset -> Session w m -> m (Either IdentityRefusal (TxIn, TxOut ConwayEra, OnChainTokenState))
- renderIdentityRefusal :: IdentityRefusal -> Text
- data ReferenceRefusal
- = ReferenceMissing ReferenceRole ScriptHash
- | ReferenceUnreadable ReadFailure
- carriesReference :: ScriptHash -> TxOut ConwayEra -> Bool
- findReferences :: Monad m => Session w m -> Maybe Addr -> Map ReferenceRole ScriptHash -> Set ReferenceRole -> m (Either ReferenceRefusal (Map ReferenceRole (TxIn, TxOut ConwayEra)))
- renderReferenceRefusal :: ReferenceRefusal -> Text
The release
The compiled code a registry command needs from the blueprint.
Constructors
| Release | |
Fields
| |
The state token
parseStateToken :: Text -> Either Text Asset Source #
A state token as the command line spells it, POLICY.NAME, each part
in hex: a 28-byte policy and a 32-byte name. Any other shape is refused
before any provider is asked.
renderStateToken :: Asset -> Text Source #
The POLICY.NAME spelling of a state token.
Reference roles and the hashes they must carry
data ReferenceRole Source #
The six scripts a registry runs, by the role their reference plays.
Constructors
| RoleState | |
| RoleRequest | |
| RoleWitnessAbsent | |
| RoleWitnessActive | |
| RoleWitnessTerminal | |
| RoleApplication |
Instances
roleName :: ReferenceRole -> Text Source #
A role as receipts spell it.
parseRole :: Text -> Maybe ReferenceRole Source #
A role from its receipt spelling.
expectedReferences :: ApplicationPin -> Release -> Asset -> Map ReferenceRole ScriptHash Source #
The script hash each role must carry, derived from the release, the
application pin and the token alone. The state hash is the release's
state script; every other role is the release's script for it applied to
the registry identity, state policy then token name. A pin read from
state arrives as PinByHash of the datum's pin: resolveRegistry
reads the datum first. A hash pin publishes no application reference
(slice 2: its script bytes do not exist), so it omits that role; a script
or compiled pin lists it as today.
Resolving a token into a registry
data ResolvedRegistry Source #
A registry exists only once every identity check has passed.
Constructors
| ResolvedRegistry | |
Fields
| |
The datum policy a registry pins, in the order they are compared.
Constructors
| PinApplication | |
| PinActive | |
| PinAbsent | |
| PinTerminal |
Instances
| Bounded PinField Source # | |
Defined in Singular.Registry.StateToken | |
| Enum PinField Source # | |
Defined in Singular.Registry.StateToken Methods succ :: PinField -> PinField Source # pred :: PinField -> PinField Source # toEnum :: Int -> PinField Source # fromEnum :: PinField -> Int Source # enumFrom :: PinField -> [PinField] Source # enumFromThen :: PinField -> PinField -> [PinField] Source # enumFromTo :: PinField -> PinField -> [PinField] Source # enumFromThenTo :: PinField -> PinField -> PinField -> [PinField] Source # | |
| Show PinField Source # | |
Defined in Singular.Registry.StateToken | |
| Eq PinField Source # | |
Defined in Singular.Registry.StateToken | |
| Ord PinField Source # | |
Defined in Singular.Registry.StateToken | |
data IdentityRefusal Source #
Why a state token is not a registry of this release, in checking order.
Constructors
| StateTokenForeignRelease ScriptHash | The token's policy is not this release's state script |
| StateTokenNotFound | The provider has no record of the asset |
| StateTokenBurned Integer | The supply is not one: the supply found |
| StateTokenSeedMismatch TxId | The minting transaction spends no seed of the token's name |
| StateOutputMissing | No output holds the token at the state address with a state datum |
| RegistryPinMismatch PinField | A datum pin differs from the hash the release and token derive |
| NetworkMismatch Network | The provider's network is not the release's |
| IdentityUnreadable ReadFailure | The provider could not be read; no identity fact was decided |
Instances
| Show IdentityRefusal Source # | |
Defined in Singular.Registry.StateToken Methods showsPrec :: Int -> IdentityRefusal -> ShowS Source # show :: IdentityRefusal -> String Source # showList :: [IdentityRefusal] -> ShowS Source # | |
| Eq IdentityRefusal Source # | |
Defined in Singular.Registry.StateToken Methods (==) :: IdentityRefusal -> IdentityRefusal -> Bool Source # (/=) :: IdentityRefusal -> IdentityRefusal -> Bool Source # | |
resolveRegistry :: Monad m => Application -> Release -> Asset -> Session w m -> m (Either IdentityRefusal ResolvedRegistry) Source #
Resolve a state token into a registry, refusing by name in the checking order. No file is read. The application pin is compared with the state datum only for a script pin; a pin read from state is taken from the datum, and the three witness pins are compared as always.
findStateOutput :: Monad m => Asset -> Session w m -> m (Either IdentityRefusal (TxIn, TxOut ConwayEra, OnChainTokenState)) Source #
The output that holds the token at the state address of the token's policy, with its state datum. The provider's answer to who holds the token is unverified: each listed output is admitted only if its own value holds the token. A command reads the state again through this after it has resolved the registry, since every transition moves the state output.
renderIdentityRefusal :: IdentityRefusal -> Text Source #
The refusal's name, then what it found.
References found by hash
data ReferenceRefusal Source #
Why a command cannot run the scripts it needs.
Constructors
| ReferenceMissing ReferenceRole ScriptHash | No source found a carrier of this role's hash |
| ReferenceUnreadable ReadFailure | A source could not be read |
Instances
| Show ReferenceRefusal Source # | |
Defined in Singular.Registry.StateToken Methods showsPrec :: Int -> ReferenceRefusal -> ShowS Source # show :: ReferenceRefusal -> String Source # showList :: [ReferenceRefusal] -> ShowS Source # | |
| Eq ReferenceRefusal Source # | |
Defined in Singular.Registry.StateToken Methods (==) :: ReferenceRefusal -> ReferenceRefusal -> Bool Source # (/=) :: ReferenceRefusal -> ReferenceRefusal -> Bool Source # | |
carriesReference :: ScriptHash -> TxOut ConwayEra -> Bool Source #
Whether the output carries a reference script whose hash, computed here from the script itself, is the expected one.
Arguments
| :: Monad m | |
| => Session w m | |
| -> Maybe Addr | The actor's wallet, when the command has one |
| -> Map ReferenceRole ScriptHash | |
| -> Set ReferenceRole | The roles the command's transaction runs |
| -> m (Either ReferenceRefusal (Map ReferenceRole (TxIn, TxOut ConwayEra))) |
Find a carrier for each needed role: from the provider's existence
query, then the actor's wallet, read only when the provider carries none
of some role. A carrier is admitted only by carriesReference; among the
admitted carriers of the first source that has any, the lowest output
reference is chosen. A command that runs no reference script reads
nothing.
renderReferenceRefusal :: ReferenceRefusal -> Text Source #
The refusal, with the remedy.