Skip to content

fix: update transition examples for evo-sdk v4 - #65

Draft
thepastaclaw wants to merge 24 commits into
dashpay:masterfrom
thepastaclaw:fix-v4-transition-examples
Draft

fix: update transition examples for evo-sdk v4#65
thepastaclaw wants to merge 24 commits into
dashpay:masterfrom
thepastaclaw:fix-v4-transition-examples

Conversation

@thepastaclaw

@thepastaclaw thepastaclaw commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace pre-v4 write examples with the shipped v4 typed payload, identity key, and signer flows
  • align identity, contract, document, token, DPNS/voting, and Platform Address metadata with @dashevo/evo-sdk@4.0.0
  • add declaration-backed regression checks for transition option names, required members, wrapper types, and generated query formatting
  • keep generated documentation checks stable when only the report timestamp changes

Closes #63.

Validation

  • python3 scripts/generate_docs.py
  • python3 scripts/check_documentation.py
  • npx vitest run — 151 tests passed
  • node --test tests/type-extraction.test.mjs — 6 tests passed
  • focused testnet transition E2E — 7/7 contract, document, and token workflows passed
  • full testnet transition E2E — 21 passed, 11 repository-defined skips, 3 fixture-only failures
  • git diff --check upstream/master..HEAD
  • mandatory exact-head pre-PR review — ship

Notes

public/docs.html is generated and gitignored; it was regenerated locally and covered by the documentation checker and transition-example tests. public/AI_REFERENCE.md is tracked and regenerated in this branch.

Network-writing tests used fresh standard-key identities and an identity-owned disposable token contract. Credit transfer/withdrawal, contract create/update, document CRUD, token mint/burn/transfer/freeze/unfreeze/destroy, and emergency actions passed. The three full-suite failures were fixture prerequisites: two later contract creates ran below the approximately 12 billion-credit testnet creation cost, and token claim used a fixture without perpetual distribution. Focused runs passed the affected contract/document paths when funded; no product defect was found.

The examples and regression tests were also validated against the exact installed @dashevo/evo-sdk@4.0.0 and @dashevo/wasm-sdk@4.0.0 declarations and runtime behavior.

Related: #64 contains the initial API-shape migration. This draft also resolves the remaining declaration and generated-example mismatches found during exact-version review, including address metadata, signer key purposes, identity-create key relationships, token fixtures, withdrawal destinations, and multiline query rendering.

thepastaclaw and others added 14 commits July 20, 2026 14:37
Replace pre-v4 privateKeyWif-in-call snippets with payload + identityKey/signer
(and asset-lock PrivateKey) examples sourced from shipped Options interfaces.
Stop multi-line example formatting from prefixing return on the first line and
drop stale sdk_example overrides for identity create/top-up.

Co-Authored-By: Claude <noreply@anthropic.com>
Apply the generator fixes for invented address/identifier helpers and
regenerate the committed AI_REFERENCE examples so they match the v4
payload + signer option shapes.

Co-Authored-By: Claude <noreply@anthropic.com>
Add unit coverage that loads generator transition examples, forbids
privateKeyWif-in-call option keys, and checks final sdk write options
against shipped wasm-sdk Options interfaces. Extend documentation check
with the classic issue dashpay#63 example patterns.

Co-Authored-By: Claude <noreply@anthropic.com>
sdk_params for those transitions already use the v4 names, so the
assetLockPrivateKeyWif rename map is unused.

Co-Authored-By: Claude <noreply@anthropic.com>
Reduce duplicated IdentitySigner and auth-key setup in generated state
transition docs, consolidate example formatting helpers, and slim the
issue dashpay#63 regression guards without changing example semantics.
AddressFundsWithdrawOptions requires pooling and outputScript values.
Use PoolingWasm.Standard and CoreScript.fromP2PKH instead of undefined
placeholders and the nonexistent CoreScript.newP2PKH helper.

Co-Authored-By: Claude <noreply@anthropic.com>
Top-up and identity-to-address transfer take Identity, not identityId.
Withdrawal requires coreFeePerByte, Pooling, CoreScript, and
PlatformAddressSigner. Asset-lock funding requires AssetLockProof,
PrivateKey, outputs, and a required PlatformAddressSigner.

Co-Authored-By: Claude <noreply@anthropic.com>
Assert withdraw examples use CoreScript.fromP2PKH/PoolingWasm, and that
top-up, transfer-from-identity, withdraw, and fund-from-asset-lock
sdk_params match v4 required option members/types.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Parsing the full wasm-sdk d.ts once per interface kept the option-key
suite near the default timeout after adding required-member checks.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 6ad8c7b9-ee08-4024-a885-e4064ef85d0d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

thepastaclaw and others added 6 commits July 20, 2026 16:10
Align Platform Address sdk_params with shipped v4 option types so
transfer, top-up, withdraw, transfer-from-identity, fund-from-asset-lock,
and create-identity document PlatformAddressInput[] / PlatformAddressOutput[]
instead of plain objects, and use PoolingWasm / concrete signer types.

Co-Authored-By: Claude <noreply@anthropic.com>
Restore valid top-level JS for multiline query snippets that start with
return await by wrapping pure expression examples as const result = await
... while leaving multi-statement transition examples intact.

