InventoryGrantRequest inventory.grant-request@1

Generated at from openvibe-contracts v0.127.0 and openvibe-sdk v0.37.0.

Version
1.0.0
Owner
inventory
Visibility
public
Status
active
Compatibility
backward
Decision
ADR-054
Schema
https://openvibe.network/contracts/inventory/grant-request.v1.json

An issuer grants one instance of a definition it issued to a person (inventory.item.grant). Idempotent per idempotency_key: a repeat answers the instance already granted. A capped definition that is sold out answers 409 inventory.supply_exhausted.

Fields

FieldTypeRequiredDescriptionConstraints
definition_idstringyes
  • pattern ^itd_[0-9A-HJKMNP-TV-Z]{26}$
subjectstringyes
  • pattern ^usr_[0-9A-HJKMNP-TV-Z]{26}$
idempotency_keystringyes
  • minLength 8
  • maxLength 128
originenum
  • one of "granted", "earned"
  • default "granted"
reasonstringShown in the ledger: what the person did (a quest, an event, a milestone).
  • maxLength 200
attributesobject

Examples

From the contract's own test fixtures: valid ones validate, rejected ones must fail.

Valid: quest
{
  "definition_id": "itd_01JZ00000000000000000001TD",
  "subject": "usr_01JZ0000000000000000000AAA",
  "idempotency_key": "quest-0000-0001",
  "origin": "earned",
  "reason": "Completed the first-stream quest"
}
Rejected: bought-origin
{
  "definition_id": "itd_01JZ00000000000000000001TD",
  "subject": "usr_01JZ0000000000000000000AAA",
  "idempotency_key": "k-12345678",
  "origin": "bought"
}
Rejected: short-key
{
  "definition_id": "itd_01JZ00000000000000000001TD",
  "subject": "usr_01JZ0000000000000000000AAA",
  "idempotency_key": "k"
}

Validate

const contracts = require('openvibe-contracts');
contracts.validate('inventory.grant-request@1', value);   // { valid, errors: [{ path, message }] }