From 2315c1f310732608a642059e64f2115e3e676305 Mon Sep 17 00:00:00 2001 From: Armando Dutra Date: Mon, 15 Jan 2024 02:31:53 -0300 Subject: [PATCH] feat: add udc schema impl --- Cargo.lock | 260 ++++++++++++-------- Cargo.toml | 7 + examples/rgb20.rs | 4 +- examples/rgb21.rs | 98 +++++++- examples/rgb25.rs | 4 +- schemata/UniqueDigitalAsset-RGB21.rgb | Bin 196 -> 196 bytes schemata/UniqueDigitalAsset-RGB21.rgba | 8 +- schemata/UniqueDigitalAsset.rgb | Bin 11072 -> 11079 bytes schemata/UniqueDigitalAsset.rgba | 16 +- schemata/UniqueDigitalCollection-RGB21.rgb | Bin 0 -> 196 bytes schemata/UniqueDigitalCollection-RGB21.rgba | 12 + schemata/UniqueDigitalCollection.rgb | Bin 0 -> 11135 bytes schemata/UniqueDigitalCollection.rgba | 223 +++++++++++++++++ src/lib.rs | 2 + src/main.rs | 16 +- src/uda.rs | 27 +- src/udc.rs | 223 +++++++++++++++++ 17 files changed, 755 insertions(+), 145 deletions(-) create mode 100644 schemata/UniqueDigitalCollection-RGB21.rgb create mode 100644 schemata/UniqueDigitalCollection-RGB21.rgba create mode 100644 schemata/UniqueDigitalCollection.rgb create mode 100644 schemata/UniqueDigitalCollection.rgba create mode 100644 src/udc.rs diff --git a/Cargo.lock b/Cargo.lock index b0eaba3..41838f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,8 +5,7 @@ version = 3 [[package]] name = "aluvm" version = "0.11.0-beta.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e10be187b383247e1902aa5a415f76ffc9a04f197829c46b9ccb6da3582e394f" +source = "git+https://github.com/AluVM/rust-aluvm?branch=master#3e9bcfbc00b72dbc23a0538230a452bb338190d1" dependencies = [ "amplify", "baid58", @@ -146,9 +145,9 @@ checksum = "6107fe1be6682a68940da878d9e9f5e90ca5745b3dec9fd1bb393c8777d4f581" [[package]] name = "base64" -version = "0.21.5" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base85" @@ -224,7 +223,19 @@ dependencies = [ "amplify", "chrono", "commit_verify", - "secp256k1 0.28.0", + "secp256k1", + "strict_encoding", +] + +[[package]] +name = "bp-consensus" +version = "0.11.0-beta.3" +source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#d90f5774e3b8d41cb97bb2f1113d8c00351d2291" +dependencies = [ + "amplify", + "chrono", + "commit_verify", + "secp256k1", "serde", "strict_encoding", "strict_types", @@ -233,31 +244,31 @@ dependencies = [ [[package]] name = "bp-core" version = "0.11.0-beta.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69269d27e32d784e37f7ca7cdf964fe5e30c5bff1ca2e229a118c84c8efdd179" +source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#d90f5774e3b8d41cb97bb2f1113d8c00351d2291" dependencies = [ "amplify", - "bp-consensus", + "bp-consensus 0.11.0-beta.3 (git+https://github.com/BP-WG/bp-core?branch=v0.11)", "bp-dbc", "bp-seals", "commit_verify", + "getrandom", "serde", "single_use_seals", "strict_encoding", "strict_types", + "wasm-bindgen", ] [[package]] name = "bp-dbc" version = "0.11.0-beta.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cef9a98c7ae4f1bb333ad8e55c9d8a91f071c347d35b62e19959faa07572b11" +source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#d90f5774e3b8d41cb97bb2f1113d8c00351d2291" dependencies = [ "amplify", "base85", - "bp-consensus", + "bp-consensus 0.11.0-beta.3 (git+https://github.com/BP-WG/bp-core?branch=v0.11)", "commit_verify", - "secp256k1 0.28.0", + "secp256k1", "serde", "strict_encoding", ] @@ -271,18 +282,17 @@ dependencies = [ "amplify", "bech32", "bitcoin_hashes", - "bp-consensus", + "bp-consensus 0.11.0-beta.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "bp-seals" version = "0.11.0-beta.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d211bb77e320abf4bba6c272fc85d73e5203140ca39e299271f4714d8b6029fe" +source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#d90f5774e3b8d41cb97bb2f1113d8c00351d2291" dependencies = [ "amplify", "baid58", - "bp-consensus", + "bp-consensus 0.11.0-beta.3 (git+https://github.com/BP-WG/bp-core?branch=v0.11)", "bp-dbc", "commit_verify", "rand", @@ -329,7 +339,7 @@ dependencies = [ "js-sys", "num-traits", "wasm-bindgen", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -375,9 +385,9 @@ checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] @@ -435,9 +445,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "js-sys", @@ -475,9 +485,9 @@ checksum = "30ed443af458ccb6d81c1e7e661545f94d3176752fb1df2f543b902a1e0f51e2" [[package]] name = "iana-time-zone" -version = "0.1.58" +version = "0.1.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -514,9 +524,9 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "js-sys" -version = "0.3.66" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" dependencies = [ "wasm-bindgen", ] @@ -529,9 +539,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.151" +version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "log" @@ -596,18 +606,18 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.71" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -645,8 +655,7 @@ dependencies = [ [[package]] name = "rgb-core" version = "0.11.0-beta.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb0581f9bc33b509400aa9225d2308dfd45af413a4fe38f7c4b823a7e09e6036" +source = "git+https://github.com/crisdut/rgb-core?branch=feat/udc#bc308410cc175888ca9944257b09b3bf8a861dcd" dependencies = [ "aluvm", "amplify", @@ -666,8 +675,7 @@ dependencies = [ [[package]] name = "rgb-invoice" version = "0.11.0-beta.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4898f1ca45d70ed18f3f1977ef35ffe8ee35870c982ad9fb842a6fbaeb512490" +source = "git+https://github.com/RGB-WG/rgb-std?branch=v0.11#3e1e4177dc50c14d815ee011df34e557cac9787b" dependencies = [ "amplify", "baid58", @@ -702,8 +710,7 @@ dependencies = [ [[package]] name = "rgb-std" version = "0.11.0-beta.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bc24f24f2e942d1c20f46a68b331d7864fbdf94ab334c6fac20840816d30a54" +source = "git+https://github.com/RGB-WG/rgb-std?branch=v0.11#3e1e4177dc50c14d815ee011df34e557cac9787b" dependencies = [ "amplify", "baid58", @@ -739,92 +746,72 @@ checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "secp256k1" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" -dependencies = [ - "rand", - "secp256k1-sys 0.8.1", - "serde", -] - -[[package]] -name = "secp256k1" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2acea373acb8c21ecb5a23741452acd2593ed44ee3d343e72baaa143bc89d0d5" +checksum = "3f622567e3b4b38154fb8190bcf6b160d7a4301d70595a49195b48c116007a27" dependencies = [ "rand", - "secp256k1-sys 0.9.1", + "secp256k1-sys", "serde", ] [[package]] name = "secp256k1-sys" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" -dependencies = [ - "cc", -] - -[[package]] -name = "secp256k1-sys" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dd97a086ec737e30053fd5c46f097465d25bb81dd3608825f65298c4c98be83" +checksum = "e5d1746aae42c19d583c3c1a8c646bfad910498e2051c551a7f2e3c0c9fbb7eb" dependencies = [ "cc", ] [[package]] name = "secp256k1-zkp" -version = "0.9.2" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "026efcdacb95ee6aae5cc19144dc1549973eac36a4972700c28493de1ee5d69f" +checksum = "c4e48ef9c98bfbcb98bd15693ffa19676cb3e29426b75eda8b73c05cdd7959f8" dependencies = [ "bitcoin-private", "rand", - "secp256k1 0.27.0", + "secp256k1", "secp256k1-zkp-sys", "serde", ] [[package]] name = "secp256k1-zkp-sys" -version = "0.8.1" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d03ab1ca75a18e1899e8d9b8d28b5998ae1ddcb42fec5956769718543293c723" +checksum = "b4ead52f43074bae2ddbd1e0e66e6b170135e76117f5ea9916f33d7bd0b36e29" dependencies = [ "cc", - "secp256k1-sys 0.8.1", + "secp256k1-sys", ] [[package]] name = "serde" -version = "1.0.193" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" dependencies = [ "itoa", "ryu", @@ -852,9 +839,9 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.9.29" +version = "0.9.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15e0ef66bf939a7c890a0bf6d5a733c70202225f9888a89ed5c62298b019129" +checksum = "b1bf28c79a99f70ee1f1d83d10c875d2e70618417fda01ad1785e027579d9d38" dependencies = [ "indexmap", "itoa", @@ -950,9 +937,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.43" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -961,22 +948,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.52" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a48fd946b02c0a526b2e9481c8e2a17755e47039164a86c4070446e3a4614d" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.52" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7fbe9b594d6568a6a1443250a7e67d80b74e1e96f6d1715e1e21cc1888291d3" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -1045,9 +1032,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1055,24 +1042,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1080,30 +1067,30 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" +checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" [[package]] name = "windows-core" -version = "0.51.1" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets", + "windows-targets 0.52.0", ] [[package]] @@ -1112,13 +1099,28 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] @@ -1127,47 +1129,89 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "winnow" -version = "0.5.31" +version = "0.5.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97a4882e6b134d6c28953a387571f1acdd3496830d5e36c5e3a1075580ea641c" +checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 1bdbc02..e9f5bbe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,3 +29,10 @@ serde_yaml = "0.9.27" [features] all=[] + + +[patch.crates-io] +aluvm = { git = "https://github.com/AluVM/rust-aluvm", branch = "master" } +rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "v0.11" } +bp-core = { git = "https://github.com/BP-WG/bp-core", branch = "v0.11" } +rgb-core = { git = "https://github.com/crisdut/rgb-core", branch = "feat/udc" } \ No newline at end of file diff --git a/examples/rgb20.rs b/examples/rgb20.rs index 62c6c6f..98088bc 100644 --- a/examples/rgb20.rs +++ b/examples/rgb20.rs @@ -94,8 +94,8 @@ fn main() { eprintln!("\nThe issued contract data:"); eprintln!("{}", serde_json::to_string(&contract.spec()).unwrap()); - for FungibleAllocation { owner, witness, value } in allocations { - eprintln!("amount={value}, owner={owner}, witness={witness}"); + for FungibleAllocation { seal, state, witness, .. } in allocations { + eprintln!("amount={}, owner={seal}, witness={witness}", state.value()); } eprintln!("totalSupply={}", contract.total_supply()); eprintln!("created={}", contract.created().to_local().unwrap()); diff --git a/examples/rgb21.rs b/examples/rgb21.rs index 23e2906..9492570 100644 --- a/examples/rgb21.rs +++ b/examples/rgb21.rs @@ -5,7 +5,7 @@ use amplify::confinement::SmallBlob; use amplify::hex::FromHex; use amplify::Wrapper; use bp::Txid; -use rgb_schemata::{uda_rgb21, uda_schema}; +use rgb_schemata::{uda_rgb21, uda_schema, udc_schema, udc_rgb21}; use rgbstd::containers::BindleContent; use rgbstd::interface::rgb21::{Allocation, EmbeddedMedia, OwnedFraction, TokenData, TokenIndex}; use rgbstd::interface::{rgb21, ContractBuilder}; @@ -32,8 +32,7 @@ impl ResolveHeight for DumbResolver { } } -#[rustfmt::skip] -fn main() { +fn uda() { let spec = DivisibleAssetSpec::new("TEST", "Test uda", Precision::Indivisible); let terms = RicardianContract::default(); let created = Timestamp::now(); @@ -42,7 +41,7 @@ fn main() { let beneficiary = XChain::Bitcoin(GenesisSeal::tapret_first_rand(beneficiary_txid, 1)); let fraction = OwnedFraction::from_inner(1); - let index = TokenIndex::from_inner(2); + let index = TokenIndex::from_inner(1); let preview = EmbeddedMedia { ty: stl::MediaType::with("text/*"), @@ -50,8 +49,8 @@ fn main() { }; let token_data = TokenData { index, preview: Some(preview), ..Default::default() }; - let allocation = Allocation::with(index, fraction); + let contract = ContractBuilder::testnet( rgb21(), uda_schema(), @@ -82,8 +81,8 @@ fn main() { let bindle = contract.bindle(); eprintln!("{bindle}"); - bindle.save("examples/rgb21-simplest.contract.rgb").expect("unable to save contract"); - fs::write("examples/rgb21-simplest.contract.rgba", bindle.to_string()).expect("unable to save contract"); + bindle.save("examples/rgb21-uda.rgb").expect("unable to save contract"); + fs::write("examples/rgb21-uda.rgba", bindle.to_string()).expect("unable to save contract"); // Let's create some stock - an in-memory stash and inventory around it: let mut stock = Stock::default(); @@ -105,3 +104,88 @@ fn main() { let nominal = contract.global("spec").unwrap(); eprintln!("{}", nominal[0]); } + +fn udc() { + let spec = DivisibleAssetSpec::new("TEST", "Test udc", Precision::Indivisible); + let terms = RicardianContract::default(); + let created = Timestamp::now(); + let beneficiary_txid = + Txid::from_hex("14295d5bb1a191cdb6286dc0944df938421e3dfcbf0811353ccac4100c2068c5").unwrap(); + let beneficiary = XChain::Bitcoin(GenesisSeal::tapret_first_rand(beneficiary_txid, 1)); + + let fraction = OwnedFraction::from_inner(1); + let index = TokenIndex::from_inner(1); + + let token_data_1 = TokenData { index, ..Default::default() }; + let allocation_1 = Allocation::with(index, fraction); + + let index = TokenIndex::from_inner(2); + let token_data_2 = TokenData { index, ..Default::default() }; + let allocation_2 = Allocation::with(index, fraction); + let beneficiary_2 = XChain::Bitcoin(GenesisSeal::tapret_first_rand(beneficiary_txid, 2)); + + let contract = ContractBuilder::testnet( + rgb21(), + udc_schema(), + udc_rgb21(), + ).expect("schema fails to implement RGB21 interface") + + .add_global_state("tokens", token_data_1) + .expect("invalid token data") + + .add_global_state("tokens", token_data_2) + .expect("invalid token data") + + .add_global_state("spec", spec) + .expect("invalid nominal") + + .add_global_state("created", created) + .expect("invalid creation date") + + .add_global_state("terms", terms) + .expect("invalid contract text") + + .add_data("assetOwner", beneficiary, allocation_1) + .expect("invalid asset blob") + + .add_data("assetOwner", beneficiary_2, allocation_2) + .expect("invalid asset blob") + + .issue_contract() + .expect("contract doesn't fit schema requirements"); + eprintln!("{}", serde_yaml::to_string(&contract.genesis).unwrap()); + + let contract_id = contract.contract_id(); + debug_assert_eq!(contract_id, contract.contract_id()); + + let bindle = contract.bindle(); + eprintln!("{bindle}"); + bindle.save("examples/rgb21-udc.rgb").expect("unable to save contract"); + fs::write("examples/rgb21-udc.rgba", bindle.to_string()).expect("unable to save contract"); + + // Let's create some stock - an in-memory stash and inventory around it: + let mut stock = Stock::default(); + stock.import_iface(rgb21()).unwrap(); + stock.import_schema(udc_schema()).unwrap(); + stock.import_iface_impl(udc_rgb21()).unwrap(); + + // Noe we verify our contract consignment and add it to the stock + let verified_contract = match bindle.unbindle().validate(&mut DumbResolver, true) { + Ok(consignment) => consignment, + Err(consignment) => { + panic!("can't produce valid consignment. Report: {}", consignment.validation_status().expect("status always present upon validation")); + } + }; + stock.import_contract(verified_contract, &mut DumbResolver).unwrap(); + + // Reading contract state through the interface from the stock: + let contract = stock.contract_iface_id(contract_id, rgb21().iface_id()).unwrap(); + let nominal = contract.global("spec").unwrap(); + eprintln!("{}", nominal[0]); +} + +#[rustfmt::skip] +fn main() { + uda(); + udc(); +} diff --git a/examples/rgb25.rs b/examples/rgb25.rs index 6f54d13..9ac53da 100644 --- a/examples/rgb25.rs +++ b/examples/rgb25.rs @@ -116,7 +116,7 @@ fn main() { let allocations = contract.fungible("assetOwner", &FilterIncludeAll).unwrap(); eprintln!("{}", Name::from_strict_val_unchecked(&name[0])); - for FungibleAllocation { owner, witness, value } in allocations { - eprintln!("(amount={value}, owner={owner}, witness={witness})"); + for FungibleAllocation { seal, state, witness, .. } in allocations { + eprintln!("amount={}, owner={seal}, witness={witness}", state.value()); } } diff --git a/schemata/UniqueDigitalAsset-RGB21.rgb b/schemata/UniqueDigitalAsset-RGB21.rgb index 68bb705c0187243de81dd8a904fc545619f9d966..a3e0d5a6bd7426c6dfb8821d82973c5efc0c3472 100644 GIT binary patch delta 80 zcmV-W0I&bV0mK1FQb$5bO;Ai@{i-E3#(^91=$RG9^l}s{lQt5?Yk8)^XUIOnOsb0j m$_hWH7`_EDzk}3nYmRPael`;GpeOfTmYcrHHK*^6kw|=?-X(_s delta 80 zcmV-W0I&bV0mK1FQb$5bO;Aj;j+!Kf4|p||+MQD~&@6E+Wd^=f*l%c#86|N1Uc18p mxjLMj;xnWs%a&@~&RDzQ-v&#v-Ob}CNAF69@Ua0U2Cd-y;+|F3L;ok;Jvfa(&Cr9r}hw!lhP;KwKhUh!fbn@NR0#zSot#D$ +0LltKrx?BkF~5VQc05cy$lWQ}*~9k~m;G{yeXNH2o3G?$_vNM4nF)Pfp#D8}+U$L&Oqaj!Td1y8 zZ@hg<{602Eb*sd9$)8`2PWI_?WlZ*W{%pj@vd*bYNpvHFfTK^Sf>VHtr@L!#hyu`P ze+F&_28I)6910BFjEoGHjEtg897h-MD}b3?9FmNV%-ReF49pA~3_umyU}0_!Zf0Eu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02crU3jqKC#h?!$00IR7OaK4?0CZ?&AYp85Z)0I}Wn>_9Z) +;_4AZTH8AYpDGX>N95Y-wa5X>Md?cmx0e000000001QcWz~5AZBu5V{~b6ZXjuMA +Z~ATATa;}00000Gq;pqz6L=jI$>WK`Sit;Oo~MTV^2f#G7bc;LUtk*0003HCo{K{ +U%m!GCpuwY8Ts_ZlT3<50b@@?^D+(uu0nPq6+-| -----END RGB SCHEMA----- diff --git a/schemata/UniqueDigitalCollection-RGB21.rgb b/schemata/UniqueDigitalCollection-RGB21.rgb new file mode 100644 index 0000000000000000000000000000000000000000..a8158eea07f2adef58b61b563d73dfd00fd02527 GIT binary patch literal 196 zcmWG?ck=WN@Hyu2gh7S#T#E88 zv@5$ErhdBp;TB)X>J_KdcUM3BT#@d#N`xc#{qD9G)|X2@-Mz{bDxbEtAnCZv&tLvQ z<@eMWn}1G_Wx2r4Qe2Rl%m4(J+1ZneQWHy3Q$RdZ4%U*?qTFH-+l+&)BtJVf56od) hz|WOfT%20sU!Ip*1d?W86j0{~DN4*MPJ;@7MFGUmNrwOc literal 0 HcmV?d00001 diff --git a/schemata/UniqueDigitalCollection-RGB21.rgba b/schemata/UniqueDigitalCollection-RGB21.rgba new file mode 100644 index 0000000..cd25832 --- /dev/null +++ b/schemata/UniqueDigitalCollection-RGB21.rgba @@ -0,0 +1,12 @@ +-----BEGIN RGB INTERFACE IMPLEMENTATION----- +Id: ELu7bg-E5Vcg7zv-rHaSFmvq-6oGAcJH2-SjPKacaK-6bDEut +Mnemonic: comedy-store-precise +IfaceId: 8Q9TfV-aJtgbWFw-entqAA5f-7hYUGjG4-xaAD9eo6-hmcfnU +SchemaId: G6NzKm-baasi49K-sYEBUjPh-ZFBxCE9R-6kXa7RGL-hLZPeX + +0N_9o`qea_X4JbtmGay0+75K9sLCh1d*SnVXHKdV2yO4XhUh!fbn@NR0#zSot#D$ +;MEUwpQg_}a0fYIF9R$z^1aoj@V*mgE0MiEtV{&C-bY)}!0000r2nBRya&2<}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C|?HWCN2ZxANO#%$RVL44jU1=oA4@F z&Ls*rA5VFGeKX_hkw1$r4CP7TwvUAekODqYv`KVsM*&1B)n3!KC#hTgK>XvbLpn5a z(OHj5gNI-5t!eK3yxc7{{T-}87FkG8Jqrn{XCXoLEF`F&g#^{Jkf3@N5>(GZg6dgF zP(2F?s)zRyqk1?Iqk1?Iqk1?Iqk1?Iqk1^8lqYm9-<4-Qw{fp(ntbZ+Ew<6VJl35N zxGZIvb0lh*VRe3emtsX?d5-H~OXuxddzHF3_Qn_ow~q+qE?r8w+z=nO(3^||QveZW zM|27fkq`W0vp{)quDbo61EODcXW+chWB7PTF1w{=- z2CNR5;2JW3AYFw~8Jx<{4Ip(o2@Zjpt?15>444Vol7K3Su0)r*Tqf^=*BD4@r0E*K z1&)Gr>3}o?7cvXNGc_6DFKLva%fNw<24KSJcvA$V20qMBS76;*p6~yn3u3exVNUg?E=gN@HTk_^r>e aN07?L-<&|C7+hSU0ArYrwG$}~7x8aNCylHC literal 0 HcmV?d00001 diff --git a/schemata/UniqueDigitalCollection.rgba b/schemata/UniqueDigitalCollection.rgba new file mode 100644 index 0000000..321f64c --- /dev/null +++ b/schemata/UniqueDigitalCollection.rgba @@ -0,0 +1,223 @@ +-----BEGIN RGB SCHEMA----- +Id: G6NzKm-baasi49K-sYEBUjPh-ZFBxCE9R-6kXa7RGL-hLZPeX +Mnemonic: russian-brigade-connect + +00005&GeDc&U6LW +M=Z%kHl1Lr^AU8_q1nt3mm+Ou>dWHc2H3%5Xly4G~&lnD!c-+QY#hXVj|NgD}^^L +KZ%!4TQO924@HVA9y+&Mb7##>0_l|s!OiYLkig!L_&65bVw0hhY!i{StNI0y)5RP ++~#!?`sQG&9**s!UWt84JRg;mFaa?UKHXR)hfn0iX{87;x>&>|_U&vjjD4#axh{f +Bik-QrJv$@`YYkgS*{X0N6ji;4cm3v~2hf;U4$>@L|V|mt8Tf>F%PuK$$b1Yz5E< +0RRC2(+2?n0RS}!0RRC2HV6R#|Nl4$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Result<()> { nia()?; uda()?; cfa()?; + udc()?; Ok(()) } @@ -74,6 +75,19 @@ fn uda() -> io::Result<()> { Ok(()) } +fn udc() -> io::Result<()> { + let schema_bindle = udc_schema().bindle(); + schema_bindle.save("schemata/UniqueDigitalCollection.rgb")?; + fs::write("schemata/UniqueDigitalCollection.rgba", schema_bindle.to_string())?; + print_lib(&schema_bindle); + + let iimpl_bindle = udc_rgb21().bindle(); + iimpl_bindle.save("schemata/UniqueDigitalCollection-RGB21.rgb")?; + fs::write("schemata/UniqueDigitalCollection-RGB21.rgba", iimpl_bindle.to_string())?; + + Ok(()) +} + fn cfa() -> io::Result<()> { let schema_bindle = cfa_schema().bindle(); schema_bindle.save("schemata/CollectibleFungibleAssets.rgb")?; diff --git a/src/uda.rs b/src/uda.rs index 7f39ae4..6ef5227 100644 --- a/src/uda.rs +++ b/src/uda.rs @@ -30,7 +30,6 @@ use rgbstd::schema::{ TransitionSchema, }; use rgbstd::stl::StandardTypes; -use rgbstd::vm::opcodes::INSTR_LDP; use rgbstd::vm::{AluScript, EntryPoint, RgbIsa}; use rgbstd::{rgbasm, GlobalStateType}; use strict_types::{SemId, Ty}; @@ -48,9 +47,9 @@ pub fn uda_schema() -> SubSchema { let code = rgbasm! { // SUBROUTINE 1: genesis validation - // TODO: Use index for global state from register // Read global state into s[1] - ldg 0x0836,0,s16[1] ; + put a8[0],0x00 ; + ldg 0x0836,a8[0],s16[1] ; // Put 0 to a16[0] put a16[0],0x00 ; // Extract 128 bits from the beginning of s[1] into r128[1] @@ -58,7 +57,7 @@ pub fn uda_schema() -> SubSchema { // a32[0] now has token index from global state spy a32[0],r128[1] ; // Read owned state into s[1] - lds 0x0FA0,0,s16[1] ; + lds 0x0FA0,a16[0],s16[1] ; // Extract 128 bits from the beginning of s[1] into r128[1] extr s16[1],r128[1],a16[0] ; // a32[1] now has token index from allocation @@ -66,13 +65,13 @@ pub fn uda_schema() -> SubSchema { // check that token indexes match eq.n a32[0],a32[1] ; // if they do, jump to the next check - jif 0x0028 ; + jif 0x002B ; // we need to put a string into first string register which will be used as an error // message put s16[0],"the allocated token has an invalid index"; // fail otherwise fail ; - // offset_0x28: + // offset_0x2B (pos 43): // Put 4 to a16[0] put a16[0],4 ; // Extract 128 bits starting from the fifth byte of s[1] into r128[0] @@ -87,19 +86,21 @@ pub fn uda_schema() -> SubSchema { put s16[0],"owned fraction is not 1"; ret ; // SUBROUTINE 2: transfer validation - // offset_0x40: + // offset_0x43 (pos 67): + // Put 0 to a16[0] + put a16[0],0 ; // Read previous state into s[1] - ldp 0x0FA0,0,s16[1] ; + ldp 0x0FA0,a16[0],s16[1] ; // jump into SUBROUTINE 1 to reuse the code jmp 0x0005 ; }; let alu_lib = Lib::assemble::>(&code).unwrap(); let alu_id = alu_lib.id(); - const FN_GENESIS_OFFSET: u16 = 0; - const FN_TRANSFER_OFFSET: u16 = 0x40; - assert_eq!(alu_lib.code.as_ref()[0x05], INSTR_PUTA); - assert_eq!(alu_lib.code.as_ref()[0x28], INSTR_PUTA); - assert_eq!(alu_lib.code.as_ref()[FN_TRANSFER_OFFSET as usize], INSTR_LDP); + const FN_GENESIS_OFFSET: u16 = 0x00; + const FN_TRANSFER_OFFSET: u16 = 0x43; + assert_eq!(alu_lib.code.as_ref()[0x00], INSTR_PUTA); + assert_eq!(alu_lib.code.as_ref()[0x2B], INSTR_PUTA); + assert_eq!(alu_lib.code.as_ref()[FN_TRANSFER_OFFSET as usize], INSTR_PUTA); Schema { ffv: zero!(), diff --git a/src/udc.rs b/src/udc.rs new file mode 100644 index 0000000..f6946f5 --- /dev/null +++ b/src/udc.rs @@ -0,0 +1,223 @@ +// RGB schemata by LNP/BP Standards Association +// +// SPDX-License-Identifier: Apache-2.0 +// +// Written in 2023 by +// Dr Maxim Orlovsky +// +// Copyright (C) 2023 LNP/BP Standards Association. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Unique digital asset (UDA) schema implementing RGB21 NFT interface. + +// use aluvm::isa::opcodes::INSTR_PUTA; +use aluvm::isa::Instr; +use aluvm::library::{Lib, LibSite}; +// use aluvm::reg::Reg32; +use rgbstd::interface::{rgb21, rgb21_stl, IfaceImpl, NamedField, NamedType, VerNo}; +use rgbstd::schema::{ + GenesisSchema, GlobalStateSchema, Occurrences, Schema, Script, StateSchema, SubSchema, + TransitionSchema, +}; +use rgbstd::stl::StandardTypes; +// use rgbstd::vm::opcodes::INSTR_LDP; +use rgbstd::vm::{AluScript, EntryPoint, RgbIsa}; +use rgbstd::{rgbasm, GlobalStateType}; +use strict_types::{SemId, Ty}; + +use crate::{GS_NOMINAL, GS_TIMESTAMP, OS_ASSET, TS_TRANSFER}; + +const GS_CONTRACT: GlobalStateType = GlobalStateType::with(2101); +const GS_TOKENS: GlobalStateType = GlobalStateType::with(2102); +#[allow(dead_code)] +const GS_ENGRAVINGS: GlobalStateType = GlobalStateType::with(2103); +const GS_ATTACH: GlobalStateType = GlobalStateType::with(2104); + +pub fn udc_schema() -> SubSchema { + let types = StandardTypes::with(rgb21_stl()); + + let code = rgbasm! { + // SUBROUTINE 1: genesis validation + // Num. tokens in global state into a8[2] + cng 0x0836,a8[2] ; + // Num. tokens in contract state into a16[0] + cnc 0x0FA0,a16[0] ; + cnv a8[2],a16[2] ; + eq.n a16[2],a16[0] ; + // if they do, jump to the next check + jif 0x0018 ; + // we need to put a string into first string register which will be used as an error + // message + put s16[0],"token index and allocations need parity"; + fail ; + // offset_0x18 (pos 24): + // Sub 0x1 to a[1] for access global states as array + sub a8[2],0x1 ; + // Put 0x0 to a[0] for iterate global states + put a8[0],0x0 ; + // offset 0x001F (pos 31): + // Put 0x0 to a[0] for iterate contract states + put a8[1],0x0 ; + // offset 0x0023 (pos 35) + // check that token global state is less then contract state + gt.u a8[1],a8[2] ; + // if they do, jump to the next check + jif 0x0057 ; + // Read global state with index a[0] into s[1] + ldg 0x0836,a8[0],s16[2] ; + // Put 0 to a16[0] for offset global state data + put a16[0],0x00 ; + // Extract 128 bits from the beginning of s[1] into r128[1] + extr s16[2],r128[1],a16[0] ; + // a32[0] now has token index from global state + spy a32[0],r128[1] ; + // Read owned state with index a[0] into s[0] + cnv a8[1],a16[1] ; + // Read contract state with index a[1] into s[2] + lds 0x0FA0,a16[1],s16[2] ; + // Put 0 to a16[0] for offset global state data + put a16[0],0x00 ; + // Extract 128 bits from the beginning of s[1] into r128[1] + extr s16[2],r128[1],a16[0] ; + // a32[1] now has token index from allocation + spy a32[1],r128[1] ; + // check that token indexes match + eq.n a32[0],a32[1] ; + // if they do, jump to the next check + jif 0x005E ; + // if not, inc +1 in contract state count + add a8[1],0x1 ; + jmp 0x0023 ; + // offset_0x0057 (pos 87): + // we need to put a string into first string register which will be used as an error + // message + put s16[0],"the allocated token has an invalid index"; + fail ; + // offset_0x005E (pos 94): + // Put 4 to a16[0] + put a16[0],4 ; + // Extract 128 bits starting from the fifth byte of s[1] into r128[0] + extr s16[2],r128[1],a16[0] ; + // a64[1] now has owned fraction + spy a64[1],r128[1] ; + // put 1 to a64[0] + put a64[0],1 ; + // check that owned fraction == 1 + eq.n a64[0],a64[1] ; + // if yes, jump to next verification + jif 0x0079 ; + // terminate the subroutine + put s16[0],"owned fraction is not 1"; + fail ; + // offset_0x0079 (pos 121): + // do we check all tokens? + eq.n a8[2],a8[0] ; + // if yes, jump to next finish program + jif 0x0085 ; + // if no, iterate next token index + add a8[0],0x1 ; + jmp 0x001F ; + // offset_0x0085 (pos 133): + // terminate the subroutine + ret ; + + }; + + let alu_lib = Lib::assemble::>(&code).unwrap(); + let alu_id = alu_lib.id(); + const FN_GENESIS_OFFSET: u16 = 0; + // const FN_TRANSFER_OFFSET: u16 = 0x40; + // assert_eq!(alu_lib.code.as_ref()[0x05], INSTR_PUTA); + // assert_eq!(alu_lib.code.as_ref()[0x28], INSTR_PUTA); + // assert_eq!(alu_lib.code.as_ref()[FN_TRANSFER_OFFSET as usize], INSTR_LDP); + + Schema { + ffv: zero!(), + subset_of: None, + type_system: types.type_system(), + global_types: tiny_bmap! { + GS_NOMINAL => GlobalStateSchema::once(types.get("RGBContract.DivisibleAssetSpec")), + GS_CONTRACT => GlobalStateSchema::once(types.get("RGBContract.RicardianContract")), + GS_TIMESTAMP => GlobalStateSchema::once(types.get("RGBContract.Timestamp")), + GS_TOKENS => GlobalStateSchema::many(types.get("RGB21.TokenData")), + GS_ATTACH => GlobalStateSchema::once(types.get("RGB21.AttachmentType")), + }, + owned_types: tiny_bmap! { + OS_ASSET => StateSchema::Structured(types.get("RGB21.Allocation")), + }, + valency_types: none!(), + genesis: GenesisSchema { + metadata: Ty::::UNIT.id(None), + globals: tiny_bmap! { + GS_NOMINAL => Occurrences::Once, + GS_CONTRACT => Occurrences::Once, + GS_TIMESTAMP => Occurrences::Once, + GS_TOKENS => Occurrences::OnceOrMore, + GS_ATTACH => Occurrences::NoneOrOnce, + }, + assignments: tiny_bmap! { + OS_ASSET => Occurrences::OnceOrMore, + }, + valencies: none!(), + }, + extensions: none!(), + transitions: tiny_bmap! { + TS_TRANSFER => TransitionSchema { + metadata: Ty::::UNIT.id(None), + globals: none!(), + inputs: tiny_bmap! { + OS_ASSET => Occurrences::OnceOrMore + }, + assignments: tiny_bmap! { + OS_ASSET => Occurrences::OnceOrMore + }, + valencies: none!(), + } + }, + script: Script::AluVM(AluScript { + libs: confined_bmap! { alu_id => alu_lib }, + entry_points: confined_bmap! { + EntryPoint::ValidateGenesis => LibSite::with(FN_GENESIS_OFFSET, alu_id), + // EntryPoint::ValidateTransition(TS_TRANSFER) => LibSite::with(FN_TRANSFER_OFFSET, alu_id), + }, + }), + } +} + +pub fn udc_rgb21() -> IfaceImpl { + let schema = udc_schema(); + let iface = rgb21(); + + IfaceImpl { + version: VerNo::V1, + schema_id: schema.schema_id(), + iface_id: iface.iface_id(), + script: none!(), + global_state: tiny_bset! { + NamedField::with(GS_NOMINAL, fname!("spec")), + NamedField::with(GS_CONTRACT, fname!("terms")), + NamedField::with(GS_TIMESTAMP, fname!("created")), + NamedField::with(GS_TOKENS, fname!("tokens")), + }, + assignments: tiny_bset! { + NamedField::with(OS_ASSET, fname!("assetOwner")), + }, + valencies: none!(), + transitions: tiny_bset! { + NamedType::with(TS_TRANSFER, tn!("Transfer")), + }, + extensions: none!(), + } +} +