
    Ng                         d dl Z d dlZd dlmZ d dlmZmZmZmZ d dl	m
Z
 d dlmZmZ d dlmZ  G d dee          Z G d	 d
e          Z G d de          ZdS )    N)Enum)ListOptionalTypeUnion)AsyncCallbackManagerForToolRun)	BaseModelField)AINBaseToolc                       e Zd ZdZdZdZdS )AppOperationTypez$Type of app operation as enumerator.	SET_ADMIN
GET_CONFIGN)__name__
__module____qualname____doc__r   r        c/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain_community/tools/ainetwork/app.pyr   r      s        ..IJJJr   r   c                       e Zd ZU dZ ed          Zeed<    edd          Ze	ed<    edd          Z
eee	ee	         f                  ed	<   dS )
	AppSchemazSchema for app operations..typez)Name of the application on the blockchain)descriptionappNameNzKA single address or a list of addresses. Default: current session's addressaddress)r   r   r   r   r
   r   r   __annotations__r   strr   r   r   r   r   r   r   r   r      s         $$"U3ZZD
'''5*UVVVGSVVV/4u0 0 0GXeCcN+,     r   r   c                       e Zd ZU dZdZeed<   dZeed<   eZ	e
e         ed<   	 	 dded	ed
eeeee         f                  dee         def
dZdS )	AINAppOpszTool for app operations.	AINappOpsnamea7  
Create an app in the AINetwork Blockchain database by creating the /apps/<appName> path.
An address set as `admin` can grant `owner` rights to other addresses (refer to `AINownerOps` for more details).
Also, `admin` is initialized to have all `owner` permissions and `rule` allowed for that path.

## appName Rule
- [a-z_0-9]+

## address Rules
- 0x[0-9a-fA-F]{40}
- Defaults to the current session's address
- Multiple addresses can be specified if needed

## SET_ADMIN Example 1
- type: SET_ADMIN
- appName: ain_project

### Result:
1. Path /apps/ain_project created.
2. Current session's address registered as admin.

## SET_ADMIN Example 2
- type: SET_ADMIN
- appName: test_project
- address: [<address1>, <address2>]

### Result:
1. Path /apps/test_project created.
2. <address1> and <address2> registered as admin.

r   args_schemaNr   r   r   run_managerreturnc                   K   ddl m} ddlm} 	 |t          j        u r|| j        j        j        j	        }t          |t                    r|g}| j        j                            d| d |                                            |dd |D             i          	           d {V }n]|t          j        u r<| j        j                            d| d
                                           d {V }nt#          d| d          t%          j        |d          S # t(          $ r5}t+          j        |          j         dt          |           cY d }~S d }~ww xY w)Nr   )ValueOnlyTransactionInput)getTimestampz/manage_app/z/create/adminc                     i | ]}|d S )Tr   ).0r   s     r   
<dictcomp>z#AINAppOps._arun.<locals>.<dictcomp>[   s    (N(N(N7$(N(N(Nr   )value)transactionInputz/configzUnsupported 'type': .F)ensure_asciiz: )	ain.typesr'   	ain.utilsr(   r   r   	interfacewalletdefaultAccountr   
isinstancer   dbrefsetValuer   getValue
ValueErrorjsondumps	Exceptionbuiltinsr   r   )	selfr   r   r   r$   r'   r(   reses	            r   _arunzAINAppOps._arunF   s      	877777******	<'111?"n3BJGgs++ (&iG N-11D7DDLLNNDD (%>%>&(N(Ng(N(N(NO& & &         )444 N-1137333 (**      !!?!?!?!?@@@:c6666 	< 	< 	<mA&&/;;3q66;;;;;;;;	<s   DD 
E)*EEE)NN)r   r   r   r   r"   r   r   r   r   r#   r   r	   r   r   r   r   r   rC   r   r   r   r    r    !   s         ""D#K   > $-Ki,,, 48@D <  < <  < %T#Y/0	 <
 <= < 
 <  <  <  <  <  <r   r    )r?   r<   enumr   typingr   r   r   r   langchain_core.callbacksr   pydanticr	   r
   (langchain_community.tools.ainetwork.baser   r   r   r   r    r   r   r   <module>rI      s           . . . . . . . . . . . . C C C C C C % % % % % % % % @ @ @ @ @ @    sD       	   E< E< E< E< E< E< E< E< E< E<r   