Skip to content

fix: car-sales tutorial — match actual evo-sdk API#6

Open
thepastaclaw wants to merge 1 commit into
developfrom
fix/car-sales-tutorial
Open

fix: car-sales tutorial — match actual evo-sdk API#6
thepastaclaw wants to merge 1 commit into
developfrom
fix/car-sales-tutorial

Conversation

@thepastaclaw
Copy link
Copy Markdown
Owner

Adds a corrected version of the Car Sales tutorial that compiles against @dashevo/evo-sdk@3.1.0-dev.1.

Changes from original tutorial

API Tutorial (broken) Fixed
contracts.publish() { identityId, documentSchemas, privateKeyWif } { dataContract: DataContract, identityKey, signer: IdentitySigner }
documents.create() { contractId, documentType, document: {...} } { document: new Document({...}), identityKey, signer }
documents.query() contractId, documentType dataContractId, documentTypeName
documents.replace() { documentId, document: {...} } Fetch existing doc, mutate .properties, bump .revision
contract.getId() method call contract.id (property getter)
doc.getData() method call doc.properties
identity.getPublicKeys() method call identity.publicKeys (property)

npx tsc --noEmit passes with zero errors.

Resolves #3

- contracts.publish(): construct DataContract + IdentitySigner, not simplified fields
- documents.create(): construct Document object with proper properties
- documents.query(): dataContractId/documentTypeName instead of contractId/documentType
- documents.replace(): fetch existing doc, modify, increment revision
- doc.properties instead of doc.getData()
- contract.id instead of contract.getId()
- Identity properties (.publicKeys) instead of methods (.getPublicKeys())

TypeScript compiles clean against @dashevo/evo-sdk@3.1.0-dev.1.

Resolves #3
@thepastaclaw thepastaclaw force-pushed the fix/car-sales-tutorial branch from cae3e4e to 55033c0 Compare April 2, 2026 14:33
@thepastaclaw
Copy link
Copy Markdown
Owner Author

✅ Live Testnet Run — All Steps Passed

Ran the car sales tutorial end-to-end on testnet with identity HHjmkbcwqFzToaoyvQcP45JZro7PoczAv7Nii57uYPX1.

Published: FZiA9xeDYZ47AmRm5aHea9X94kXNqBDds2aS2gu3T8cw
Listing created!
Query: 1 results
  Toyota Camry $22500 available
Updated to sold!
Review created!
Reviews: 1
  rating: 5 Great!

=== CAR SALES: ALL STEPS PASSED ===

Additional issues discovered during live testing

These are NOT just API name mismatches — they would prevent any tutorial from working even with the correct method signatures:

  1. Schema properties require position fields — DPP requires each property to have a position: N field. The tutorials omit this entirely.
  2. Indexed string properties need maxLength <= 63 — The tutorial uses maxLength: 64 for indexed fields like make and status, but the platform rejects values >63 for indexed strings.
  3. Index sort direction only supports asc — The tutorial uses orderBy: [["rating", "desc"]] but the platform only accepts asc in index definitions.
  4. identityNonce needs +1sdk.identities.nonce() returns the last used nonce; DataContract constructor needs the next one (nonce + 1n).
  5. Integer properties return as bigint — When queried back, integer fields come as bigint. When passing them back to replace(), they must be converted to number or the platform rejects them with "not of type integer".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Car Sales tutorial: API mismatches with evo-sdk@3.1.0-dev.1

1 participant