schemata/
lib.rs

1// RGB schemas
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5// Written in 2023-2024 by
6//     Dr Maxim Orlovsky <orlovsky@lnp-bp.org>
7//
8// Copyright (C) 2023-2024 LNP/BP Standards Association. All rights reserved.
9//
10// Licensed under the Apache License, Version 2.0 (the "License");
11// you may not use this file except in compliance with the License.
12// You may obtain a copy of the License at
13//
14//     http://www.apache.org/licenses/LICENSE-2.0
15//
16// Unless required by applicable law or agreed to in writing, software
17// distributed under the License is distributed on an "AS IS" BASIS,
18// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19// See the License for the specific language governing permissions and
20// limitations under the License.
21
22#[macro_use]
23extern crate amplify;
24#[macro_use]
25extern crate strict_types;
26
27mod cfa;
28mod nia;
29mod pfa;
30mod uda;
31mod ifa;
32
33pub use cfa::{CfaWrapper, CollectibleFungibleAsset, CFA_SCHEMA_ID};
34pub use ifa::{IfaWrapper, InflatableFungibleAsset, IFA_SCHEMA_ID};
35pub use nia::{NiaWrapper, NonInflatableAsset, NIA_SCHEMA_ID};
36pub use pfa::{PermissionedFungibleAsset, PfaWrapper, PFA_SCHEMA_ID};
37use rgbstd::{AssignmentType, GlobalStateType, MetaType, TransitionType};
38pub use uda::{UdaWrapper, UniqueDigitalAsset, UDA_SCHEMA_ID};
39
40pub const GS_ART: GlobalStateType = GlobalStateType::with(3000);
41pub const GS_ATTACH: GlobalStateType = GlobalStateType::with(2104);
42pub const GS_REJECT_LIST_URL: GlobalStateType = GlobalStateType::with(2012);
43pub const GS_DETAILS: GlobalStateType = GlobalStateType::with(3004);
44pub const GS_ENGRAVINGS: GlobalStateType = GlobalStateType::with(2103);
45pub const GS_ISSUED_SUPPLY: GlobalStateType = GlobalStateType::with(2010);
46pub const GS_MAX_SUPPLY: GlobalStateType = GlobalStateType::with(2011);
47pub const GS_NAME: GlobalStateType = GlobalStateType::with(3001);
48pub const GS_NOMINAL: GlobalStateType = GlobalStateType::with(2000);
49pub const GS_PRECISION: GlobalStateType = GlobalStateType::with(3005);
50pub const GS_TERMS: GlobalStateType = GlobalStateType::with(2001);
51pub const GS_TOKENS: GlobalStateType = GlobalStateType::with(2102);
52pub const GS_PUBKEY: GlobalStateType = GlobalStateType::with(3006);
53
54pub const OS_ASSET: AssignmentType = AssignmentType::with(4000);
55pub const OS_INFLATION: AssignmentType = AssignmentType::with(4010);
56pub const OS_REPLACE: AssignmentType = AssignmentType::with(4012);
57
58pub const TS_INFLATION: TransitionType = TransitionType::with(8000);
59pub const TS_BURN: TransitionType = TransitionType::with(8010);
60pub const TS_REPLACE: TransitionType = TransitionType::with(8011);
61pub const TS_TRANSFER: TransitionType = TransitionType::with(10000);
62
63pub const MS_ALLOWED_INFLATION: MetaType = MetaType::with(1000);
64
65pub const ERRNO_NON_EQUAL_IN_OUT: u8 = 0;
66pub const ERRNO_ISSUED_MISMATCH: u8 = 1;
67pub const ERRNO_NON_FRACTIONAL: u8 = 10;
68pub const ERRNO_MISSING_PUBKEY: u8 = 20;
69pub const ERRNO_INVALID_SIGNATURE: u8 = 21;
70pub const ERRNO_INFLATION_MISMATCH: u8 = 30;
71pub const ERRNO_INFLATION_EXCEEDS_ALLOWANCE: u8 = 31;
72pub const ERRNO_REPLACE_NO_INPUT: u8 = 35;
73pub const ERRNO_REPLACE_HIDDEN_BURN: u8 = 36;
74
75pub mod dumb {
76    use rgbstd::validation::{ResolveWitness, WitnessResolverError, WitnessStatus};
77    use rgbstd::{ChainNet, Txid};
78
79    pub struct NoResolver;
80
81    impl ResolveWitness for NoResolver {
82        fn resolve_witness(&self, _: Txid) -> Result<WitnessStatus, WitnessResolverError> {
83            unreachable!()
84        }
85
86        fn check_chain_net(&self, _: ChainNet) -> Result<(), WitnessResolverError> {
87            unreachable!()
88        }
89    }
90}