Skip to content

Commit

Permalink
rgb21 features
Browse files Browse the repository at this point in the history
  • Loading branch information
jack committed Jun 10, 2024
1 parent 32d85b8 commit 26ea423
Show file tree
Hide file tree
Showing 6 changed files with 479 additions and 3 deletions.
176 changes: 176 additions & 0 deletions interfaces/RGB21.con
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
@version(1)
@id(rgb:ifc:zLZ5H1If-IedNbQ3-kzhoYO1-12djZWD-CHeHlEH-4CjQYM4#quasi-noise-martin)
@developer("ssi:LZS1ux-gjD9nXPF-OcetUUkW-6r3uSCS6-aQhs9W5f-8JE7w")
@timestamp(1711405444)
interface RGB21Base: NamedAsset, NonFungibleToken
global attachmentTypes(*): RGB21.AttachmentType
global spec: RGBContract.AssetSpec
global terms: RGBContract.ContractTerms
global tokens(*): RGB21.TokenData

owned assetOwner(*): RGBContract.Allocation

error fractionOverflow
"the amount of token fractions in outputs exceeds 1"
error invalidAttachmentType
"attachment has a type which is not allowed for the token"
error nonEqualValues
"the sum of spent token fractions doesn't equal to the sum of token fractions in outputs"
error nonFractionalToken
"attempt to transfer a fraction of non-fractionable token"
error unknownToken
"allocation of unknown token ID"

genesis: abstract
errors: fractionOverflow, invalidAttachmentType, unknownToken
globals: attachmentTypes(*), spec, terms, tokens(*)
assigns: assetOwner(*)

transition transfer: required, default, final
errors: fractionOverflow, nonEqualValues, nonFractionalToken, unknownToken
assigns: assetOwner(+)
default: assetOwner
inputs: assetOwner(+)


@version(1)
@id(rgb:ifc:3AEpY1Iv-Ybh$o5x-yJRdQjA-dmwy3@b-Rx5XZUI-8yldqFg#brazil-graph-license)
@developer("ssi:LZS1ux-gjD9nXPF-OcetUUkW-6r3uSCS6-aQhs9W5f-8JE7w")
@timestamp(1711405444)
interface RGB21Renamable: NamedAsset, NonFungibleToken, RGB21Base, RenameableAsset
global attachmentTypes(*): RGB21.AttachmentType
global spec: RGBContract.AssetSpec
global terms: RGBContract.ContractTerms
global tokens(*): RGB21.TokenData

owned assetOwner(*): RGBContract.Allocation
public updateRight: Rights

error fractionOverflow
"the amount of token fractions in outputs exceeds 1"
error invalidAttachmentType
"attachment has a type which is not allowed for the token"
error nonEqualValues
"the sum of spent token fractions doesn't equal to the sum of token fractions in outputs"
error nonFractionalToken
"attempt to transfer a fraction of non-fractionable token"
error unknownToken
"allocation of unknown token ID"

genesis: abstract
errors: fractionOverflow, invalidAttachmentType, unknownToken
globals: attachmentTypes(*), spec, terms, tokens(*)
assigns: assetOwner(*), updateRight

transition rename: required, final
globals: spec
assigns: updateRight(?)
default: updateRight
inputs: updateRight

transition transfer: required, default, final
errors: fractionOverflow, nonEqualValues, nonFractionalToken, unknownToken
assigns: assetOwner(+)
default: assetOwner
inputs: assetOwner(+)


@version(1)
@id(rgb:ifc:zaiUh27F-2cYWfcd-FfL5lBc-uUenO66-IYZE0D9-GeVIvGU#forest-heroic-energy)
@developer("ssi:LZS1ux-gjD9nXPF-OcetUUkW-6r3uSCS6-aQhs9W5f-8JE7w")
@timestamp(1711405444)
interface RGB21Unique: NamedAsset, NonFungibleToken, RGB21Base, UniqueNft
global attachmentTypes: RGB21.AttachmentType
global spec: RGBContract.AssetSpec
global terms: RGBContract.ContractTerms
global tokens: RGB21.TokenData

owned assetOwner(+): RGBContract.Allocation

error fractionOverflow
"the amount of token fractions in outputs exceeds 1"
error invalidAttachmentType
"attachment has a type which is not allowed for the token"
error nonEqualValues
"the sum of spent token fractions doesn't equal to the sum of token fractions in outputs"
error nonFractionalToken
"attempt to transfer a fraction of non-fractionable token"
error unknownToken
"allocation of unknown token ID"

genesis: abstract
errors: fractionOverflow, invalidAttachmentType, unknownToken
globals: attachmentTypes, spec, terms, tokens
assigns: assetOwner(+)

transition transfer: required, default, final
errors: fractionOverflow, nonEqualValues, nonFractionalToken, unknownToken
assigns: assetOwner(+)
default: assetOwner
inputs: assetOwner(+)


@version(1)
@id(rgb:ifc:MTbC0xIy-t4kjnRO-6lrefMT-QDDxtSN-SNOHen$-WEeyyfc#cubic-motif-corona)
@developer("ssi:LZS1ux-gjD9nXPF-OcetUUkW-6r3uSCS6-aQhs9W5f-8JE7w")
@timestamp(1711405444)
interface RGB21Issuable: NamedAsset, NonFungibleToken, RGB21Base, RenameableAsset, gBnlwlsh-tuErFnK-EX4V40v-mx1P0OP-orty2gq-10yH4fc#hair-unicorn-initial
, EngravableNft, $@VBEHez-6$MHRU0-kPIulCv-oTDRpmd-OnRANMo-3$Snnng#current-metal-guitar
, IssuableNft
global attachmentTypes(*): RGB21.AttachmentType
global engravings(*): RGB21.EngravingData
global spec: RGBContract.AssetSpec
global terms: RGBContract.ContractTerms
global tokens(*): RGB21.TokenData

owned assetOwner(*): RGBContract.Allocation
public inflationAllowance(+): RGB21.ItemsCount
public updateRight: Rights

error fractionOverflow
"the amount of token fractions in outputs exceeds 1"
error invalidAttachmentType
"attachment has a type which is not allowed for the token"
error issueExceedsAllowance
"you try to issue more assets than allowed by the contract terms"
error nonEngravableToken
"attempt to engrave on a token which prohibit engraving"
error nonEqualValues
"the sum of spent token fractions doesn't equal to the sum of token fractions in outputs"
error nonFractionalToken
"attempt to transfer a fraction of non-fractionable token"
error unknownToken
"allocation of unknown token ID"

genesis: abstract
errors: fractionOverflow, invalidAttachmentType, unknownToken
globals: attachmentTypes(*), spec, terms, tokens(*)
assigns: assetOwner(*), inflationAllowance(+), updateRight

transition engrave: required, final
errors: fractionOverflow, nonEngravableToken, nonEqualValues, nonFractionalToken, unknownToken
globals: engravings
assigns: assetOwner(+)
default: assetOwner
inputs: assetOwner(+)

transition issue: required, abstract
errors: fractionOverflow, invalidAttachmentType, issueExceedsAllowance, unknownToken
globals: attachmentTypes(*), tokens(*)
assigns: assetOwner(*), inflationAllowance(*)
default: assetOwner
inputs: inflationAllowance(+)

transition rename: required, final
globals: spec
assigns: updateRight(?)
default: updateRight
inputs: updateRight

transition transfer: required, default, final
errors: fractionOverflow, nonEqualValues, nonFractionalToken, unknownToken
assigns: assetOwner(+)
default: assetOwner
inputs: assetOwner(+)


16 changes: 16 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,21 @@ fn main() -> io::Result<()> {
writeln!(file, "{}", iface.display(&map, &ifsys)).unwrap();
}

let mut ifaces = vec![rgb21::iface::rgb21_base(), rgb21::iface::rgb21_renamable()];
ifaces.extend(rgb21::Features::ENUMERATE.iter().copied().map(Rgb21::iface));

map.extend(
ifaces
.iter()
.map(|iface| (iface.iface_id(), iface.name.clone())),
);

filename.pop();
filename.push("RGB21.con");
let mut file = fs::File::create(&filename).unwrap();
for iface in ifaces {
writeln!(file, "{}", iface.display(&map, &ifsys)).unwrap();
}

Check warning on line 197 in src/main.rs

View check run for this annotation

Codecov / codecov/patch

src/main.rs#L183-L197

Added lines #L183 - L197 were not covered by tests

Ok(())
}
6 changes: 6 additions & 0 deletions src/rgb21/iface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ use rgbstd::interface::{
use rgbstd::stl::StandardTypes;
use rgbstd::{Identity, Occurrences};

use crate::rgb20::iface::{named_asset, renameable};
use crate::rgb21::wrapper::Rgb21;
use crate::LNPBP_IDENTITY;

pub fn rgb21_base() -> Iface { named_asset().expect_extended(nft(), tn!("RGB21Base")) }
pub fn rgb21_renamable() -> Iface {
rgb21_base().expect_extended(renameable(), tn!("RGB21Renamable"))
}

Check warning on line 36 in src/rgb21/iface.rs

View check run for this annotation

Codecov / codecov/patch

src/rgb21/iface.rs#L33-L36

Added lines #L33 - L36 were not covered by tests

pub fn nft() -> Iface {
let types = StandardTypes::with(Rgb21::stl());
Iface {
Expand Down
Loading

0 comments on commit 26ea423

Please sign in to comment.