Skip to content

Commit

Permalink
schema: commit to developer identity
Browse files Browse the repository at this point in the history
Closes #226
  • Loading branch information
dr-orlovsky committed Mar 30, 2024
1 parent df250c0 commit 8d73140
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 154 deletions.
2 changes: 1 addition & 1 deletion src/contract/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub use fungible::{
pub use global::{GlobalState, GlobalValues};
pub use meta::{MetaValue, Metadata, MetadataError};
pub use operations::{
Extension, Genesis, Input, Inputs, Issuer, OpRef, Operation, Redeemed, Transition, Valencies,
Extension, Genesis, Identity, Input, Inputs, OpRef, Operation, Redeemed, Transition, Valencies,
};
pub use seal::{
ExposedSeal, GenesisSeal, GraphSeal, OutputSeal, SecretSeal, TxoSeal, WitnessId, WitnessOrd,
Expand Down
13 changes: 5 additions & 8 deletions src/contract/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,10 @@ pub trait Operation {
fn disclose_hash(&self) -> DiscloseHash { self.disclose().commit_id() }
}

/// Issuer is a binary string which must be encoded into the issuer identity in
/// the application.
///
/// We deliberately do not define the internal structure of the identity such
/// that it can be updated without changes to the consensus level.
///
/// Contract validity doesn't assume any checks on the issuer identity; these
/// Contract or schema validity doesn't assume any checks on the identity; these
/// checks must be performed at the application level.
#[derive(Wrapper, Clone, PartialEq, Eq, Hash, Debug, Default, From, Display)]
#[wrapper(Deref, AsSlice, BorrowSlice, Hex)]
Expand All @@ -258,12 +255,12 @@ pub trait Operation {
derive(Serialize, Deserialize),
serde(crate = "serde_crate", transparent)
)]
pub struct Issuer(SmallBlob);
pub struct Identity(SmallBlob);

impl FromStr for Issuer {
impl FromStr for Identity {
type Err = hex::Error;

fn from_str(s: &str) -> Result<Self, Self::Err> { Issuer::from_hex(s) }
fn from_str(s: &str) -> Result<Self, Self::Err> { Identity::from_hex(s) }
}

#[derive(Clone, PartialEq, Eq, Debug)]
Expand All @@ -285,7 +282,7 @@ pub struct Genesis {
pub globals: GlobalState,
pub assignments: Assignments<GenesisSeal>,
pub valencies: Valencies,
pub issuer: Issuer,
pub issuer: Identity,
pub validator: ReservedBytes<1, 0>,
}

Expand Down
6 changes: 5 additions & 1 deletion src/schema/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use strict_types::SemId;
use super::{
AssignmentType, ExtensionSchema, GenesisSchema, OwnedStateSchema, TransitionSchema, ValencyType,
};
use crate::{Ffv, GlobalStateSchema, Occurrences, LIB_NAME_RGB};
use crate::{Ffv, GlobalStateSchema, Identity, Occurrences, LIB_NAME_RGB};

#[derive(Wrapper, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug, From, Display)]
#[wrapper(FromStr, LowerHex, UpperHex)]
Expand Down Expand Up @@ -177,6 +177,8 @@ pub struct Schema {
pub genesis: GenesisSchema,
pub extensions: TinyOrdMap<ExtensionType, ExtensionSchema>,
pub transitions: TinyOrdMap<TransitionType, TransitionSchema>,

pub developer: Identity,
}

impl CommitEncode for Schema {
Expand All @@ -193,6 +195,8 @@ impl CommitEncode for Schema {
e.commit_to_serialized(&self.genesis);
e.commit_to_map(&self.extensions);
e.commit_to_map(&self.transitions);

e.commit_to_serialized(&self.developer);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/stl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use crate::{

/// Strict types id for the library providing data types for RGB consensus.
pub const LIB_ID_RGB: &str =
"urn:ubideco:stl:8mcrov7AXHM6ursbnhGhUL4fqTZy75qbnizFBXkVraDc#owner-sport-siren";
"urn:ubideco:stl:3FutCjz99uxoPmwTgNPP6TxXnZo3FqKUvgzSTqeHE6Ef#opinion-visitor-domino";

fn _rgb_core_stl() -> Result<TypeLib, CompileError> {
LibBuilder::new(libname!(LIB_NAME_RGB), tiny_bset! {
Expand Down
273 changes: 137 additions & 136 deletions stl/[email protected]

Large diffs are not rendered by default.

Binary file modified stl/[email protected]
Binary file not shown.
15 changes: 8 additions & 7 deletions stl/[email protected]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-
Id: urn:ubideco:stl:8mcrov7AXHM6ursbnhGhUL4fqTZy75qbnizFBXkVraDc#owner-sport-siren
Id: urn:ubideco:stl:3FutCjz99uxoPmwTgNPP6TxXnZo3FqKUvgzSTqeHE6Ef#opinion-visitor-domino
Name: RGB
Version: 0.1.0
Description: Consensus layer for RGB smart contracts
Expand Down Expand Up @@ -271,7 +271,7 @@ data FungibleState : bits64#8 U64
data FungibleType : unsigned64Bit#8


@mnemonic(super-hexagon-sample)
@mnemonic(photo-peru-rider)
data Genesis : ffv Ffv
, schemaId SchemaId
, flags CommitVerify.ReservedBytes1#joker-lemon-mental
Expand All @@ -282,7 +282,7 @@ data Genesis : ffv Ffv
, globals GlobalState
, assignments AssignmentsBlindSealTxid
, valencies Valencies
, issuer Issuer
, issuer Identity
, validator CommitVerify.ReservedBytes1#joker-lemon-mental

@mnemonic(formal-door-pixel)
Expand All @@ -309,6 +309,9 @@ data GlobalStateType : U16
@mnemonic(bicycle-europe-shampoo)
data GlobalValues : [RevealedData ^ 1..]

@mnemonic(instant-tiger-athena)
data Identity : [Byte]

@mnemonic(press-egypt-helena)
data Input : prevOut Opout, reserved CommitVerify.ReservedBytes2#pocket-habitat-soviet

Expand All @@ -318,9 +321,6 @@ data InputMap : {Bitcoin.Vout -> ^ 1.. OpId}
@mnemonic(liquid-meaning-convert)
data Inputs : {Input}

@mnemonic(veteran-tango-content)
data Issuer : [Byte]

@mnemonic(light-nelson-brain)
data MediaType : any#255

Expand Down Expand Up @@ -406,7 +406,7 @@ data RevealedFungible : value FungibleState
, blinding BlindingFactor
, tag AssetTag

@mnemonic(scale-initial-anita)
@mnemonic(pump-popular-sensor)
data Schema : ffv Ffv
, flags CommitVerify.ReservedBytes1#joker-lemon-mental
, metaTypes {MetaType -> ^ ..0xff StrictTypes.SemId#cargo-plasma-catalog}
Expand All @@ -416,6 +416,7 @@ data Schema : ffv Ffv
, genesis GenesisSchema
, extensions {ExtensionType -> ^ ..0xff ExtensionSchema}
, transitions {TransitionType -> ^ ..0xff TransitionSchema}
, developer Identity

@mnemonic(garcia-smoke-ozone)
data SchemaId : [Byte ^ 32]
Expand Down
2 changes: 2 additions & 0 deletions stl/Schema.vesper
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ SchemaId commitment hasher=SHA256 tagged=urn:lnp-bp:rgb:schema#2024-02-03
TransitionSchema map len=0..MAX8
TransitionType mapKey
TransitionSchema mapValue
Identity serialized

Schema rec
ffv is U16 aka=Ffv
Expand Down Expand Up @@ -115,4 +116,5 @@ Schema rec
some rec LibSite option wrapped tag=1
lib bytes len=32 aka=LibId
pos is U16
developer bytes len=0..MAX16 aka=Identity

0 comments on commit 8d73140

Please sign in to comment.