diff --git a/Cargo.lock b/Cargo.lock index fb5aed8..ba6b738 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -209,6 +209,12 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +[[package]] +name = "assert_matches" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" + [[package]] name = "async-stream" version = "0.3.5" @@ -246,7 +252,8 @@ dependencies = [ name = "attestation-registry" version = "0.0.1" dependencies = [ - "near-sdk", + "near-contract-standards", + "near-sdk 5.0.0", "uint", ] @@ -889,6 +896,35 @@ dependencies = [ "zeroize", ] +[[package]] +name = "curve25519-dalek" +version = "4.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.7", + "fiat-crypto", + "platforms", + "rand_core 0.6.4", + "rustc_version", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "darling" version = "0.20.3" @@ -1032,7 +1068,16 @@ version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" dependencies = [ - "signature", + "signature 1.6.4", +] + +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "signature 2.2.0", ] [[package]] @@ -1041,14 +1086,27 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ - "curve25519-dalek", - "ed25519", + "curve25519-dalek 3.2.1", + "ed25519 1.5.3", "rand 0.7.3", "serde", "sha2 0.9.9", "zeroize", ] +[[package]] +name = "ed25519-dalek" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" +dependencies = [ + "curve25519-dalek 4.1.2", + "ed25519 2.2.3", + "rand_core 0.6.4", + "sha2 0.10.8", + "subtle", +] + [[package]] name = "either" version = "1.9.0" @@ -1135,6 +1193,12 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +[[package]] +name = "fiat-crypto" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1676f435fc1dadde4d03e43f5d62b259e1ce5f40bd4ffb21db2b42ebe59c1382" + [[package]] name = "filetime" version = "0.2.23" @@ -1816,6 +1880,15 @@ dependencies = [ "libc", ] +[[package]] +name = "memoffset" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +dependencies = [ + "autocfg", +] + [[package]] name = "memory_units" version = "0.4.0" @@ -1910,6 +1983,16 @@ dependencies = [ "serde", ] +[[package]] +name = "near-account-id" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35cbb989542587b47205e608324ddd391f0cee1c22b4b64ae49f458334b95907" +dependencies = [ + "borsh 1.3.1", + "serde", +] + [[package]] name = "near-chain-configs" version = "0.17.0" @@ -1919,9 +2002,9 @@ dependencies = [ "anyhow", "chrono", "derive_more", - "near-config-utils", + "near-config-utils 0.17.0", "near-crypto 0.17.0", - "near-o11y", + "near-o11y 0.17.0", "near-primitives 0.17.0", "num-rational", "once_cell", @@ -1944,6 +2027,27 @@ dependencies = [ "tracing", ] +[[package]] +name = "near-config-utils" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ae1eaab1d545a9be7a55b6ef09f365c2017f93a03063547591d12c0c6d27e58" +dependencies = [ + "anyhow", + "json_comments", + "thiserror", + "tracing", +] + +[[package]] +name = "near-contract-standards" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d60a794d819e96fb307eb9afe5dd5d5c5dc7a73ce46eb8a94a0f40c387a165b" +dependencies = [ + "near-sdk 5.0.0", +] + [[package]] name = "near-crypto" version = "0.14.0" @@ -1955,9 +2059,9 @@ dependencies = [ "borsh 0.9.3", "bs58 0.4.0", "c2-chacha", - "curve25519-dalek", + "curve25519-dalek 3.2.1", "derive_more", - "ed25519-dalek", + "ed25519-dalek 1.0.1", "near-account-id 0.14.0", "once_cell", "parity-secp256k1", @@ -1980,13 +2084,40 @@ dependencies = [ "borsh 0.10.3", "bs58 0.4.0", "c2-chacha", - "curve25519-dalek", + "curve25519-dalek 3.2.1", "derive_more", - "ed25519-dalek", + "ed25519-dalek 1.0.1", "hex", "near-account-id 0.17.0", - "near-config-utils", - "near-stdx", + "near-config-utils 0.17.0", + "near-stdx 0.17.0", + "once_cell", + "primitive-types", + "rand 0.7.3", + "secp256k1", + "serde", + "serde_json", + "subtle", + "thiserror", +] + +[[package]] +name = "near-crypto" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2991d2912218a80ec0733ac87f84fa803accea105611eea209d4419271957667" +dependencies = [ + "blake2", + "borsh 1.3.1", + "bs58 0.4.0", + "c2-chacha", + "curve25519-dalek 4.1.2", + "derive_more", + "ed25519-dalek 2.1.1", + "hex", + "near-account-id 1.0.0", + "near-config-utils 0.20.1", + "near-stdx 0.20.1", "once_cell", "primitive-types", "rand 0.7.3", @@ -2006,6 +2137,15 @@ dependencies = [ "near-primitives-core 0.17.0", ] +[[package]] +name = "near-fmt" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7d998dfc1e04001608899b2498ad5a782c7d036b73769d510de21964db99286" +dependencies = [ + "near-primitives-core 0.20.1", +] + [[package]] name = "near-gas" version = "0.2.5" @@ -2069,7 +2209,7 @@ dependencies = [ "opentelemetry-semantic-conventions", "prometheus", "serde", - "strum", + "strum 0.24.1", "thiserror", "tokio", "tracing", @@ -2078,6 +2218,53 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "near-o11y" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d20762631bc8253030013bbae9b5f0542691edc1aa6722f1e8141cc9b928ae5b" +dependencies = [ + "actix", + "base64 0.21.7", + "clap 4.4.18", + "near-crypto 0.20.1", + "near-fmt 0.20.1", + "near-primitives-core 0.20.1", + "once_cell", + "opentelemetry", + "opentelemetry-otlp", + "opentelemetry-semantic-conventions", + "prometheus", + "serde", + "serde_json", + "strum 0.24.1", + "thiserror", + "tokio", + "tracing", + "tracing-appender", + "tracing-opentelemetry", + "tracing-subscriber", +] + +[[package]] +name = "near-parameters" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9f16a59b6c3e69b0585be951af6fe42a0ba86c0e207cb8c63badd19efd16680" +dependencies = [ + "assert_matches", + "borsh 1.3.1", + "enum-map", + "near-account-id 1.0.0", + "near-primitives-core 0.20.1", + "num-rational", + "serde", + "serde_repr", + "serde_yaml", + "strum 0.24.1", + "thiserror", +] + [[package]] name = "near-primitives" version = "0.14.0" @@ -2103,7 +2290,7 @@ dependencies = [ "serde", "serde_json", "smart-default", - "strum", + "strum 0.24.1", "thiserror", ] @@ -2123,10 +2310,10 @@ dependencies = [ "enum-map", "hex", "near-crypto 0.17.0", - "near-fmt", + "near-fmt 0.17.0", "near-primitives-core 0.17.0", "near-rpc-error-macro 0.17.0", - "near-stdx", + "near-stdx 0.17.0", "near-vm-errors 0.17.0", "num-rational", "once_cell", @@ -2138,7 +2325,49 @@ dependencies = [ "serde_with", "serde_yaml", "smart-default", - "strum", + "strum 0.24.1", + "thiserror", + "time", + "tracing", +] + +[[package]] +name = "near-primitives" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0462b067732132babcc89d5577db3bfcb0a1bcfbaaed3f2db4c11cd033666314" +dependencies = [ + "arbitrary", + "base64 0.21.7", + "borsh 1.3.1", + "bytesize", + "cfg-if 1.0.0", + "chrono", + "derive_more", + "easy-ext", + "enum-map", + "hex", + "near-crypto 0.20.1", + "near-fmt 0.20.1", + "near-o11y 0.20.1", + "near-parameters", + "near-primitives-core 0.20.1", + "near-rpc-error-macro 0.20.1", + "near-stdx 0.20.1", + "near-vm-runner", + "num-rational", + "once_cell", + "primitive-types", + "rand 0.8.5", + "rand_chacha 0.3.1", + "reed-solomon-erasure", + "serde", + "serde_json", + "serde_with", + "serde_yaml", + "sha3", + "smart-default", + "strum 0.24.1", "thiserror", "time", "tracing", @@ -2158,7 +2387,7 @@ dependencies = [ "num-rational", "serde", "sha2 0.10.8", - "strum", + "strum 0.24.1", ] [[package]] @@ -2179,7 +2408,29 @@ dependencies = [ "serde_repr", "serde_with", "sha2 0.10.8", - "strum", + "strum 0.24.1", + "thiserror", +] + +[[package]] +name = "near-primitives-core" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8443eb718606f572c438be6321a097a8ebd69f8e48d953885b4f16601af88225" +dependencies = [ + "arbitrary", + "base64 0.21.7", + "borsh 1.3.1", + "bs58 0.4.0", + "derive_more", + "enum-map", + "near-account-id 1.0.0", + "num-rational", + "serde", + "serde_repr", + "serde_with", + "sha2 0.10.8", + "strum 0.24.1", "thiserror", ] @@ -2205,6 +2456,17 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "near-rpc-error-core" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80fca203c51edd9595ec14db1d13359fb9ede32314990bf296b6c5c4502f6ab7" +dependencies = [ + "quote", + "serde", + "syn 2.0.48", +] + [[package]] name = "near-rpc-error-macro" version = "0.14.0" @@ -2228,6 +2490,18 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "near-rpc-error-macro" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897a445de2102f6732c8a185d922f5e3bf7fd0a41243ce40854df2197237f799" +dependencies = [ + "fs2", + "near-rpc-error-core 0.20.1", + "serde", + "syn 2.0.48", +] + [[package]] name = "near-sandbox-utils" version = "0.7.0" @@ -2255,7 +2529,7 @@ dependencies = [ "near-crypto 0.14.0", "near-primitives 0.14.0", "near-primitives-core 0.14.0", - "near-sdk-macros", + "near-sdk-macros 4.1.1", "near-sys", "near-vm-logic", "once_cell", @@ -2265,6 +2539,31 @@ dependencies = [ "wee_alloc", ] +[[package]] +name = "near-sdk" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5c2e7c9524308b1b301cca05d875de13b3b20dc8b92e71f3890b380372e4c88" +dependencies = [ + "base64 0.21.7", + "borsh 1.3.1", + "bs58 0.5.0", + "near-account-id 1.0.0", + "near-crypto 0.20.1", + "near-gas", + "near-parameters", + "near-primitives 0.20.1", + "near-primitives-core 0.20.1", + "near-sdk-macros 5.0.0", + "near-sys", + "near-token", + "near-vm-runner", + "once_cell", + "serde", + "serde_json", + "wee_alloc", +] + [[package]] name = "near-sdk-macros" version = "4.1.1" @@ -2277,12 +2576,35 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "near-sdk-macros" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1e9b23d9d7757ade258921c9cbc7923542e64d9d3b52a6cd91f746c77cb0a0f" +dependencies = [ + "Inflector", + "darling", + "proc-macro2", + "quote", + "serde", + "serde_json", + "strum 0.26.2", + "strum_macros 0.26.2", + "syn 2.0.48", +] + [[package]] name = "near-stdx" version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6540152fba5e96fe5d575b79e8cd244cf2add747bb01362426bdc069bc3a23bc" +[[package]] +name = "near-stdx" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "855fd5540e3b4ff6fedf12aba2db1ee4b371b36f465da1363a6d022b27cb43b8" + [[package]] name = "near-sys" version = "0.2.1" @@ -2295,6 +2617,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b68f3f8a2409f72b43efdbeff8e820b81e70824c49fee8572979d789d1683fb" dependencies = [ + "borsh 1.3.1", "serde", ] @@ -2320,7 +2643,7 @@ dependencies = [ "near-account-id 0.17.0", "near-rpc-error-macro 0.17.0", "serde", - "strum", + "strum 0.24.1", "thiserror", ] @@ -2346,6 +2669,36 @@ dependencies = [ "zeropool-bn", ] +[[package]] +name = "near-vm-runner" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c56c80bdb1954808f59bd36a9112377197b38d424991383bf05f52d0fe2e0da5" +dependencies = [ + "base64 0.21.7", + "borsh 1.3.1", + "ed25519-dalek 2.1.1", + "enum-map", + "memoffset", + "near-crypto 0.20.1", + "near-parameters", + "near-primitives-core 0.20.1", + "near-stdx 0.20.1", + "num-rational", + "once_cell", + "prefix-sum-vec", + "ripemd", + "serde", + "serde_repr", + "serde_with", + "sha2 0.10.8", + "sha3", + "strum 0.24.1", + "thiserror", + "tracing", + "zeropool-bn", +] + [[package]] name = "near-workspaces" version = "0.9.0" @@ -2368,7 +2721,7 @@ dependencies = [ "near-jsonrpc-primitives", "near-primitives 0.17.0", "near-sandbox-utils", - "near-sdk", + "near-sdk 4.1.1", "near-token", "rand 0.8.5", "reqwest", @@ -2754,6 +3107,12 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" +[[package]] +name = "platforms" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626dec3cac7cc0e1577a2ec3fc496277ec2baa084bebad95bb6fdbfae235f84c" + [[package]] name = "powerfmt" version = "0.2.0" @@ -2772,6 +3131,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" +[[package]] +name = "prefix-sum-vec" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa06bd51638b6e76ac9ba9b6afb4164fa647bd2916d722f2623fbb6d1ed8bdba" + [[package]] name = "primitive-types" version = "0.10.1" @@ -3517,6 +3882,12 @@ version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" + [[package]] name = "siphasher" version = "0.3.11" @@ -3619,9 +3990,15 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" dependencies = [ - "strum_macros", + "strum_macros 0.24.3", ] +[[package]] +name = "strum" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" + [[package]] name = "strum_macros" version = "0.24.3" @@ -3635,6 +4012,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "strum_macros" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.48", +] + [[package]] name = "subtle" version = "2.5.0" diff --git a/Cargo.toml b/Cargo.toml index 52ecf85..a5d29b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,9 +8,13 @@ edition = "2021" crate-type = ["cdylib"] [dependencies] -near-sdk = "4.1.1" +near-sdk = "5.0.0" +near-contract-standards = "5.0.0" uint = { version = "0.9.3", default-features = false } +[dev-dependencies] +near-sdk = { version = "5.0.0", features = ["unit-testing"] } + [patch.crates-io] parity-secp256k1 = { git = 'https://github.com/paritytech/rust-secp256k1.git' } diff --git a/src/lib.rs b/src/lib.rs index 07fd02e..bb9acb2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; +use near_sdk::borsh::{BorshDeserialize, BorshSerialize}; use near_sdk::env::log_str; use near_sdk::serde::{Serialize, Deserialize}; use near_sdk::collections::LookupMap; @@ -7,9 +7,9 @@ use near_sdk::{ AccountId, BorshStorageKey, PublicKey, require }; - // Represents the content being stored into the storage map #[derive(BorshSerialize, BorshDeserialize, Clone, Debug)] +#[borsh(crate = "near_sdk::borsh")] pub struct Manifest { pub version: String, pub cid: String, @@ -18,6 +18,7 @@ pub struct Manifest { // An attestation for a given manifest #[derive(BorshSerialize, BorshDeserialize, Serialize, Deserialize, Clone, Debug)] +#[borsh(crate = "near_sdk::borsh")] #[serde(crate = "near_sdk::serde")] pub struct Attestation { pub pubkey: PublicKey, @@ -25,6 +26,7 @@ pub struct Attestation { } #[derive(BorshDeserialize, BorshStorageKey, BorshSerialize, Copy, Clone)] +#[borsh(crate = "near_sdk::borsh")] enum PrefixKeys { Package, Manifest, @@ -38,6 +40,7 @@ pub type Attestations = Vec; #[near_bindgen] #[derive(BorshDeserialize, BorshSerialize)] +#[borsh(crate = "near_sdk::borsh")] pub struct Contract { // Each package in the registry is linked by a NEAR Account. Releases are then treated as a list of manifests pub packages: LookupMap, @@ -292,7 +295,7 @@ impl Contract { } } -#[cfg(test)] +#[cfg(all(test, not(target_arch = "wasm32")))] mod tests { use super::*; use near_sdk::test_utils::VMContextBuilder;