Skip to content

Commit

Permalink
feat: updates on new V of name service contract (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro-Morales committed Jul 4, 2023
1 parent 73e751e commit 303131c
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 38 deletions.
2 changes: 1 addition & 1 deletion src/uagents/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AgentNetwork(Enum):
USER_PREFIX = "user"
CONTRACT_ALMANAC = "fetch1h5rhtj5m6dqjmufj5m3t4mq6l7cnd8dvaxclwmrk6tfdm0gy3lmszksf0s"
CONTRACT_NAME_SERVICE = (
"fetch1yrf4xpglq02fzj50m9wn44qdq89a5vr0ufa42qa506uhwal4n79s99sp87"
"fetch1mxz8kn3l5ksaftx8a9pj9a6prpzk2uhxnqdkwuqvuh37tw80xu6qges77l"
)
REGISTRATION_FEE = 500000000000000000
REGISTRATION_DENOM = "atestfet"
Expand Down
15 changes: 0 additions & 15 deletions src/uagents/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,6 @@ def is_owner(self, name: str, wallet_address: str):
permission = self.query(query_msg)["permissions"]
return permission == "admin"

def _get_ownership_msg(self, name: str, wallet_address: str):
return {
"update_ownership": {
"domain": f"{name}.agent",
"owner": {"address": {"address": wallet_address}},
"permissions": "admin",
}
}

def _get_registration_msg(self, name: str, address: str):
return {
"register": {
Expand All @@ -121,14 +112,8 @@ def get_registration_tx(self, name: str, wallet_address: str, agent_address: str

transaction = Transaction()

ownership_msg = self._get_ownership_msg(name, wallet_address)
registration_msg = self._get_registration_msg(name, agent_address)

transaction.add_message(
create_cosmwasm_execute_msg(
wallet_address, CONTRACT_NAME_SERVICE, ownership_msg
)
)
transaction.add_message(
create_cosmwasm_execute_msg(
wallet_address, CONTRACT_NAME_SERVICE, registration_msg
Expand Down
22 changes: 0 additions & 22 deletions tests/test_agent_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,6 @@ def test_alamanc_failed_registration(self):
"Shouldn't be registered on alamanac",
)

def test_name_service_ownership(self):
agent = Agent()
fund_agent_if_low(agent.wallet.address())

ownership_msg = agent._service_contract._get_ownership_msg(
agent.name, str(agent.wallet.address())
)

transaction = agent._service_contract.execute(ownership_msg, agent.wallet)

transaction.wait_to_complete()

is_owner = agent._service_contract.is_owner(
agent.name, str(agent.wallet.address())
)

self.assertEqual(is_owner, True, "Domain ownership failed")

def test_name_service_failed_ownership(self):
agent = Agent()

Expand Down Expand Up @@ -110,14 +92,10 @@ def test_registration(self):
)
self.assertEqual(is_owner, False)

ownership_msg = agent._service_contract._get_ownership_msg(
agent.name, str(agent.wallet.address())
)
registration_msg = agent._service_contract._get_registration_msg(
agent.name, agent.address
)

agent._service_contract.execute(ownership_msg, agent.wallet).wait_to_complete()
agent._service_contract.execute(
registration_msg, agent.wallet
).wait_to_complete()
Expand Down

0 comments on commit 303131c

Please sign in to comment.