Skip to content

Commit

Permalink
[cleanup] Rename PublicTransferObject to TransferObject (MystenLabs#2780
Browse files Browse the repository at this point in the history
)

- Rename recently renamed transaction based on feedback
  • Loading branch information
tnowacki authored Jun 28, 2022
1 parent 26f0f08 commit b83e558
Show file tree
Hide file tree
Showing 29 changed files with 816 additions and 832 deletions.
6 changes: 3 additions & 3 deletions crates/sui-core/src/execution_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use sui_types::{
event::{Event, TransferType},
gas::{self, SuiGasStatus},
messages::{
CallArg, ChangeEpoch, ExecutionStatus, MoveCall, MoveModulePublish, PublicTransferObject,
SingleTransactionKind, TransactionData, TransactionEffects, TransferSui,
CallArg, ChangeEpoch, ExecutionStatus, MoveCall, MoveModulePublish, SingleTransactionKind,
TransactionData, TransactionEffects, TransferObject, TransferSui,
},
object::Object,
storage::{BackingPackageStore, Storage},
Expand Down Expand Up @@ -117,7 +117,7 @@ fn execute_transaction<S: BackingPackageStore>(
// once across single tx, we should be able to run them in parallel.
for single_tx in transaction_data.kind.into_single_transactions() {
result = match single_tx {
SingleTransactionKind::PublicTransferObject(PublicTransferObject {
SingleTransactionKind::TransferObject(TransferObject {
recipient,
object_ref,
}) => {
Expand Down
24 changes: 11 additions & 13 deletions crates/sui-core/src/gateway_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ use crate::{
use sui_json::{resolve_move_function_args, SuiJsonCallArg, SuiJsonValue};
use sui_json_rpc_api::rpc_types::{
GetObjectDataResponse, GetRawObjectDataResponse, MergeCoinResponse, MoveCallParams,
PublicTransferObjectParams, PublishResponse, RPCTransactionRequestParams, SplitCoinResponse,
SuiMoveObject, SuiObject, SuiObjectInfo, SuiTransactionEffects, SuiTypeTag,
TransactionEffectsResponse, TransactionResponse,
PublishResponse, RPCTransactionRequestParams, SplitCoinResponse, SuiMoveObject, SuiObject,
SuiObjectInfo, SuiTransactionEffects, SuiTypeTag, TransactionEffectsResponse,
TransactionResponse, TransferObjectParams,
};

use crate::transaction_input_checker::InputObjects;
Expand Down Expand Up @@ -335,7 +335,7 @@ pub trait GatewayAPI {

/// Create a Batch Transaction that contains a vector of parameters needed to construct
/// all the single transactions in it.
/// Supported single transactions are PublicTransferObject and MoveCall.
/// Supported single transactions are TransferObject and MoveCall.
async fn batch_transaction(
&self,
signer: SuiAddress,
Expand Down Expand Up @@ -855,18 +855,16 @@ where

async fn create_public_transfer_object_transaction_kind(
&self,
params: PublicTransferObjectParams,
params: TransferObjectParams,
used_object_ids: &mut BTreeSet<ObjectID>,
) -> Result<SingleTransactionKind, anyhow::Error> {
used_object_ids.insert(params.object_id);
let object = self.get_object_internal(&params.object_id).await?;
let object_ref = object.compute_object_reference();
Ok(SingleTransactionKind::PublicTransferObject(
PublicTransferObject {
recipient: params.recipient,
object_ref,
},
))
Ok(SingleTransactionKind::TransferObject(TransferObject {
recipient: params.recipient,
object_ref,
}))
}

async fn create_move_call_transaction_kind(
Expand Down Expand Up @@ -1063,7 +1061,7 @@ where
recipient: SuiAddress,
) -> Result<TransactionData, anyhow::Error> {
let mut used_object_ids = BTreeSet::new();
let params = PublicTransferObjectParams {
let params = TransferObjectParams {
recipient,
object_id,
};
Expand Down Expand Up @@ -1110,7 +1108,7 @@ where
let mut used_object_ids = BTreeSet::new();
for param in single_transaction_params {
let kind = match param {
RPCTransactionRequestParams::PublicTransferObjectRequestParams(t) => {
RPCTransactionRequestParams::TransferObjectRequestParams(t) => {
self.create_public_transfer_object_transaction_kind(t, &mut used_object_ids)
.await?
}
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-core/src/transaction_input_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ where
.kind
.single_transactions()
.filter_map(|s| {
if let SingleTransactionKind::PublicTransferObject(t) = s {
if let SingleTransactionKind::TransferObject(t) = s {
Some(t.object_ref.0)
} else {
None
Expand Down
36 changes: 16 additions & 20 deletions crates/sui-core/src/unit_tests/batch_transaction_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,14 @@ async fn test_batch_transaction_ok() -> anyhow::Result<()> {
init_state_with_ids([sender; TOTAL].into_iter().zip(all_ids.clone().into_iter())).await;
let mut transactions = vec![];
for obj_id in all_ids.iter().take(N) {
transactions.push(SingleTransactionKind::PublicTransferObject(
PublicTransferObject {
recipient,
object_ref: authority_state
.get_object(obj_id)
.await?
.unwrap()
.compute_object_reference(),
},
));
transactions.push(SingleTransactionKind::TransferObject(TransferObject {
recipient,
object_ref: authority_state
.get_object(obj_id)
.await?
.unwrap()
.compute_object_reference(),
}));
}
let package_object_ref = authority_state.get_framework_object_ref().await?;
for _ in 0..N {
Expand Down Expand Up @@ -96,16 +94,14 @@ async fn test_batch_transaction_last_one_fail() -> anyhow::Result<()> {
init_state_with_ids([sender; TOTAL].into_iter().zip(all_ids.clone().into_iter())).await;
let mut transactions = vec![];
for obj_id in all_ids.iter().take(N) {
transactions.push(SingleTransactionKind::PublicTransferObject(
PublicTransferObject {
recipient,
object_ref: authority_state
.get_object(obj_id)
.await?
.unwrap()
.compute_object_reference(),
},
));
transactions.push(SingleTransactionKind::TransferObject(TransferObject {
recipient,
object_ref: authority_state
.get_object(obj_id)
.await?
.unwrap()
.compute_object_reference(),
}));
}
let package_object_ref = authority_state.get_framework_object_ref().await?;
transactions.push(SingleTransactionKind::Call(MoveCall {
Expand Down
10 changes: 4 additions & 6 deletions crates/sui-core/src/unit_tests/gas_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,10 @@ async fn execute_transfer_with_price(
.unwrap()
.unwrap();

let kind = TransactionKind::Single(SingleTransactionKind::PublicTransferObject(
PublicTransferObject {
recipient,
object_ref: object.compute_object_reference(),
},
));
let kind = TransactionKind::Single(SingleTransactionKind::TransferObject(TransferObject {
recipient,
object_ref: object.compute_object_reference(),
}));
let data =
TransactionData::new_with_gas_price(kind, sender, gas_object_ref, gas_budget, gas_price);
let signature = Signature::new(&data, &sender_key);
Expand Down
20 changes: 8 additions & 12 deletions crates/sui-core/src/unit_tests/gateway_state_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,18 +725,14 @@ async fn test_batch_transaction() {
);
let gateway = create_gateway_state(genesis_objects).await;
let params = vec![
RPCTransactionRequestParams::PublicTransferObjectRequestParams(
PublicTransferObjectParams {
object_id: coin_object1.id(),
recipient: addr2,
},
),
RPCTransactionRequestParams::PublicTransferObjectRequestParams(
PublicTransferObjectParams {
object_id: coin_object2.id(),
recipient: addr2,
},
),
RPCTransactionRequestParams::TransferObjectRequestParams(TransferObjectParams {
object_id: coin_object1.id(),
recipient: addr2,
}),
RPCTransactionRequestParams::TransferObjectRequestParams(TransferObjectParams {
object_id: coin_object2.id(),
recipient: addr2,
}),
RPCTransactionRequestParams::MoveCallRequestParams(MoveCallParams {
package_object_id: gateway.get_framework_object_ref().await.unwrap().0,
module: "bag".to_string(),
Expand Down
22 changes: 11 additions & 11 deletions crates/sui-core/tests/staged/sui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,6 @@ Owner:
Immutable: UNIT
PublicKeyBytes:
NEWTYPESTRUCT: BYTES
PublicTransferObject:
STRUCT:
- recipient:
TYPENAME: SuiAddress
- object_ref:
TUPLE:
- TYPENAME: ObjectID
- TYPENAME: SequenceNumber
- TYPENAME: ObjectDigest
SequenceNumber:
NEWTYPESTRUCT: U64
Signature:
Expand All @@ -245,9 +236,9 @@ SignedBatch:
SingleTransactionKind:
ENUM:
0:
PublicTransferObject:
TransferObject:
NEWTYPE:
TYPENAME: PublicTransferObject
TYPENAME: TransferObject
1:
Publish:
NEWTYPE:
Expand Down Expand Up @@ -295,6 +286,15 @@ TransactionKind:
NEWTYPE:
SEQ:
TYPENAME: SingleTransactionKind
TransferObject:
STRUCT:
- recipient:
TYPENAME: SuiAddress
- object_ref:
TUPLE:
- TYPENAME: ObjectID
- TYPENAME: SequenceNumber
- TYPENAME: ObjectDigest
TransferSui:
STRUCT:
- recipient:
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-json-rpc-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub trait RpcFullNodeReadApi {
pub trait RpcTransactionBuilder {
/// Create a transaction to transfer an object from one address to another. The object's type
/// must allow public transfers
#[method(name = "publicTransferObject")]
#[method(name = "transferObject")]
async fn public_transfer_object(
&self,
signer: SuiAddress,
Expand Down
24 changes: 11 additions & 13 deletions crates/sui-json-rpc-api/src/rpc_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ impl TryFrom<TransactionData> for SuiTransactionData {
#[serde(rename = "TransactionKind")]
pub enum SuiTransactionKind {
/// Initiate an object transfer between addresses
PublicTransferObject(SuiPublicTransferObject),
TransferObject(SuiTransferObject),
/// Publish a new Move module
Publish(SuiMovePackage),
/// Call a function in a published Move module
Expand All @@ -864,8 +864,8 @@ impl Display for SuiTransactionKind {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let mut writer = String::new();
match &self {
Self::PublicTransferObject(t) => {
writeln!(writer, "Transaction Kind : Public Transfer Object")?;
Self::TransferObject(t) => {
writeln!(writer, "Transaction Kind : Transfer Object")?;
writeln!(writer, "Recipient : {}", t.recipient)?;
writeln!(writer, "Object ID : {}", t.object_ref.object_id)?;
writeln!(writer, "Version : {:?}", t.object_ref.version)?;
Expand Down Expand Up @@ -915,12 +915,10 @@ impl TryFrom<SingleTransactionKind> for SuiTransactionKind {

fn try_from(tx: SingleTransactionKind) -> Result<Self, Self::Error> {
Ok(match tx {
SingleTransactionKind::PublicTransferObject(t) => {
Self::PublicTransferObject(SuiPublicTransferObject {
recipient: t.recipient,
object_ref: t.object_ref.into(),
})
}
SingleTransactionKind::TransferObject(t) => Self::TransferObject(SuiTransferObject {
recipient: t.recipient,
object_ref: t.object_ref.into(),
}),
SingleTransactionKind::TransferSui(t) => Self::TransferSui(SuiTransferSui {
recipient: t.recipient,
amount: t.amount,
Expand Down Expand Up @@ -1351,8 +1349,8 @@ impl SuiEvent {
}

#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename = "PublicTransferObject", rename_all = "camelCase")]
pub struct SuiPublicTransferObject {
#[serde(rename = "TransferObject", rename_all = "camelCase")]
pub struct SuiTransferObject {
pub recipient: SuiAddress,
pub object_ref: SuiObjectRef,
}
Expand Down Expand Up @@ -1445,13 +1443,13 @@ impl From<TypeTag> for SuiTypeTag {
#[derive(Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub enum RPCTransactionRequestParams {
PublicTransferObjectRequestParams(PublicTransferObjectParams),
TransferObjectRequestParams(TransferObjectParams),
MoveCallRequestParams(MoveCallParams),
}

#[derive(Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct PublicTransferObjectParams {
pub struct TransferObjectParams {
pub recipient: SuiAddress,
pub object_id: ObjectID,
}
Expand Down
Loading

0 comments on commit b83e558

Please sign in to comment.