-
Notifications
You must be signed in to change notification settings - Fork 45
Description
Description
Some *WithProof query methods use JsValue::UNDEFINED when there's no data to return, while others correctly use JsValue::NULL. When JsValue::UNDEFINED is used, the data property is omitted entirely from the JSON response (standard JS behavior - undefined values are not serialized).
Current behavior (inconsistent queries):
{
"metadata": { ... },
"proof": { ... }
}Expected behavior (all queries should match this):
{
"data": null,
"metadata": { ... },
"proof": { ... }
}Affected Methods (using JsValue::UNDEFINED - incorrect)
| File | Line | Method |
|---|---|---|
address.rs |
107 | getPlatformAddressWithProof |
address.rs |
152, 202 | getPlatformAddressesWithProof (per-address in map) |
group.rs |
945 | getGroupMembersWithProof |
token.rs |
847 | getTokenContractInfoWithProof |
token.rs |
893 | getTokenPerpetualDistributionLastClaimWithProof |
system.rs |
967 | getTotalCreditsInPlatformWithProof |
system.rs |
1004 | getPrefundedSpecializedBalanceWithProof |
Already Correct (using JsValue::NULL)
These methods already handle this correctly and can serve as reference:
identity.rs:354-getIdentityWithProofidentity.rs:594-getIdentityNonceWithProofidentity.rs:667-getIdentityContractNonceWithProofidentity.rs:1041-getIdentityBalanceWithProofidentity.rs:1089-getIdentitiesBalancesWithProofidentity.rs:1126-getIdentityBalanceAndRevisionWithProofidentity.rs:1168-getIdentityByPublicKeyHashWithProofdocument.rs:348, 383- document queriestoken.rs:659-getTokenTotalSupplyWithProof
Suggested Fix
Change .unwrap_or(JsValue::UNDEFINED) to .unwrap_or(JsValue::NULL) in the affected locations.
Example in system.rs:1004:
// Before
.unwrap_or(JsValue::UNDEFINED)
// After
.unwrap_or(JsValue::NULL)Impact
Consumers of the SDK cannot reliably check for "no data" vs "malformed response" when the data property is missing entirely. This was discovered via evo-sdk-website e2e tests which validate that all proof responses have { data, metadata, proof } structure.
Related to #2986