diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index e87acc5c7..afb36cefe 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -12,6 +12,7 @@ concurrency: env: ARTIFACT_RETENTION_DAYS_FOR_TEST_WASMS: 7 + SOROBAN_SDK_BUILD_SYSTEM_SUPPORTS_SPEC_SHAKING_V2: 1 defaults: run: diff --git a/soroban-token-sdk/src/_migrating.rs b/soroban-token-sdk/src/_migrating.rs index 723c10269..5a9377b65 100644 --- a/soroban-token-sdk/src/_migrating.rs +++ b/soroban-token-sdk/src/_migrating.rs @@ -1,3 +1,10 @@ +//! # Migrating from v23 to v26 +//! +//! 1. Remove the deprecated event format. For details, see the [migration guide for v23 contract events]. +//! And for an example using the `soroban_token_sdk` directly, see the [migration guide for v23 token transfer][v23_token_transfer]. +//! +//! [migration guide for v23 contract events]: soroban_sdk::_migrating::v23_contractevent +//! //! # Migrating from v22 to v23 //! //! 1. [`MuxedAddress` replaces `Address` as the `to` of the `TokenInterface::transfer`][v23_token_transfer] diff --git a/soroban-token-sdk/src/_migrating/v23_token_transfer.rs b/soroban-token-sdk/src/_migrating/v23_token_transfer.rs index 337abe7a6..e0581cd8c 100644 --- a/soroban-token-sdk/src/_migrating/v23_token_transfer.rs +++ b/soroban-token-sdk/src/_migrating/v23_token_transfer.rs @@ -16,9 +16,12 @@ //! the exchange deposits for the token contracts, but is necessary for that. //! //! The necessary token modification is very minimal. Consider the following -//! `transfer` implementation that still uses `Address` destination: +//! `transfer` implementation that still uses `Address` destination. Note that +//! this example will only compile pre-v26 because the old event publishing +//! helper used below is no longer available. If you are using v26 or later, +//! use the updated implementation shown in the next code snippet. //! -//! ``` +//! ```compile_fail //! use soroban_sdk::{Env, Address}; //! use soroban_token_sdk::TokenUtils; //! // ... inside some token contract ... @@ -27,7 +30,8 @@ //! from.require_auth(); //! // Token-specific implementation of balance movement. //! token_impl::move_balance(&env, &from, &to, amount); -//! // Publish the event. +//! // Publish the event using the pre-v26 helper API. +//! // In v26+, use the event type from `soroban_token_sdk::events` instead. //! TokenUtils::new(&env).events().transfer(from, to, amount); //! } //! diff --git a/soroban-token-sdk/src/event.rs b/soroban-token-sdk/src/event.rs deleted file mode 100644 index 3c93e5dda..000000000 --- a/soroban-token-sdk/src/event.rs +++ /dev/null @@ -1,71 +0,0 @@ -use soroban_sdk::{symbol_short, Address, Env, Symbol}; - -pub struct Events { - env: Env, -} - -#[allow(deprecated)] -impl Events { - #[inline(always)] - pub fn new(env: &Env) -> Events { - Events { env: env.clone() } - } - - #[deprecated = "use soroban_token_sdk::events::Approve::publish"] - pub fn approve(&self, from: Address, to: Address, amount: i128, expiration_ledger: u32) { - let topics = (Symbol::new(&self.env, "approve"), from, to); - self.env - .events() - .publish(topics, (amount, expiration_ledger)); - } - - #[deprecated = "use soroban_token_sdk::events::Transfer::publish"] - pub fn transfer(&self, from: Address, to: Address, amount: i128) { - let topics = (symbol_short!("transfer"), from, to); - self.env.events().publish(topics, amount); - } - - #[deprecated = "use soroban_token_sdk::events::Mint::publish"] - pub fn mint(&self, admin: Address, to: Address, amount: i128) { - let topics = (symbol_short!("mint"), admin, to); - self.env.events().publish(topics, amount); - } - - #[deprecated = "use soroban_token_sdk::events::Clawback::publish"] - pub fn clawback(&self, admin: Address, from: Address, amount: i128) { - let topics = (symbol_short!("clawback"), admin, from); - self.env.events().publish(topics, amount); - } - - #[deprecated = "define a contractevent instead:\n\ - #[contractevent(data_format = \"single-value\")]\n\ - pub struct SetAuthorized {\n\ - #[topic]\n\ - admin: Address,\n\ - #[topic]\n\ - id: Address,\n\ - authorize: bool,\n\ - }"] - pub fn set_authorized(&self, admin: Address, id: Address, authorize: bool) { - let topics = (Symbol::new(&self.env, "set_authorized"), admin, id); - self.env.events().publish(topics, authorize); - } - - #[deprecated = "define a contractevent instead:\n\ - #[contractevent(data_format = \"single-value\")]\n\ - pub struct SetAdmin {\n\ - #[topic]\n\ - admin: Address,\n\ - new_admin: Address,\n\ - }"] - pub fn set_admin(&self, admin: Address, new_admin: Address) { - let topics = (symbol_short!("set_admin"), admin); - self.env.events().publish(topics, new_admin); - } - - #[deprecated = "use soroban_token_sdk::events::Burn::publish"] - pub fn burn(&self, from: Address, amount: i128) { - let topics = (symbol_short!("burn"), from); - self.env.events().publish(topics, amount); - } -} diff --git a/soroban-token-sdk/src/lib.rs b/soroban-token-sdk/src/lib.rs index cb69f6e0e..489b17353 100644 --- a/soroban-token-sdk/src/lib.rs +++ b/soroban-token-sdk/src/lib.rs @@ -2,11 +2,9 @@ #![cfg_attr(feature = "docs", feature(doc_cfg))] pub mod _migrating; -use crate::event::Events; use crate::metadata::Metadata; use soroban_sdk::Env; -pub mod event; pub mod events; pub mod metadata; mod tests; @@ -23,8 +21,4 @@ impl TokenUtils { pub fn metadata(&self) -> Metadata { Metadata::new(&self.0) } - - pub fn events(&self) -> Events { - Events::new(&self.0) - } }