NIP-90 Job Result compliance: Missing ability to set `content` field in DVM job result
AbdelStark opened this issue · 2 comments
Description
According to NIP-90, the result of a Data Vending Machine (DVM) Job should be placed in the content
field of the Nostr event. However, the current implementation of the job_result
function in the EventBuilder
doesn't seem to provide a way to set the content
field.
Current Behavior
The job_result
function in EventBuilder
doesn't allow setting the content
field of the event when creating a DVM job result.
Expected Behavior
There should be a way to set the content
field when creating a DVM job result event using the job_result
function or a similar method.
Question
Am I missing something, or is this functionality indeed missing from the current implementation?
Possible Solution
If this is indeed an issue, I'm willing to submit a PR to fix it. I've already implemented a change in my fork for my own needs: https://github.com/AbdelStark/nostr/tree/feature/nip-90-job-result-content
pub fn job_result(
job_request: Event,
content_payload: Option<String>,
amount_millisats: u64,
bolt11: Option<String>,
) -> Result<Self, Error> {
let kind: Kind = job_request.kind() + 1000;
if kind.is_job_result() {
let mut tags: Vec<Tag> = job_request
.tags
.iter()
.filter_map(|t| {
if t.kind()
== TagKind::SingleLetter(SingleLetterTag {
character: Alphabet::I,
uppercase: false,
})
{
Some(t.clone())
} else {
None
}
})
.collect();
tags.extend_from_slice(&[
Tag::event(job_request.id()),
Tag::public_key(job_request.author()),
Tag::from_standardized_without_cell(TagStandard::Request(job_request)),
Tag::from_standardized_without_cell(TagStandard::Amount {
millisats: amount_millisats,
bolt11,
}),
]);
Ok(Self::new(kind, content_payload.unwrap_or_default(), tags))
} else {
Err(Error::WrongKind {
received: kind,
expected: WrongKindError::Range(NIP90_JOB_RESULT_RANGE),
})
}
}
Thanks! I added
payload
arg at 5e8dd8f commit
Ok perfect, thanks for the responsiveness.