Skip to content

Commit

Permalink
[move] Removed unnecessary parameter to transfer_internal (MystenLabs…
Browse files Browse the repository at this point in the history
…#5985)

* [move] Removed unnecessary parameter to transfer_internal

* Updated genesis snapshot
  • Loading branch information
awelc authored Nov 10, 2022
1 parent d2be035 commit 7b1c3c1
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 24 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ expression: common_costs_estimate
---
{
"MergeCoin": {
"computation_cost": 5533,
"storage_cost": 8167,
"computation_cost": 5532,
"storage_cost": 8165,
"storage_rebate": 0
},
"Publish": {
"computation_cost": 5522,
"storage_cost": 8102,
"computation_cost": 5521,
"storage_cost": 8101,
"storage_rebate": 0
},
"SharedCounterAssertValue": {
Expand All @@ -30,7 +30,7 @@ expression: common_costs_estimate
},
"SplitCoin": {
"computation_cost": 5511,
"storage_cost": 8134,
"storage_cost": 8133,
"storage_rebate": 0
},
"TransferPortionSuiCoin": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ expression: common_costs_actual
"storage_rebate": 0
},
"Publish": {
"computation_cost": 724,
"computation_cost": 723,
"storage_cost": 83,
"storage_rebate": 0
},
Expand All @@ -29,7 +29,7 @@ expression: common_costs_actual
"storage_rebate": 15
},
"SplitCoin": {
"computation_cost": 795,
"computation_cost": 793,
"storage_cost": 80,
"storage_rebate": 0
},
Expand Down
6 changes: 3 additions & 3 deletions crates/sui-framework/docs/transfer.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ unique ID.

<pre><code><b>public</b> <b>fun</b> <a href="transfer.md#0x2_transfer">transfer</a>&lt;T: key&gt;(obj: T, recipient: <b>address</b>) {
// TODO: emit <a href="event.md#0x2_event">event</a>
<a href="transfer.md#0x2_transfer_transfer_internal">transfer_internal</a>(obj, recipient, <b>false</b>)
<a href="transfer.md#0x2_transfer_transfer_internal">transfer_internal</a>(obj, recipient)
}
</code></pre>

Expand Down Expand Up @@ -123,7 +123,7 @@ in this transaction. This restriction may be relaxed in the future.



<pre><code><b>fun</b> <a href="transfer.md#0x2_transfer_transfer_internal">transfer_internal</a>&lt;T: key&gt;(obj: T, recipient: <b>address</b>, to_object: bool)
<pre><code><b>fun</b> <a href="transfer.md#0x2_transfer_transfer_internal">transfer_internal</a>&lt;T: key&gt;(obj: T, recipient: <b>address</b>)
</code></pre>


Expand All @@ -132,7 +132,7 @@ in this transaction. This restriction may be relaxed in the future.
<summary>Implementation</summary>


<pre><code><b>native</b> <b>fun</b> <a href="transfer.md#0x2_transfer_transfer_internal">transfer_internal</a>&lt;T: key&gt;(obj: T, recipient: <b>address</b>, to_object: bool);
<pre><code><b>native</b> <b>fun</b> <a href="transfer.md#0x2_transfer_transfer_internal">transfer_internal</a>&lt;T: key&gt;(obj: T, recipient: <b>address</b>);
</code></pre>


Expand Down
11 changes: 5 additions & 6 deletions crates/sui-framework/sources/transfer.move
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module sui::transfer {
/// unique ID.
public fun transfer<T: key>(obj: T, recipient: address) {
// TODO: emit event
transfer_internal(obj, recipient, false)
transfer_internal(obj, recipient)
}

/// Freeze `obj`. After freezing `obj` becomes immutable and can no
Expand All @@ -32,7 +32,7 @@ module sui::transfer {
/// in this transaction. This restriction may be relaxed in the future.
public native fun share_object<T: key>(obj: T);

native fun transfer_internal<T: key>(obj: T, recipient: address, to_object: bool);
native fun transfer_internal<T: key>(obj: T, recipient: address);

// Cost calibration functions
#[test_only]
Expand All @@ -54,14 +54,13 @@ module sui::transfer {
}

#[test_only]
public fun calibrate_transfer_internal<T: key>(obj: T, recipient: address, to_object: bool) {
transfer_internal(obj, recipient, to_object);
public fun calibrate_transfer_internal<T: key>(obj: T, recipient: address) {
transfer_internal(obj, recipient);
}
#[test_only]
public fun calibrate_transfer_internal_nop<T: key + drop>(obj: T, recipient: address, to_object: bool) {
public fun calibrate_transfer_internal_nop<T: key + drop>(obj: T, recipient: address) {
let _ = obj;
let _ = recipient;
let _ = to_object;
}

}
9 changes: 2 additions & 7 deletions crates/sui-framework/src/natives/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,12 @@ pub fn transfer_internal(
mut args: VecDeque<Value>,
) -> PartialVMResult<NativeResult> {
debug_assert!(ty_args.len() == 1);
debug_assert!(args.len() == 3);
debug_assert!(args.len() == 2);

let ty = ty_args.pop().unwrap();
let to_object = pop_arg!(args, bool);
let recipient = pop_arg!(args, AccountAddress);
let obj = args.pop_back().unwrap();
let owner = if to_object {
Owner::ObjectOwner(recipient.into())
} else {
Owner::AddressOwner(recipient.into())
};
let owner = Owner::AddressOwner(recipient.into());
object_runtime_transfer(context, owner, ty, obj)?;
// Charge a constant native gas cost here, since
// we will charge it properly when processing
Expand Down

0 comments on commit 7b1c3c1

Please sign in to comment.