Skip to content

Commit 4c72075

Browse files
thephezclaude
andcommitted
fix(wasm-sdk): increment document revision for transfer transitions
When creating document transfer transitions, the code now properly increments the document's revision number before creating the transition. This ensures the transfer transition uses revision + 1 instead of the current revision, which is required for proper state transition validation on the platform. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent c38f5e8 commit 4c72075

File tree

1 file changed

+21
-1
lines changed
  • packages/wasm-sdk/src/state_transitions/documents

1 file changed

+21
-1
lines changed

packages/wasm-sdk/src/state_transitions/documents/mod.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,26 @@ impl WasmSdk {
965965
.map_err(|e| JsValue::from_str(&format!("Failed to fetch document: {}", e)))?
966966
.ok_or_else(|| JsValue::from_str("Document not found"))?;
967967

968+
// Get the current revision and increment it
969+
let current_revision = document.revision().unwrap_or(0);
970+
971+
// Create a modified document with incremented revision for the transfer transition
972+
let transfer_document = Document::V0(DocumentV0 {
973+
id: document.id(),
974+
owner_id: document.owner_id(),
975+
properties: document.properties().clone(),
976+
revision: Some(current_revision + 1),
977+
created_at: document.created_at(),
978+
updated_at: document.updated_at(),
979+
transferred_at: document.transferred_at(),
980+
created_at_block_height: document.created_at_block_height(),
981+
updated_at_block_height: document.updated_at_block_height(),
982+
transferred_at_block_height: document.transferred_at_block_height(),
983+
created_at_core_block_height: document.created_at_core_block_height(),
984+
updated_at_core_block_height: document.updated_at_core_block_height(),
985+
transferred_at_core_block_height: document.transferred_at_core_block_height(),
986+
});
987+
968988
// Fetch the identity to get the correct key
969989
let identity = dash_sdk::platform::Identity::fetch(&sdk, owner_identifier)
970990
.await
@@ -983,7 +1003,7 @@ impl WasmSdk {
9831003

9841004
// Create a transfer transition
9851005
let transition = BatchTransition::new_document_transfer_transition_from_document(
986-
document,
1006+
transfer_document,
9871007
document_type_ref,
9881008
recipient_identifier,
9891009
matching_key,

0 commit comments

Comments
 (0)