-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feat) Updated queries and messages from the Permissions module to su…
…pport the new version
- Loading branch information
Showing
57 changed files
with
2,317 additions
and
1,183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import asyncio | ||
import os | ||
|
||
import dotenv | ||
|
||
from pyinjective.composer import Composer as ProtoMsgComposer | ||
from pyinjective.core.broadcaster import MsgBroadcasterWithPk | ||
from pyinjective.core.network import Network | ||
from pyinjective.wallet import PrivateKey | ||
|
||
|
||
async def main() -> None: | ||
dotenv.load_dotenv() | ||
private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY") | ||
|
||
# select network: local, testnet, mainnet | ||
network = Network.devnet() | ||
composer = ProtoMsgComposer(network=network.string()) | ||
|
||
message_broadcaster = MsgBroadcasterWithPk.new_using_simulation( | ||
network=network, | ||
private_key=private_key_in_hexa, | ||
) | ||
|
||
priv_key = PrivateKey.from_hex(private_key_in_hexa) | ||
pub_key = priv_key.to_public_key() | ||
address = pub_key.to_address() | ||
|
||
denom = "factory/inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r/inj_test" | ||
|
||
role1 = composer.permissions_role( | ||
name="EVERYONE", | ||
role_id=0, | ||
permissions=composer.PERMISSIONS_ACTION["UNSPECIFIED"], # revoke all permissions | ||
) | ||
role2 = composer.permissions_role( | ||
name="user", | ||
role_id=2, | ||
permissions=composer.PERMISSIONS_ACTION["RECEIVE"] | composer.PERMISSIONS_ACTION["SEND"], | ||
) | ||
|
||
role_manager = composer.permissions_role_manager( | ||
manager="inj1manageraddress", | ||
roles=["admin", "user"], | ||
) | ||
|
||
policy_status1 = composer.permissions_policy_status( | ||
action=composer.PERMISSIONS_ACTION["MINT"], | ||
is_disabled=True, | ||
is_sealed=False, | ||
) | ||
policy_status2 = composer.permissions_policy_status( | ||
action=composer.PERMISSIONS_ACTION["BURN"], | ||
is_disabled=False, | ||
is_sealed=True, | ||
) | ||
|
||
policy_manager_capability = composer.permissions_policy_manager_capability( | ||
manager="inj1policymanageraddress", | ||
action=composer.PERMISSIONS_ACTION["MODIFY_ROLE_PERMISSIONS"], | ||
can_disable=True, | ||
can_seal=False, | ||
) | ||
|
||
message = composer.msg_update_namespace( | ||
sender=address.to_acc_bech32(), | ||
denom=denom, | ||
contract_hook="inj19ld6swyldyujcn72j7ugnu9twafhs9wxlyye5m", | ||
role_permissions=[role1, role2], | ||
role_managers=[role_manager], | ||
policy_statuses=[policy_status1, policy_status2], | ||
policy_manager_capabilities=[policy_manager_capability], | ||
) | ||
|
||
# broadcast the transaction | ||
result = await message_broadcaster.broadcast([message]) | ||
print("---Transaction Response---") | ||
print(result) | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.get_event_loop().run_until_complete(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
46 changes: 0 additions & 46 deletions
46
examples/chain_client/permissions/5_MsgRevokeNamespaceRoles.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import asyncio | ||
|
||
from pyinjective.async_client import AsyncClient | ||
from pyinjective.core.network import Network | ||
|
||
|
||
async def main() -> None: | ||
network = Network.testnet() | ||
client = AsyncClient(network) | ||
|
||
denom = "inj" | ||
vouchers = await client.fetch_permissions_vouchers(denom=denom) | ||
print(vouchers) | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.get_event_loop().run_until_complete(main()) |
Oops, something went wrong.