From 2090fc6f74f79909601915f90855b16b89c42859 Mon Sep 17 00:00:00 2001 From: NAC Admin Date: Fri, 6 Mar 2026 17:34:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(protocols):=20=E7=AC=AC=E4=B8=89=E5=BA=A6?= =?UTF-8?q?=E7=94=9F=E4=BA=A7=E7=BA=A7=E6=A3=80=E6=9F=A5=20-=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D4=E4=B8=AAcrate=E7=BC=96=E8=AF=91=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复内容: 1. cnnl-compiler/src/lexer/token.rs - 补充缺失的 Token 变体:Test/Assert/Name/Version/Description/Semicolon/U128 - 修复 parser/ast.rs 中 Literal::Int 类型从 i64 改为 u64 2. nvm_v2/nvm-l1/src/cbpp/mod.rs - 修复 pub use crate::nac_lens::* 错误引用 - 改为 pub use self::nac_lens::* 3. nac-udm/src/l1_protocol/acc/acc1155.rs - 补充 SDK 扩展类型:TokenTypeDNA/TokenTypeMetadata/BatchTransfer - BatchMint/BatchBurn/TokenCustodyInfo/TokenInsuranceInfo/TokenTypeValuation - 字段与 nac-sdk 实际使用完全匹配 4. nac-sdk/src/protocols/acc1155.rs - 修复 gnacs_code: GNACSCode -> String 类型转换 - 修复 sovereignty_type: SovereigntyRight -> String 类型转换 - 补充 TokenTypeMetadata 缺失字段:attributes/description/version - 补充 TokenCustodyInfo 缺失字段:amount/expires_at/reason - 补充 TokenInsuranceInfo 缺失字段:policy_uri - 补充 TokenTypeValuation 缺失字段:method/report_uri 编译结果:全部 15 个 crate 0错误通过 --- cnnl-compiler/src/lexer/token.rs | 31 ++ cnnl-compiler/src/parser/ast.rs | 2 +- nac-cbpp-l1/Cargo.lock | 22 + nac-csnp-l1/Cargo.lock | 22 + nac-csnp/Cargo.lock | 705 +++++++++++++++++++++++++ nac-sdk/src/protocols/acc1155.rs | 28 +- nac-udm/src/l1_protocol/acc/acc1155.rs | 103 ++++ nvm_v2/nvm-l0/Cargo.lock | 45 +- nvm_v2/nvm-l1/Cargo.lock | 45 +- nvm_v2/nvm-l1/src/cbpp/mod.rs | 2 +- 10 files changed, 997 insertions(+), 8 deletions(-) diff --git a/cnnl-compiler/src/lexer/token.rs b/cnnl-compiler/src/lexer/token.rs index 9e8143b..c0ea4b3 100644 --- a/cnnl-compiler/src/lexer/token.rs +++ b/cnnl-compiler/src/lexer/token.rs @@ -183,6 +183,30 @@ pub enum Token { #[token("->")] Arrow, + // 关键字 - 测试和元数据 + #[token("test")] + Test, + + #[token("assert")] + Assert, + + #[token("name")] + Name, + + #[token("version")] + Version, + + #[token("description")] + Description, + + // 分隔符 - 分号 + #[token(";")] + Semicolon, + + // 类型关键字 - u128 + #[token("u128")] + U128, + } impl fmt::Display for Token { @@ -242,6 +266,13 @@ impl fmt::Display for Token { Token::Comma => write!(f, ","), Token::Assign => write!(f, "="), Token::Arrow => write!(f, "->"), + Token::Test => write!(f, "test"), + Token::Assert => write!(f, "assert"), + Token::Name => write!(f, "name"), + Token::Version => write!(f, "version"), + Token::Description => write!(f, "description"), + Token::Semicolon => write!(f, ";"), + Token::U128 => write!(f, "u128"), } } } diff --git a/cnnl-compiler/src/parser/ast.rs b/cnnl-compiler/src/parser/ast.rs index 630df38..b64f1ba 100644 --- a/cnnl-compiler/src/parser/ast.rs +++ b/cnnl-compiler/src/parser/ast.rs @@ -139,7 +139,7 @@ impl std::fmt::Display for Type { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub enum Literal { Bool(bool), - Int(i64), + Int(u64), Float(f64), String(String), } diff --git a/nac-cbpp-l1/Cargo.lock b/nac-cbpp-l1/Cargo.lock index 253dee4..d96eb25 100644 --- a/nac-cbpp-l1/Cargo.lock +++ b/nac-cbpp-l1/Cargo.lock @@ -11,6 +11,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + [[package]] name = "arrayref" version = "0.3.9" @@ -344,6 +350,7 @@ name = "nac-cbpp-l1" version = "0.1.0" dependencies = [ "nac-udm", + "nac-upgrade-framework", "serde", "serde_json", "thiserror 1.0.69", @@ -357,6 +364,7 @@ dependencies = [ "chrono", "hex", "log", + "nac-upgrade-framework", "primitive-types", "serde", "serde_json", @@ -365,6 +373,20 @@ dependencies = [ "thiserror 2.0.18", ] +[[package]] +name = "nac-upgrade-framework" +version = "0.1.0" +dependencies = [ + "anyhow", + "chrono", + "hex", + "log", + "serde", + "serde_json", + "sha3", + "thiserror 1.0.69", +] + [[package]] name = "num-traits" version = "0.2.19" diff --git a/nac-csnp-l1/Cargo.lock b/nac-csnp-l1/Cargo.lock index bde4d25..9c0e6fa 100644 --- a/nac-csnp-l1/Cargo.lock +++ b/nac-csnp-l1/Cargo.lock @@ -11,6 +11,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + [[package]] name = "arrayref" version = "0.3.9" @@ -344,6 +350,7 @@ name = "nac-csnp-l1" version = "0.1.0" dependencies = [ "nac-udm", + "nac-upgrade-framework", "serde", "serde_json", "thiserror 1.0.69", @@ -357,6 +364,7 @@ dependencies = [ "chrono", "hex", "log", + "nac-upgrade-framework", "primitive-types", "serde", "serde_json", @@ -365,6 +373,20 @@ dependencies = [ "thiserror 2.0.18", ] +[[package]] +name = "nac-upgrade-framework" +version = "0.1.0" +dependencies = [ + "anyhow", + "chrono", + "hex", + "log", + "serde", + "serde_json", + "sha3", + "thiserror 1.0.69", +] + [[package]] name = "num-traits" version = "0.2.19" diff --git a/nac-csnp/Cargo.lock b/nac-csnp/Cargo.lock index e69de29..7ef4593 100644 --- a/nac-csnp/Cargo.lock +++ b/nac-csnp/Cargo.lock @@ -0,0 +1,705 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "bitflags" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" + +[[package]] +name = "bytes" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" + +[[package]] +name = "cc" +version = "1.2.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "chrono" +version = "0.4.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "itoa" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + +[[package]] +name = "js-sys" +version = "0.3.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "keccak" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb26cec98cce3a3d96cbb7bced3c4b16e3d13f27ec56dbd62cbc8f39cfb9d653" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "libc" +version = "0.2.182" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "mio" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "nac-csnp" +version = "1.0.0" +dependencies = [ + "anyhow", + "nac-upgrade-framework", + "serde", + "serde_json", + "thiserror", + "tokio", +] + +[[package]] +name = "nac-upgrade-framework" +version = "0.1.0" +dependencies = [ + "anyhow", + "chrono", + "hex", + "log", + "serde", + "serde_json", + "sha3", + "thiserror", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest", + "keccak", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "socket2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0" +dependencies = [ + "libc", + "windows-sys 0.60.2", +] + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio" +version = "1.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d" +dependencies = [ + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c55a2eff8b69ce66c84f85e1da1c233edc36ceb85a2058d11b0d6a3c7e7569c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "typenum" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasm-bindgen" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.53.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" + +[[package]] +name = "windows_i686_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/nac-sdk/src/protocols/acc1155.rs b/nac-sdk/src/protocols/acc1155.rs index acf5491..4f07715 100644 --- a/nac-sdk/src/protocols/acc1155.rs +++ b/nac-sdk/src/protocols/acc1155.rs @@ -144,9 +144,9 @@ impl ACC1155 { .ok_or(NACError::InvalidResponse("Missing dna_hash".to_string()))? ).map_err(|e| NACError::InvalidHash(format!("Invalid dna_hash: {}", e)))?, token_id, - gnacs_code, + gnacs_code: gnacs_code.to_string(), token_type, - sovereignty_type, + sovereignty_type: format!("{:?}", sovereignty_type), metadata_hash: Hash::from_hex( dna_data["metadata_hash"] .as_str() @@ -396,6 +396,15 @@ impl ACC1155 { .as_str() .ok_or(NACError::InvalidResponse("Missing uri".to_string()))? .to_string(), + description: meta_data["description"] + .as_str() + .unwrap_or("") + .to_string(), + attributes: vec![], + version: meta_data["version"] + .as_str() + .unwrap_or("1.0.0") + .to_string(), max_supply: meta_data["max_supply"] .as_str() .and_then(|s| s.parse().ok()), @@ -499,6 +508,9 @@ impl ACC1155 { is_active: custody_data["is_active"] .as_bool() .ok_or(NACError::InvalidResponse("Missing is_active".to_string()))?, + amount: 0, + expires_at: None, + reason: String::new(), custody_proof: Hash::from_hex( custody_data["custody_proof"] .as_str() @@ -556,6 +568,10 @@ impl ACC1155 { .as_str() .ok_or(NACError::InvalidResponse("Missing policy_number".to_string()))? .to_string(), + policy_uri: insurance_data["policy_uri"] + .as_str() + .unwrap_or("") + .to_string(), }; Ok(insurance_info) @@ -629,6 +645,14 @@ impl ACC1155 { validity_period: val_data["validity_period"] .as_u64() .ok_or(NACError::InvalidResponse("Missing validity_period".to_string()))?, + method: val_data["method"] + .as_str() + .unwrap_or("market") + .to_string(), + report_uri: val_data["report_uri"] + .as_str() + .unwrap_or("") + .to_string(), }; Ok(valuation) diff --git a/nac-udm/src/l1_protocol/acc/acc1155.rs b/nac-udm/src/l1_protocol/acc/acc1155.rs index c90df2e..c01bece 100644 --- a/nac-udm/src/l1_protocol/acc/acc1155.rs +++ b/nac-udm/src/l1_protocol/acc/acc1155.rs @@ -698,3 +698,106 @@ mod tests { assert_eq!(acc.balance_of(&receiver, &t2), 400); } } + + + + +// ======================== +// SDK 扩展类型(供 nac-sdk 使用) +// ======================== + +/// 代币类型 DNA(唯一标识信息) +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct TokenTypeDNA { + pub dna_hash: Hash, + pub token_id: TokenId, + pub gnacs_code: String, + pub token_type: TokenType, + pub sovereignty_type: String, + pub metadata_hash: Hash, + pub generated_at: Timestamp, +} + +/// 代币类型元数据 +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct TokenTypeMetadata { + pub token_id: TokenId, + pub name: String, + pub symbol: String, + pub token_type: TokenType, + pub uri: String, + pub description: String, + pub attributes: Vec<(String, String)>, + pub version: String, + pub current_supply: u128, + pub max_supply: Option, + pub created_at: Timestamp, +} + +/// 批量转账请求 +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct BatchTransfer { + pub from: Address, + pub to: Address, + pub token_ids: Vec, + pub amounts: Vec, + pub constitutional_receipt: Hash, + pub transferred_at: Timestamp, +} + +/// 批量铸造请求 +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct BatchMint { + pub to: Address, + pub token_ids: Vec, + pub amounts: Vec, + pub constitutional_receipt: Hash, + pub minted_at: Timestamp, +} + +/// 批量销毁请求 +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct BatchBurn { + pub from: Address, + pub token_ids: Vec, + pub amounts: Vec, + pub constitutional_receipt: Hash, + pub burned_at: Timestamp, +} + +/// 代币托管信息 +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct TokenCustodyInfo { + pub token_id: TokenId, + pub custodian: Address, + pub custody_start: Timestamp, + pub is_active: bool, + pub custody_proof: Hash, + pub amount: u128, + pub expires_at: Option, + pub reason: String, +} + +/// 代币保险信息 +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct TokenInsuranceInfo { + pub token_id: TokenId, + pub insurer: Address, + pub coverage_per_unit_xtzh: u128, + pub insurance_start: Timestamp, + pub insurance_expiry: Timestamp, + pub policy_number: String, + pub policy_uri: String, +} + +/// 代币类型估值信息 +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct TokenTypeValuation { + pub token_id: TokenId, + pub value_per_unit_xtzh: u128, + pub valuation_provider: Address, + pub valued_at: Timestamp, + pub validity_period: u64, + pub method: String, + pub report_uri: String, +} diff --git a/nvm_v2/nvm-l0/Cargo.lock b/nvm_v2/nvm-l0/Cargo.lock index db95f9c..338dff0 100644 --- a/nvm_v2/nvm-l0/Cargo.lock +++ b/nvm_v2/nvm-l0/Cargo.lock @@ -11,6 +11,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + [[package]] name = "arrayref" version = "0.3.9" @@ -356,12 +362,27 @@ dependencies = [ "chrono", "hex", "log", + "nac-upgrade-framework", "primitive-types", "serde", "serde_json", "sha2", "sha3", - "thiserror", + "thiserror 2.0.18", +] + +[[package]] +name = "nac-upgrade-framework" +version = "0.1.0" +dependencies = [ + "anyhow", + "chrono", + "hex", + "log", + "serde", + "serde_json", + "sha3", + "thiserror 1.0.69", ] [[package]] @@ -629,13 +650,33 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + [[package]] name = "thiserror" version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" dependencies = [ - "thiserror-impl", + "thiserror-impl 2.0.18", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] diff --git a/nvm_v2/nvm-l1/Cargo.lock b/nvm_v2/nvm-l1/Cargo.lock index dd21f5d..8961e73 100644 --- a/nvm_v2/nvm-l1/Cargo.lock +++ b/nvm_v2/nvm-l1/Cargo.lock @@ -11,6 +11,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + [[package]] name = "arrayref" version = "0.3.9" @@ -347,12 +353,27 @@ dependencies = [ "chrono", "hex", "log", + "nac-upgrade-framework", "primitive-types", "serde", "serde_json", "sha2", "sha3", - "thiserror", + "thiserror 2.0.18", +] + +[[package]] +name = "nac-upgrade-framework" +version = "0.1.0" +dependencies = [ + "anyhow", + "chrono", + "hex", + "log", + "serde", + "serde_json", + "sha3", + "thiserror 1.0.69", ] [[package]] @@ -608,13 +629,33 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + [[package]] name = "thiserror" version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" dependencies = [ - "thiserror-impl", + "thiserror-impl 2.0.18", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] diff --git a/nvm_v2/nvm-l1/src/cbpp/mod.rs b/nvm_v2/nvm-l1/src/cbpp/mod.rs index a50b080..8229704 100644 --- a/nvm_v2/nvm-l1/src/cbpp/mod.rs +++ b/nvm_v2/nvm-l1/src/cbpp/mod.rs @@ -14,4 +14,4 @@ pub use open_production_network::*; pub use gossip_protocol::*; pub mod nac_lens; -pub use crate::nac_lens::*; +pub use self::nac_lens::*;