Skip to content

Commit c5a66c0

Browse files
authored
fix(wallet): correct version for vaults in substates table (#1308)
Description --- fix(wallet): correct version for vaults in substates table Motivation and Context --- Bug in the transaction result handling caused the account version to be used instead of the vault substate version. How Has This Been Tested? --- Manually (partially) What process can a PR reviewer use to test or verify this change? --- Breaking Changes --- - [x] None - [ ] Requires data directory to be deleted - [ ] Other - Please specify <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Updated the transaction processing logic for improved consistency and stability in wallet operations. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent aad784a commit c5a66c0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

dan_layer/wallet/sdk/src/apis/transaction.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ where
339339

340340
for owned_id in value.referenced_substates() {
341341
if let Some(pos) = rest.iter().position(|(addr, _)| addr == &owned_id) {
342-
let (_, s) = rest.swap_remove(pos);
342+
let (_, child) = rest.swap_remove(pos);
343343
// If there was a previous parent for this substate, we keep it as is.
344344
let parent = downed_substates_with_parents
345345
.get(&owned_id)
@@ -353,7 +353,7 @@ where
353353
tx.substates_upsert_child(
354354
transaction_id,
355355
vault.account_address.clone(),
356-
VersionedSubstateId::new(owned_id, substate.version()),
356+
VersionedSubstateId::new(owned_id, child.version()),
357357
[vault.resource_address.into()].into_iter().collect(),
358358
)?;
359359
if let Some(resource) = tx.substates_get(&vault.resource_address.into()).optional()? {
@@ -367,8 +367,8 @@ where
367367
} else {
368368
tx.substates_upsert_root(
369369
transaction_id,
370-
VersionedSubstateId::new(owned_id, substate.version()),
371-
[(*s.substate_value().vault().unwrap().resource_address()).into()]
370+
VersionedSubstateId::new(owned_id, child.version()),
371+
[(*child.substate_value().vault().unwrap().resource_address()).into()]
372372
.into_iter()
373373
.collect(),
374374
None,
@@ -382,7 +382,7 @@ where
382382
tx.substates_upsert_child(
383383
transaction_id,
384384
parent,
385-
VersionedSubstateId::new(owned_id, s.version()),
385+
VersionedSubstateId::new(owned_id, child.version()),
386386
maybe_substate
387387
.map(|s| s.referenced_substates.into_iter().collect())
388388
.unwrap_or_default(),

0 commit comments

Comments
 (0)