@@ -2428,13 +2428,35 @@ impl SenderSignedData {
24282428 }
24292429 );
24302430
2431- // Check the `MoveAuthenticator` transactions limitations.
2432- if self.move_authenticator().is_some() && !tx_data.kind().is_programmable_transaction() {
2433- return Err(UserInputError::Unsupported(
2434- "SenderSignedData with MoveAuthenticator must be a programmable transaction"
2435- .to_string(),
2436- )
2437- .into());
2431+ // Check the `MoveAuthenticator` limitations.
2432+ let authenticators_num = self.move_authenticators().len();
2433+ if authenticators_num > 0 {
2434+ if !tx_data.kind().is_programmable_transaction() {
2435+ return Err(UserInputError::Unsupported(
2436+ "SenderSignedData with MoveAuthenticator must be a programmable transaction"
2437+ .to_string(),
2438+ )
2439+ .into());
2440+ }
2441+
2442+ // TODO(https://github.com/iotaledger/iota/issues/8966): The following
2443+ // restrictions are temporary added until we implement MoveAuthenticator support
2444+ // for sponsors.
2445+
2446+ if authenticators_num > 1 {
2447+ return Err(UserInputError::Unsupported(
2448+ "SenderSignedData with more than one MoveAuthenticator is not supported"
2449+ .to_string(),
2450+ )
2451+ .into());
2452+ }
2453+
2454+ if self.sender_move_authenticator().is_none() {
2455+ return Err(UserInputError::Unsupported(
2456+ "SenderSignedData can have MoveAuthenticator only for the sender".to_string(),
2457+ )
2458+ .into());
2459+ }
24382460 }
24392461
24402462 // Checks to see if the transaction has expired
@@ -2467,19 +2489,28 @@ impl SenderSignedData {
24672489 Ok(tx_size)
24682490 }
24692491
2470- // TODO: A temporary created function. Needs to be replaced with a proper check.
2471- pub fn move_authenticator(&self) -> Option<&MoveAuthenticator> {
2472- let signatures = self.tx_signatures();
2492+ pub fn move_authenticators(&self) -> Vec<&MoveAuthenticator> {
2493+ self.tx_signatures()
2494+ .iter()
2495+ .filter_map(|sig| {
2496+ if let GenericSignature::MoveAuthenticator(move_authenticator) = sig {
2497+ Some(move_authenticator)
2498+ } else {
2499+ None
2500+ }
2501+ })
2502+ .collect()
2503+ }
2504+
2505+ pub fn sender_move_authenticator(&self) -> Option<&MoveAuthenticator> {
2506+ let sender = self.intent_message().value.sender();
24732507
2474- if signatures.len() == 1 {
2475- if let GenericSignature::MoveAuthenticator(move_authenticator) = &signatures[0] {
2476- Some(move_authenticator)
2477- } else {
2478- None
2479- }
2480- } else {
2481- None
2482- }
2508+ self.move_authenticators()
2509+ .into_iter()
2510+ .find(|a| match a.address() {
2511+ Ok(addr) => addr == sender,
2512+ Err(_) => false,
2513+ })
24832514 }
24842515}
24852516
@@ -2512,7 +2543,7 @@ impl<S> Envelope<SenderSignedData, S> {
25122543 pub fn shared_input_objects(&self) -> impl Iterator<Item = SharedInputObject> + '_ {
25132544 // Add the Move authenticator shared objects if any.
25142545 let authenticator_shared_objects =
2515- if let Some(move_authenticator) = self.move_authenticator () {
2546+ if let Some(move_authenticator) = self.sender_move_authenticator () {
25162547 move_authenticator
25172548 .shared_objects()
25182549 .into_iter()
0 commit comments