Concordium / concordium-rust-smart-contracts

Libraries and tools for writing and testing smart contracts on Concordium
https://docs.rs/concordium-std/latest/concordium_std/
Mozilla Public License 2.0
57 stars 35 forks source link

Macros for embedding constants in a convenient manner #385

Closed abizjak closed 6 months ago

abizjak commented 9 months ago

Task description

It is often useful to embed constants into contracts. We do this often for keys or addresses in tests. Currently the only way to do this is to embed a representation such as

const ACC = [0u8; 32]

meaning a low-level representation. Similar for keys and signatures which is even more inconvenient since those are typically generated as hex strings by various tools.

A related issue is embedding compile time constants defined by environment variables. This can only be done if the constant is a str without resorting to writing custom macros. We should provide macros in concordium-std that allow for embedding of such constants.