Skip to content

Handle Reject Scenario when Responding Job #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions virtuals_acp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,20 +310,31 @@ def respond_to_job_memo(
) -> str:

try:
tx_hash = self.contract_manager.sign_memo(self.agent_address, memo_id, accept, reason or "")
time.sleep(10)

print(f"Responding to job {job_id} with memo {memo_id} and accept {accept} and reason {reason}")
self.contract_manager.create_memo(
self.agent_address,
job_id,
f"{reason if reason else f'Job {job_id} accepted.'}",
MemoType.MESSAGE,
is_secured=False,
next_phase=ACPJobPhase.TRANSACTION
)
if accept:
self.contract_manager.sign_memo(self.agent_address, memo_id, accept, reason or "")
time.sleep(10)

transaction_result = self.contract_manager.create_memo(
self.agent_address,
job_id,
f"{reason if reason else f'Job {job_id} accepted.'}",
MemoType.MESSAGE,
is_secured=False,
next_phase=ACPJobPhase.TRANSACTION
)
else:
transaction_result = self.contract_manager.create_memo(
self.agent_address,
job_id,
f"{reason if reason else f'Job {job_id} rejected.'}",
MemoType.MESSAGE,
is_secured=False,
next_phase=ACPJobPhase.REJECTED
)

print(f"Responded to job {job_id} with memo {memo_id} and accept {accept} and reason {reason}")
return tx_hash
return transaction_result
except Exception as e:
print(f"Error in respond_to_job_memo: {e}")
raise
Expand Down