
    h                         d dl Z d dl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mZ  G d de
      Z G d d	e      Zy)
    N)ListOptionalTypeUnion)AsyncCallbackManagerForToolRun)	BaseModelField)AINBaseToolOperationTypec                      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	<    ed
d      Zee   ed<    ed
d      Zee   ed<    ed
d      Zee   ed<    ed
d      Zee   ed<   y)
RuleSchemazSchema for owner operations..typezBlockchain reference path)descriptionpathNz'A single address or a list of addressesaddressFz2Authority to edit the `owner` property of the pathwrite_ownerz+Authority to edit `write rule` for the path
write_rulez(Authority to `set function` for the pathwrite_functionz,Authority to initialize `owner` of sub-pathsbranch_owner)__name__
__module____qualname____doc__r	   r   r   __annotations__r   strr   r   r   r   r   boolr   r   r        g/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/langchain_community/tools/ainetwork/owner.pyr   r      s    &*D-$c'BCD#C/4C0GXeCcN+,  #(O#K$  "'H"J  &+E&NHTN  $)I$L(4. 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e   dee   dee   dee   defdZy)AINOwnerOpszTool for owner operations.AINownerOpsnamea  
Rules for `owner` in AINetwork Blockchain database.
An address set as `owner` can modify permissions according to its granted authorities

## Path Rule
- (/[a-zA-Z_0-9]+)+
- Permission checks ascend from the most specific (child) path to broader (parent) paths until an `owner` is located.

## Address Rules
- 0x[0-9a-fA-F]{40}: 40-digit hexadecimal address
- *: All addresses permitted
- Defaults to the current session's address

## SET
- `SET` alters permissions for specific addresses, while other addresses remain unaffected.
- When removing an address of `owner`, set all authorities for that address to false.
- message `write_owner permission evaluated false` if fail

### Example
- type: SET
- path: /apps/langchain
- address: [<address 1>, <address 2>]
- write_owner: True
- write_rule: True
- write_function: True
- branch_owner: True

## GET
- Provides all addresses with `owner` permissions and their authorities in the path.

### Example
- type: GET
- path: /apps/langchain
r   args_schemaNr   r   r   r   r   r   r   run_managerreturnc	                   K   ddl m}	 	 |t        j                  u r|*| j                  j
                  j                  j                  }t        |t              r|g}| j                  j                  j                  |      j                   |	dd|D ci c]  }||xs d|xs d|xs d|xs dd c}ii             d {   }
n]|t        j                  u r<| j                  j                  j                  |      j                          d {   }
nt        d	| d
      t!        j"                  |
d      S c c}w 7 ~7 2# t$        $ r7}t'        j(                  |      j*                   dt        |       cY d }~S d }~ww xY ww)Nr   )ValueOnlyTransactionInputz.ownerownersF)r   r   r   r   )value)transactionInputzUnsupported 'type': .)ensure_asciiz: )	ain.typesr(   r   SET	interfacewalletdefaultAccountr   
isinstancer   dbrefsetOwnerGETgetOwner
ValueErrorjsondumps	Exceptionbuiltinsr   r   )selfr   r   r   r   r   r   r   r%   r(   reses               r   _arunzAINOwnerOps._arunI   s~     	8	<}(((?"nn33BBJJGgs+&iG NN--11$7@@%>$ ( 4;+" )0 %,7B7Ke6@6IE:H:QE8D8M	.& %&+"
'& A  " *** NN--11$7@@BB #7vQ!?@@::c66#+"	$ C  	<mmA&//03q6(;;	<sf   FBE D<0E EAE E*E ;F<E E 	F,F :F;F FF)NNNNNN)r   r   r   r   r#   r   r   r   r   r$   r   r   r   r   r   r   r   r   rA   r   r   r   r!   r!   !   s    $D#!K !D $.Ki- 48&*%))-'+@D*<*< *< %T#Y/0	*<
 d^*< TN*< !*< tn*< <=*< 
*<r   r!   )r=   r:   typingr   r   r   r   langchain_core.callbacksr   pydanticr   r	   (langchain_community.tools.ainetwork.baser
   r   r   r!   r   r   r   <module>rF      s4      . . C % O ,R<+ R<r   