From b7fcb3dfd877e35c9801d07d996dac5053a39d1b Mon Sep 17 00:00:00 2001 From: Lozano Date: Tue, 2 Jul 2024 18:36:03 +0200 Subject: [PATCH] chore: recover previous version --- Cargo.lock | 58 ++++++++--------- contracts/blob-registry/src/events.rs | 91 ++++++++++----------------- contracts/blob-registry/src/lib.rs | 2 +- 3 files changed, 61 insertions(+), 90 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ce007bc..f881715 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1456,7 +1456,7 @@ dependencies = [ "cranelift-codegen", "cranelift-entity", "cranelift-frontend", - "itertools 0.10.5", + "itertools", "log", "smallvec", "wasmparser 0.115.0", @@ -2988,15 +2988,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.11" @@ -3805,26 +3796,6 @@ dependencies = [ "tracing-subscriber", ] -[[package]] -name = "near-da-http-api" -version = "0.4.0" -dependencies = [ - "anyhow", - "axum", - "clap 4.5.8", - "hex 0.4.3", - "moka", - "near-da-http-api-data", - "near-da-primitives", - "near-da-rpc", - "serde", - "serde_json", - "tokio", - "tower-http", - "tracing", - "tracing-subscriber", -] - [[package]] name = "near-da-http-api-data" version = "0.4.0" @@ -3885,6 +3856,29 @@ dependencies = [ "which 6.0.1", ] +[[package]] +name = "near-da-sidecar" +version = "0.4.0" +dependencies = [ + "anyhow", + "axum", + "clap 4.5.8", + "futures", + "futures-util", + "hex 0.4.3", + "itertools", + "moka", + "near-da-http-api-data", + "near-da-primitives", + "near-da-rpc", + "serde", + "serde_json", + "tokio", + "tower-http", + "tracing", + "tracing-subscriber", +] + [[package]] name = "near-fmt" version = "0.17.0" @@ -5771,7 +5765,7 @@ checksum = "62941722fb675d463659e49c4f3fe1fe792ff24fe5bbaa9c08cd3b98a1c354f5" dependencies = [ "bytes", "heck 0.3.3", - "itertools 0.10.5", + "itertools", "lazy_static", "log", "multimap", @@ -5790,7 +5784,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe" dependencies = [ "anyhow", - "itertools 0.10.5", + "itertools", "proc-macro2", "quote", "syn 1.0.109", diff --git a/contracts/blob-registry/src/events.rs b/contracts/blob-registry/src/events.rs index c4e48a7..8b6ff9b 100644 --- a/contracts/blob-registry/src/events.rs +++ b/contracts/blob-registry/src/events.rs @@ -2,7 +2,7 @@ use crate::{Maintainer, Namespace}; use near_sdk::{ env::log_str, serde::{Deserialize, Serialize}, - serde_json, + serde_json::to_string, }; const CONTRACT_STANDARD_NAME: &str = "nepXXX"; @@ -16,7 +16,7 @@ const CONTRACT_STANDARD_VERSION: &str = "1.0.0"; /// * `event`: associate event data #[derive(Serialize, Deserialize, Debug)] #[serde(crate = "near_sdk::serde")] -pub struct EventLog { +pub(crate) struct EventLog { pub standard: String, pub version: String, #[serde(flatten)] @@ -29,42 +29,9 @@ pub struct EventLog { #[serde(rename_all = "snake_case")] #[serde(crate = "near_sdk::serde")] #[non_exhaustive] -pub enum EventLogVariant { +pub(crate) enum EventLogVariant { AddMaintainer(AddMaintainerLog), - OwnerTransfer(OwnerEvent), -} - -/// An event to log the submission of a blob. -/// -/// Arguments -/// * `namespace`: "namespace.near" -/// * `blob_id`: "blob.near" -/// * `memo`: optional message -#[derive(Serialize, Deserialize, Debug)] -#[serde(crate = "near_sdk::serde")] -pub struct BlobSubmissionLog { - pub who: AccountId, - pub namespace: u32, - pub blob: Vec, - #[serde(skip_serializing_if = "Option::is_none")] - pub memo: Option, -} - -/// Log the submission of a blob by `log_str`ing an [`EventLogVariant::BlobSubmissionLog`]. -pub(crate) fn log_blob_submission(namespace: u32, blob: Vec) { - let log = EventLog { - standard: CONTRACT_STANDARD_NAME.to_string(), - version: CONTRACT_STANDARD_VERSION.to_string(), - event: EventLogVariant::BlobSubmission(BlobSubmissionLog { - who: predecessor_account_id(), - namespace, - blob, - memo: None, - }), - }; - log_str(&log.to_string()); -} - + NamespaceRegistration(NamespaceRegistrationLog), } /// An event log to capture a maintainer inclusion. @@ -74,30 +41,12 @@ pub(crate) fn log_blob_submission(namespace: u32, blob: Vec) { /// * `memo`: optional message #[derive(Serialize, Deserialize, Debug)] #[serde(crate = "near_sdk::serde")] -pub struct AddMaintainerLog { +pub(crate) struct AddMaintainerLog { pub maintainer: Maintainer, #[serde(skip_serializing_if = "Option::is_none")] pub memo: Option, } -/// An event log to capture an ownership transfer. -/// -/// Arguments -/// * `authorized_id`: approved account to transfer -/// * `old_owner_id`: "owner.near" -/// * `new_owner_id`: "receiver.near" -/// * `memo`: optional message -#[derive(Serialize, Deserialize, Debug)] -#[serde(crate = "near_sdk::serde")] -pub struct OwnershipTransferLog { - #[serde(skip_serializing_if = "Option::is_none")] - pub authorized_id: Option, - pub old_owner_id: String, - pub new_owner_id: String, - #[serde(skip_serializing_if = "Option::is_none")] - pub memo: Option, -} - /// An event log to capture a new namespace registration. /// /// Arguments @@ -105,8 +54,36 @@ pub struct OwnershipTransferLog { /// * `memo`: optional message #[derive(Serialize, Deserialize, Debug)] #[serde(crate = "near_sdk::serde")] -pub struct NamespaceRegistrationLog { +pub(crate) struct NamespaceRegistrationLog { pub namespace: Namespace, #[serde(skip_serializing_if = "Option::is_none")] pub memo: Option, } + +impl EventLog { + fn new(event: EventLogVariant) -> Self { + Self { + standard: CONTRACT_STANDARD_NAME.to_string(), + version: CONTRACT_STANDARD_VERSION.to_string(), + event, + } + } + + pub(crate) fn maintainer(maintainer: Maintainer) { + let log = EventLog::new(EventLogVariant::AddMaintainer(AddMaintainerLog { + maintainer, + memo: None, + })); + log_str(&to_string(&log).unwrap()); + } + + pub(crate) fn namespace(namespace: Namespace) { + let log = EventLog::new(EventLogVariant::NamespaceRegistration( + NamespaceRegistrationLog { + namespace, + memo: None, + }, + )); + log_str(&to_string(&log).unwrap()); + } +} diff --git a/contracts/blob-registry/src/lib.rs b/contracts/blob-registry/src/lib.rs index d7ff2ef..5db0deb 100644 --- a/contracts/blob-registry/src/lib.rs +++ b/contracts/blob-registry/src/lib.rs @@ -86,7 +86,7 @@ impl Contract { } /// Submit the blob and the namespace. - pub fn submit(&self, namespace: Namespace, transaction_ids: Vec) { + pub fn submit(&self, namespace: Namespace, _transaction_ids: Vec) { // check the namespace exists and the caller is in the maintainers list match self.check_authorized(namespace) { Some(_) => {