@@ -750,6 +750,22 @@ pub async fn get_balance_in_aligned(
750750 }
751751}
752752
753+ /// Unlocks the balance of a user in the Aligned payment service.
754+ ///
755+ /// This function initiates an unlock request for the user's balance. After calling this function,
756+ /// the user's balance will be locked for a certain period before it can be withdrawn.
757+ /// Use [`get_unlock_block_time`] to check when the balance can be withdrawn.
758+ ///
759+ /// # Arguments
760+ /// * `signer` - The signer middleware containing the user's wallet and provider.
761+ /// * `network` - The network on which the unlock operation will be performed.
762+ ///
763+ /// # Returns
764+ /// * The transaction receipt of the unlock operation.
765+ ///
766+ /// # Errors
767+ /// * `SendError` if there is an error sending the transaction.
768+ /// * `SubmitError` if there is an error submitting the transaction.
753769pub async fn unlock_balance_in_aligned (
754770 signer : & SignerMiddleware < Provider < Http > , LocalWallet > ,
755771 network : Network ,
@@ -772,6 +788,22 @@ pub async fn unlock_balance_in_aligned(
772788 }
773789}
774790
791+ /// Locks the balance of a user in the Aligned payment service.
792+ ///
793+ /// This function locks the user's balance, preventing it from being withdrawn.
794+ /// Locked balances can be used for proof verification payments but cannot be withdrawn
795+ /// until they are unlocked using [`unlock_balance_in_aligned`] and the unlock period expires.
796+ ///
797+ /// # Arguments
798+ /// * `signer` - The signer middleware containing the user's wallet and provider.
799+ /// * `network` - The network on which the lock operation will be performed.
800+ ///
801+ /// # Returns
802+ /// * The transaction receipt of the lock operation.
803+ ///
804+ /// # Errors
805+ /// * `SendError` if there is an error sending the transaction.
806+ /// * `SubmitError` if there is an error submitting the transaction.
775807pub async fn lock_balance_in_aligned (
776808 signer : & SignerMiddleware < Provider < Http > , LocalWallet > ,
777809 network : Network ,
@@ -794,6 +826,22 @@ pub async fn lock_balance_in_aligned(
794826 }
795827}
796828
829+ /// Returns the timestamp when a user's balance will be unlocked and available for withdrawal.
830+ ///
831+ /// After calling [`unlock_balance_in_aligned`], users must wait for the lock period
832+ /// before they can withdraw their funds using [`withdraw_balance_from_aligned`].
833+ ///
834+ /// # Arguments
835+ /// * `user` - The address of the user to check the unlock time for.
836+ /// * `eth_rpc_url` - The URL of the Ethereum RPC node.
837+ /// * `network` - The network on which to check the unlock time.
838+ ///
839+ /// # Returns
840+ /// * The timestamp when the user's balance will be unlocked (as u64).
841+ ///
842+ /// # Errors
843+ /// * `EthereumProviderError` if there is an error in the connection with the RPC provider.
844+ /// * `EthereumCallError` if there is an error in the Ethereum call.
797845pub async fn get_unlock_block_time (
798846 user : Address ,
799847 eth_rpc_url : & str ,
@@ -819,6 +867,22 @@ pub async fn get_unlock_block_time(
819867 }
820868}
821869
870+ /// Withdraws a specified amount from the user's balance in the Aligned payment service.
871+ ///
872+ /// This function can only be called after the balance has been unlocked using [`unlock_balance_in_aligned`]
873+ /// and the lock period has expired. Use [`get_unlock_block_time`] to check when the withdrawal becomes available.
874+ ///
875+ /// # Arguments
876+ /// * `signer` - The signer middleware containing the user's wallet and provider.
877+ /// * `network` - The network on which the withdrawal will be performed.
878+ /// * `amount` - The amount to withdraw from the user's balance.
879+ ///
880+ /// # Returns
881+ /// * The transaction receipt of the withdrawal operation.
882+ ///
883+ /// # Errors
884+ /// * `SendError` if there is an error sending the transaction.
885+ /// * `SubmitError` if there is an error submitting the transaction.
822886pub async fn withdraw_balance_from_aligned (
823887 signer : & SignerMiddleware < Provider < Http > , LocalWallet > ,
824888 network : Network ,
0 commit comments