Co-Authored-By: Claude <noreply@anthropic.com>
Add focused regression coverage for PlatformAddressInput[] /
PlatformAddressOutput[] metadata across address transitions and for
multiline AI_REFERENCE query examples becoming const result = await.

Co-Authored-By: Claude <noreply@anthropic.com>
Keep the previous report file when only the timestamp changes so docs
check success does not create noise commits. Restore the prior report
body from before the unexpected timestamp-only refresh.

Co-Authored-By: Claude <noreply@anthropic.com>
Omit signingKey on identity credit transfer/withdrawal examples so the
SDK selects a matching purpose key. Key ID 3 and AUTHENTICATION fallback
were invalid for v4 transfer semantics.
Assert generated transfer/withdrawal examples omit signingKey, document
TRANSFER (and OWNER for withdrawal), and never fall back to AUTHENTICATION.
@thepastaclaw thepastaclaw changed the title fix: update state transition examples for SDK v4 fix: update transition examples for evo-sdk v4 Jul 20, 2026
@thepastaclaw

thepastaclaw commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

⛔ Blockers found — Sonnet deferred (commit baf93a6)
Canonical validated blockers: 1

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preliminary review — Codex only

The current head still generates invalid signing-key selection logic for the DPNS and masternode voting examples. Both issues were introduced by this PR's v4 transition documentation work and can cause users following the generated examples to submit transitions with keys that fail Platform authorization.

Validated blockers were found in the Codex precheck. Sonnet is deferred until a fresh Codex revalidation clears the blocker gate.

Review provenance

  • Codex reviewers: gpt-5.6-sol — general (completed)
  • Verifier: gpt-5.6-sol — verifier
  • Sonnet: not run (deferred by blocker gate)

🔴 2 blocking

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `scripts/generate_docs.py`:
- [BLOCKING] scripts/generate_docs.py:1151-1154: Validate the DPNS signing key before accepting key ID 1
  The fixed-ID lookup bypasses the semantic checks in the fallback: if key ID 1 exists but has another purpose or security level, it is passed directly to `registerName`. DPNS registration creates document transitions whose default HIGH requirement permits CRITICAL or HIGH AUTHENTICATION keys; an arbitrary key ID is not guaranteed to satisfy those rules and will fail authorization. Select exclusively by purpose and an accepted security level, and report a clear error when no suitable key exists.
- [BLOCKING] scripts/generate_docs.py:1176-1178: Do not fall back to an arbitrary key for masternode voting
  When no VOTING-purpose key is found, the generated example falls back to key ID 0 without verifying its purpose. Masternode vote transitions explicitly require a VOTING key, so a typical key ID 0 with another purpose will fail authorization instead of producing a useful local error. The same fallback is duplicated in the `masternodeVote` example at lines 1204-1206; both examples must require a VOTING-purpose key and throw clearly if none is available.

Note: GitHub does not allow PastaClaw to submit an approval or request changes on their own PR, so the canonical verifier result is transported as a COMMENT review.

Comment thread scripts/generate_docs.py Outdated
Comment on lines +1151 to +1154
const identityKey = identity.getPublicKeyById(1)
|| identity.publicKeys.find(
k => k.purpose === 'AUTHENTICATION' && k.securityLevel === 'HIGH',
);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Blocking: Validate the DPNS signing key before accepting key ID 1

The fixed-ID lookup bypasses the semantic checks in the fallback: if key ID 1 exists but has another purpose or security level, it is passed directly to registerName. DPNS registration creates document transitions whose default HIGH requirement permits CRITICAL or HIGH AUTHENTICATION keys; an arbitrary key ID is not guaranteed to satisfy those rules and will fail authorization. Select exclusively by purpose and an accepted security level, and report a clear error when no suitable key exists.

Suggested change
const identityKey = identity.getPublicKeyById(1)
|| identity.publicKeys.find(
k => k.purpose === 'AUTHENTICATION' && k.securityLevel === 'HIGH',
);
const identityKey = identity.publicKeys.find(
k => k.purpose === 'AUTHENTICATION'
&& ['CRITICAL', 'HIGH'].includes(k.securityLevel),
);
if (!identityKey) {
throw new Error('No CRITICAL/HIGH authentication key available for DPNS registration');
}

source: ['codex']

Comment thread scripts/generate_docs.py Outdated
Comment on lines +1176 to +1178
const votingIdentity = await sdk.identities.fetch(masternodeProTxHash);
const votingKey = votingIdentity.publicKeys.find(k => k.purpose === 'VOTING')
|| votingIdentity.getPublicKeyById(0);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Blocking: Do not fall back to an arbitrary key for masternode voting

When no VOTING-purpose key is found, the generated example falls back to key ID 0 without verifying its purpose. Masternode vote transitions explicitly require a VOTING key, so a typical key ID 0 with another purpose will fail authorization instead of producing a useful local error. The same fallback is duplicated in the masternodeVote example at lines 1204-1206; both examples must require a VOTING-purpose key and throw clearly if none is available.

source: ['codex']

thepastaclaw and others added 3 commits July 31, 2026 13:43
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
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.

docs.html and AI_REFERENCE.md show pre-v4 API (privateKeyWif in calls) — v4 uses payload + identityKey + signer

1 participant