@@ -2811,3 +2811,139 @@ def admin_create_account(
28112811 endpoint = Path .ADMIN_ACCOUNTS ,
28122812 login = login ,
28132813 ).send_sync (config = config , json_payload = payload , headers = headers or {})
2814+
2815+ def admin_account_sign (
2816+ self ,
2817+ network : str ,
2818+ alias : str ,
2819+ owner_identifier : str ,
2820+ owner_type : str ,
2821+ input_pairs : List [Tuple [str , Any ]],
2822+ hash_message : Optional [bool ] = False ,
2823+ user_identifier : Optional [str ] = None ,
2824+ user_type : Optional [str ] = None ,
2825+ headers : Optional [dict ] = None ,
2826+ login : Login = None ,
2827+ config : ConnectionConfig = None ,
2828+ ) -> dict :
2829+ """
2830+ POST ``/admin/blockchain/{name}/sign/``
2831+
2832+ Sign on behalf of a user.
2833+
2834+ :param network: The blockchain name.
2835+ :type network: str
2836+ :param alias: The account alias.
2837+ :type alias: str
2838+ :param owner_identifier: The account owner.
2839+ :type owner_identifier: str
2840+ :param owner_type: The account owner type. One of User or Organisation.
2841+ :type owner_type: str
2842+ :param user_identifier: The requesting user.
2843+ :type user_identifier: str
2844+ :param user_type: The requesting user type. One of User or SimbaIdentity. Required if owner is an organisation.
2845+ :type user_type: Optional[str]
2846+ :param input_pairs: A list of tuples defining the data type and data to sign.
2847+ :type input_pairs: List[Tuple(str, Any)]
2848+ :param hash_message: Whether to hash the message before signing or not
2849+ :type hash_message: Optional[bool]. Default False
2850+
2851+ :Keyword Arguments:
2852+ * **headers** (`Optional[dict]`) - additional http headers
2853+ * **login** (`Optional[Login]`)
2854+ * **config** (`Optional[ConnectionConfig]`)
2855+ :return: a signed data structure.
2856+ :rtype: dict
2857+ """
2858+ if owner_type == "Organisation" and (not user_identifier or not user_type ):
2859+ raise ValueError ("Owner is an org but user or user type is not given." )
2860+ payload = {
2861+ "account" : {
2862+ "identifier" : {
2863+ "type" : "Alias" ,
2864+ "value" : alias
2865+ },
2866+ "owner" : {
2867+ "type" : owner_type ,
2868+ "identifier" : owner_identifier
2869+ }
2870+ },
2871+ "data" : {
2872+ "input_pairs" : [list (t ) for t in input_pairs ],
2873+ "hash_message" : hash_message ,
2874+ }
2875+ }
2876+ if owner_type == "Organisation" :
2877+ payload ["account" ]["user" ] = {
2878+ "type" : user_type ,
2879+ "identifier" : user_identifier
2880+ }
2881+ return SimbaRequest (
2882+ method = "POST" ,
2883+ endpoint = Path .ADMIN_BLOCKCHAIN_SIGN .create (network ),
2884+ login = login ,
2885+ ).send_sync (config = config , json_payload = payload , headers = headers or {})
2886+
2887+ def admin_account_validate (
2888+ self ,
2889+ network : str ,
2890+ alias : str ,
2891+ owner_identifier : str ,
2892+ owner_type : str ,
2893+ user_identifier : Optional [str ] = None ,
2894+ user_type : Optional [str ] = None ,
2895+ headers : Optional [dict ] = None ,
2896+ login : Login = None ,
2897+ config : ConnectionConfig = None ,
2898+ ) -> dict :
2899+ """
2900+ POST ``/admin/blockchain/{name}/validate/``
2901+
2902+ Validate the user has access to the given wallet.
2903+
2904+ :param network: The blockchain name.
2905+ :type network: str
2906+ :param alias: The account alias.
2907+ :type alias: str
2908+ :param owner_identifier: The account owner.
2909+ :type owner_identifier: str
2910+ :param owner_type: The account owner type. One of User or Organisation.
2911+ :type owner_type: str
2912+ :param user_identifier: The requesting user.
2913+ :type user_identifier: str
2914+ :param user_type: The requesting user type. One of User or SimbaIdentity. Required if owner is an organisation.
2915+ :type user_type: Optional[str]
2916+
2917+ :Keyword Arguments:
2918+ * **headers** (`Optional[dict]`) - additional http headers
2919+ * **login** (`Optional[Login]`)
2920+ * **config** (`Optional[ConnectionConfig]`)
2921+ :return: a signed data structure.
2922+ :rtype: dict
2923+ """
2924+ if owner_type == "Organisation" and (not user_identifier or not user_type ):
2925+ raise ValueError ("Owner is an org but user or user type is not given." )
2926+ payload = {
2927+ "account" : {
2928+ "identifier" : {
2929+ "type" : "Alias" ,
2930+ "value" : alias
2931+ },
2932+ "owner" : {
2933+ "type" : owner_type ,
2934+ "identifier" : owner_identifier
2935+ }
2936+ }
2937+ }
2938+ if owner_type == "Organisation" :
2939+ payload ["account" ]["user" ] = {
2940+ "type" : user_type ,
2941+ "identifier" : user_identifier
2942+ }
2943+ return SimbaRequest (
2944+ method = "POST" ,
2945+ endpoint = Path .ADMIN_BLOCKCHAIN_VALIDATE .create (network ),
2946+ login = login ,
2947+ ).send_sync (config = config , json_payload = payload , headers = headers or {})
2948+
2949+
0 commit comments