Skip to content

Commit 7d485ab

Browse files
authored
owner: add support for ConsensusAddress Owner variant (#109)
This adds support for the new ConsensusAddress Owner variant which indicates that a single address has exclusive ownership of an object, but that the object is used as a "shared" input to transactions and version managmenet is handled by consensus similar to how this is done for shared objects.
1 parent 282157d commit 7d485ab

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

crates/sui-sdk-types/src/object.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,18 @@ pub enum Owner {
107107
),
108108
/// Object is immutable, and hence ownership doesn't matter.
109109
Immutable,
110+
111+
/// Object is exclusively owned by a single address and sequenced via consensus.
112+
ConsensusAddress {
113+
/// The version at which the object most recently became a consensus object.
114+
/// This serves the same function as `initial_shared_version`, except it may change
115+
/// if the object's Owner type changes.
116+
#[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
117+
start_version: Version,
118+
119+
/// The owner of the object.
120+
owner: Address,
121+
},
110122
}
111123

112124
/// Object data, either a package or struct

crates/sui-transaction-builder/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,9 @@ mod tests {
905905
panic!("Upgrade capability controlled by object")
906906
}
907907
sui_types::Owner::Immutable => panic!("Upgrade capability is stored immutably and cannot be used for upgrades"),
908+
sui_types::Owner::ConsensusAddress { .. } => {
909+
upgrade_cap = Some(tx.input(&obj))
910+
}
908911
};
909912
break;
910913
}

crates/sui-transaction-builder/src/unresolved.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,9 @@ impl From<&sui_types::Object> for Input {
309309
Owner::Object(_) => input,
310310
Owner::Shared(at_version) => input.with_initial_shared_version(*at_version),
311311
Owner::Immutable => input.with_immutable_kind(),
312+
Owner::ConsensusAddress { start_version, .. } => {
313+
input.with_initial_shared_version(*start_version)
314+
}
312315
}
313316
}
314317
}

0 commit comments

Comments
 (0)