Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create the signature facilities for arbitrary messages #1521

Merged
merged 16 commits into from
Feb 7, 2024

Conversation

TheQuantumPhysicist
Copy link
Contributor

No description provided.

@TheQuantumPhysicist TheQuantumPhysicist marked this pull request as draft January 30, 2024 20:12
@TheQuantumPhysicist TheQuantumPhysicist mentioned this pull request Feb 2, 2024
25 tasks
@OBorce OBorce force-pushed the feat/arbitrary-message-sigs branch 3 times, most recently from 3eb14dd to c7e361e Compare February 6, 2024 09:01
@OBorce OBorce marked this pull request as ready for review February 6, 2024 09:01
address: String,
) -> WRpcResult<SignedArbitraryMessage, N> {
let config = ControllerConfig { in_top_x_mb: 5 }; // irrelevant
let destination = Address::from_str(&self.chain_config, &address)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Address::from_str function is a bit strange - it calls decode_object, ignores its result and stores the original string inside Address, on which you later call decode_object again.
I suggest to introduce a separate function decode_object_from_str in Address:

pub fn decode_object_from_str(address: &str, cfg: &ChainConfig) -> Result<T, AddressError> {
    let data = encoding::decode(address)?;
    // here goes the rest of the body of the current "decode_object" 
}

 pub fn decode_object(&self, cfg: &ChainConfig) -> Result<T, AddressError> {
    Self::decode_object_from_str(&self.address, cfg)
}

and use it here and in similar places below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from_str needs to ensure that the encoding is valid. That's why we do it like that.

@TheQuantumPhysicist TheQuantumPhysicist merged commit 94010c4 into master Feb 7, 2024
17 checks passed
@TheQuantumPhysicist TheQuantumPhysicist deleted the feat/arbitrary-message-sigs branch February 7, 2024 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants