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

Allow ImplicitAccountCreationAddress unlocking #1597

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion sdk/src/types/block/address/implicit_account_creation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::types::block::address::Ed25519Address;
/// [`AccountOutput`](crate::types::block::output::AccountOutput).
#[derive(Copy, Clone, Display, Eq, PartialEq, Ord, PartialOrd, Hash, FromStr, AsRef, Deref, From, Packable)]
#[as_ref(forward)]
pub struct ImplicitAccountCreationAddress(pub(crate) Ed25519Address);
pub struct ImplicitAccountCreationAddress(Ed25519Address);

impl ImplicitAccountCreationAddress {
/// The [`Address`](crate::types::block::address::Address) kind of an [`ImplicitAccountCreationAddress`].
Expand All @@ -24,6 +24,11 @@ impl ImplicitAccountCreationAddress {
pub fn new(address: [u8; Self::LENGTH]) -> Self {
Self(Ed25519Address::new(address))
}

/// Returns the inner [`Ed25519Address`] of the [`ImplicitAccountCreationAddress`].
pub fn ed25519_address(&self) -> &Ed25519Address {
&self.0
}
}

impl core::fmt::Debug for ImplicitAccountCreationAddress {
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/types/block/address/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ impl Address {
}
// TODO maybe shouldn't be a semantic error but this function currently returns a TransactionFailureReason.
(Self::Anchor(_), _) => return Err(TransactionFailureReason::SemanticValidationFailed),
(Self::ImplicitAccountCreation(ImplicitAccountCreationAddress(ed25519_address)), _) => {
return Self::from(ed25519_address.clone()).unlock(unlock, context);
(Self::ImplicitAccountCreation(address), _) => {
return Self::from(address.ed25519_address().clone()).unlock(unlock, context);
DaughterOfMars marked this conversation as resolved.
Show resolved Hide resolved
}
_ => return Err(TransactionFailureReason::InvalidInputUnlock),
}
Expand Down
Loading