
    dh                         S SK r S SKrS SKJrJrJrJr  S SKJr  S SK	J
r
Jr  S SKJrJr   " S S\
5      r " S S	\5      rg)
    N)ListOptionalTypeUnion)AsyncCallbackManagerForToolRun)	BaseModelField)AINBaseToolOperationTypec                       \ rS rSr% Sr\" S5      r\\S'   \" SSS9r	\
\S'   \" SS	S9r\\\
\\
   4      \S
'   \" SSS9r\\   \S'   \" SSS9r\\   \S'   \" SSS9r\\   \S'   \" SSS9r\\   \S'   Srg)
RuleSchema   z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____firstlineno____doc__r	   r   r   __annotations__r   strr   r   r   r   r   boolr   r   r   __static_attributes__r       a/var/www/html/shao/venv/lib/python3.13/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                       \ rS rSr% SrSr\\S'   Sr\\S'   \	r
\\   \S'         SS	\S
\S\\\\\   4      S\\   S\\   S\\   S\\   S\\   S\4S jjrSrg)AINOwnerOps!   z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	                 D  #    SSK Jn	   U[        R                  L a  Uc*  U R                  R
                  R                  R                  n[        U[        5      (       a  U/nU R                  R                  R                  U5      R                  U	" SSU Vs0 sH/  nUU=(       d    SU=(       d    SU=(       d    SU=(       d    SS._M1     sn00S9S9I S h  vN n
O^U[        R                  L a<  U R                  R                  R                  U5      R                  5       I S h  vN n
O[        S	U S
35      e[         R"                  " U
SS9$ s  snf  N} N0! [$         a8  n[&        R(                  " U5      R*                   S[        U5       3s S nA$ S nAff = f7f)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"   _arunAINOwnerOps._arunI   s     	8	<}(((?"nn33BBJJGgs++&iG NN--11$7@@%>$ ( 4;+" 4; %,7B7Ke6@6IE:H:QE8D8M	.& %& 4;+"
'& A  " *** NN--11$7@@BB #7vQ!?@@::c66#+"	$ C  	<mmA&//03q6(;;	<sf   F BE 5EE EAE (E)(E F E E 
F%-FFF FF r   )NNNNNN)r   r   r   r   r   r'   r   r   r   r   r(   r   r   r   r   r   r   r   r   rE   r    r   r!   r"   r$   r$   !   s    $D#!K !D $.Ki- 48&*%))-'+@D*<*< *< %T#Y/0	*<
 d^*< TN*< !*< tn*< <=*< 
*< *<r!   r$   )rA   r>   typingr   r   r   r   langchain_core.callbacksr   pydanticr   r	   (langchain_community.tools.ainetwork.baser
   r   r   r$   r   r!   r"   <module>rK      s4      . . C % O ,R<+ R<r!   