From 681222b78457e18bae62fcf9e6841585e5ff8568 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Bizjak?= Date: Thu, 4 Apr 2024 09:10:37 +0200 Subject: [PATCH] Use qualified types. --- concordium-std-derive/CHANGELOG.md | 4 ---- concordium-std-derive/Cargo.toml | 2 +- concordium-std-derive/src/lib.rs | 18 +++++++++--------- .../tests/test-programs/success.rs | 10 +++++++--- concordium-std/CHANGELOG.md | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/concordium-std-derive/CHANGELOG.md b/concordium-std-derive/CHANGELOG.md index b58c481a..21a186fc 100644 --- a/concordium-std-derive/CHANGELOG.md +++ b/concordium-std-derive/CHANGELOG.md @@ -1,11 +1,7 @@ # Changelog -- Added MSRV (1.72) - ## Unreleased changes -### Added - - Macros for creating constant values from strings for the following types: - `AccountAddress` - `ContractAddress` diff --git a/concordium-std-derive/Cargo.toml b/concordium-std-derive/Cargo.toml index 6f16c98c..5f9836ef 100644 --- a/concordium-std-derive/Cargo.toml +++ b/concordium-std-derive/Cargo.toml @@ -14,7 +14,7 @@ repository = "https://github.com/Concordium/concordium-rust-smart-contracts/" proc-macro = true [dependencies] -concordium-contracts-common = { path = "../concordium-rust-sdk/concordium-base/smart-contracts/contracts-common/concordium-contracts-common", features = [ "derive-serde" ] } +concordium-contracts-common = { path = "../concordium-rust-sdk/concordium-base/smart-contracts/contracts-common/concordium-contracts-common", features = [ "derive-serde" ], version = "9" } syn = "2.0" proc-macro2 = "1.0" quote = "1.0" diff --git a/concordium-std-derive/src/lib.rs b/concordium-std-derive/src/lib.rs index 0542b21a..0fa0fa8c 100644 --- a/concordium-std-derive/src/lib.rs +++ b/concordium-std-derive/src/lib.rs @@ -36,7 +36,7 @@ fn parse_input(item: TokenStream, msg: &str) -> syn::Result { fn get_token_res( item: TokenStream, msg: &str, - worker_fun: fn(String, Span) -> syn::Result, + worker_fun: impl FnOnce(String, Span) -> syn::Result, ) -> syn::Result { let input = parse_input(item, msg)?; worker_fun(input.value(), input.span()) @@ -48,7 +48,7 @@ fn get_token_res( fn get_token_res_env( item: TokenStream, msg: &str, - worker_fun: fn(String, Span) -> syn::Result, + worker_fun: impl FnOnce(String, Span) -> syn::Result, ) -> syn::Result { let input = parse_input(item, msg)?; let environment_var_value = match std::env::var(input.value()) { @@ -75,7 +75,7 @@ fn acc_address_worker(str: String, span: Span) -> syn::Result { Err(e) => return Err(syn::Error::new(span, format!("Invalid account address: {}", e))), }; - Ok(quote!(AccountAddress(#address)).into()) + Ok(quote!(concordium_std::AccountAddress(#address)).into()) } fn pubkey_ed25519_worker(str: String, span: Span) -> syn::Result { @@ -84,7 +84,7 @@ fn pubkey_ed25519_worker(str: String, span: Span) -> syn::Result { Err(e) => return Err(syn::Error::new(span, format!("Invalid Ed25519 public key: {}", e))), }; - Ok(quote!(PublicKeyEd25519(#public_key)).into()) + Ok(quote!(concordium_std::PublicKeyEd25519(#public_key)).into()) } fn pubkey_ecdsa_worker(str: String, span: Span) -> syn::Result { @@ -93,7 +93,7 @@ fn pubkey_ecdsa_worker(str: String, span: Span) -> syn::Result { Err(e) => return Err(syn::Error::new(span, format!("Invalid ECDSA public key: {}", e))), }; - Ok(quote!(PublicKeyEcdsaSecp256k1(#public_key)).into()) + Ok(quote!(concordium_std::PublicKeyEcdsaSecp256k1(#public_key)).into()) } fn signature_ed25519_worker(str: String, span: Span) -> syn::Result { @@ -102,7 +102,7 @@ fn signature_ed25519_worker(str: String, span: Span) -> syn::Result Err(e) => return Err(syn::Error::new(span, format!("Invalid Ed25519 signature: {}", e))), }; - Ok(quote!(SignatureEd25519(#signature)).into()) + Ok(quote!(concordium_std::SignatureEd25519(#signature)).into()) } fn signature_ecdsa_worker(str: String, span: Span) -> syn::Result { @@ -111,7 +111,7 @@ fn signature_ecdsa_worker(str: String, span: Span) -> syn::Result { Err(e) => return Err(syn::Error::new(span, format!("Invalid ECDSA signature: {}", e))), }; - Ok(quote!(SignatureEcdsaSecp256k1(#signature)).into()) + Ok(quote!(concordium_std::SignatureEcdsaSecp256k1(#signature)).into()) } fn contract_address_worker(str: String, span: Span) -> syn::Result { @@ -120,7 +120,7 @@ fn contract_address_worker(str: String, span: Span) -> syn::Result Err(e) => return Err(syn::Error::new(span, format!("Invalid contract address: {}", e))), }; - Ok(quote!(ContractAddress { index: #index, subindex: #subindex }).into()) + Ok(quote!(concordium_std::ContractAddress::new(#index, #subindex)).into()) } fn module_ref_worker(str: String, span: Span) -> syn::Result { @@ -129,7 +129,7 @@ fn module_ref_worker(str: String, span: Span) -> syn::Result { Err(e) => return Err(syn::Error::new(span, format!("Invalid module reference: {}", e))), }; - Ok(quote!(ModuleReference::new(#module_ref)).into()) + Ok(quote!(concordium_std::ModuleReference::new(#module_ref)).into()) } /// Procedural macro for instantiating account addresses. diff --git a/concordium-std-derive/tests/test-programs/success.rs b/concordium-std-derive/tests/test-programs/success.rs index b915dc51..64c70524 100644 --- a/concordium-std-derive/tests/test-programs/success.rs +++ b/concordium-std-derive/tests/test-programs/success.rs @@ -1,13 +1,17 @@ //! Ensure that the macros generate compilable code. +use concordium_contracts_common as concordium_std; use concordium_contracts_common::*; use concordium_std_derive::*; const ACC: AccountAddress = account_address!("3kBx2h5Y2veb4hZgAJWPrr8RyQESKm5TjzF3ti1QQ4VSYLwK1G"); -const REF: ModuleReference = module_reference!("0000000000000000000000000000000000000000000000000000000000000000"); +const REF: ModuleReference = + module_reference!("0000000000000000000000000000000000000000000000000000000000000000"); const CONTRACT: ContractAddress = contract_address!("<1234,0>"); -const PK_25519: PublicKeyEd25519 = public_key_ed25519!("012a7e286063ae5dfcebce40636c0546d367d8c65cd4cb69aae1af77a4d61412"); -const PK_ECDSA: PublicKeyEcdsaSecp256k1 = public_key_ecdsa!("0214e6a60b8fc58ea707d8ee8fa6ca7b28626d4f6f80b170982644c95d12111853"); +const PK_25519: PublicKeyEd25519 = + public_key_ed25519!("012a7e286063ae5dfcebce40636c0546d367d8c65cd4cb69aae1af77a4d61412"); +const PK_ECDSA: PublicKeyEcdsaSecp256k1 = + public_key_ecdsa!("0214e6a60b8fc58ea707d8ee8fa6ca7b28626d4f6f80b170982644c95d12111853"); const SG_25519: SignatureEd25519 = signature_ed25519!("ec076ae7adaf0a8b921cf2bad86a1a5b5346226618637aa0d6b30f9616f108f9f482640a4ceb14235569cd3af05fac00be2c82dc81c6f6b4a6ba4ea7c3b51a0b"); const SG_ECDSA: SignatureEcdsaSecp256k1 = signature_ecdsa!("EC076AE7ADAF0A8B921CF2BAD86A1A5B5346226618637AA0D6B30F9616F108F9F482640A4CEB14235569CD3AF05FAC00BE2C82DC81C6F6B4A6BA4EA7C3B51A0B"); diff --git a/concordium-std/CHANGELOG.md b/concordium-std/CHANGELOG.md index 5c0454b2..638c4918 100644 --- a/concordium-std/CHANGELOG.md +++ b/concordium-std/CHANGELOG.md @@ -1,7 +1,5 @@ # Changelog -- Bump MSRV to 1.72 - ## Unreleased changes - Add support for querying the module reference and contract name of an instance, @@ -9,6 +7,8 @@ These are only available from protocol version 7, and as such are guarded by the `p7` feature flag. - Add two ordered collections: `StateBTreeMap` and `StateBTreeSet`. These are based on [B-Tree](https://en.wikipedia.org/wiki/B-tree), but where each node is stored in the low-level smart contract key-value store. Use one of these when needing operations related to the ordering of the keys, such as `higher(k)` providing the smallest key in collection which is stricly greater than `k`. +- Bump MSRV to 1.73 + ## concordium-std 10.0.0 (2024-02-22)