Skip to content

Commit

Permalink
[framework] Adds sui::pay module for wallet functionality (MystenLabs…
Browse files Browse the repository at this point in the history
…#5018)

* adds sui::pay module for wallet functionality

sui::pay

- now has only functions that work with Coins;
- all of the functions of the sui::pay are entry functions;
- coin::keep is now pay::keep and coin::join is re-exported into pay::join making the latter a silver bullet for wallet functionality

sui::coin

- contains Coin-Balance transformers (also keeps methods like coin::put(Balance, Coin))
- keeps minting / burning functions as well as anything that involves TreasuryCap
- the rest of the methods are returning Coin (eg divide_into_n is moved to coin)
  • Loading branch information
damirka authored Oct 13, 2022
1 parent 682708d commit 1b55e6a
Show file tree
Hide file tree
Showing 22 changed files with 797 additions and 413 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

//# view-object 100

//# run sui::coin::split_and_transfer --type-args sui::sui::SUI --args object(100) 10 @B --sender A
//# run sui::pay::split_and_transfer --type-args sui::sui::SUI --args object(100) 10 @B --sender A

//# view-object 100

//# view-object 106

//# run sui::coin::split_and_transfer --type-args sui::sui::SUI --args object(100) 0 @C --sender B
//# run sui::pay::split_and_transfer --type-args sui::sui::SUI --args object(100) 0 @C --sender B

//# view-object 100

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions crates/sui-core/src/gateway_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -867,21 +867,21 @@ where
SingleTransactionKind::Call(move_call) => {
self.metrics.num_tx_movecall.inc();
if move_call.package == self.get_framework_object_ref().await?
&& move_call.module.as_ref() == coin::COIN_MODULE_NAME
&& move_call.module.as_ref() == coin::PAY_MODULE_NAME
{
if move_call.function.as_ref() == coin::COIN_SPLIT_VEC_FUNC_NAME {
if move_call.function.as_ref() == coin::PAY_SPLIT_VEC_FUNC_NAME {
self.metrics.num_tx_splitcoin.inc();
return Ok(Some(
self.create_split_coin_response(certificate, effects, false)
.await?,
));
} else if move_call.function.as_ref() == coin::COIN_SPLIT_N_FUNC_NAME {
} else if move_call.function.as_ref() == coin::PAY_SPLIT_N_FUNC_NAME {
self.metrics.num_tx_splitcoin_equal.inc();
return Ok(Some(
self.create_split_coin_response(certificate, effects, true)
.await?,
));
} else if move_call.function.as_ref() == coin::COIN_JOIN_FUNC_NAME {
} else if move_call.function.as_ref() == coin::PAY_JOIN_FUNC_NAME {
self.metrics.num_tx_mergecoin.inc();
return Ok(Some(
self.create_merge_coin_response(certificate, effects)
Expand Down Expand Up @@ -1554,8 +1554,8 @@ where
let data = TransactionData::new_move_call(
signer,
self.get_framework_object_ref().await?,
coin::COIN_MODULE_NAME.to_owned(),
coin::COIN_SPLIT_VEC_FUNC_NAME.to_owned(),
coin::PAY_MODULE_NAME.to_owned(),
coin::PAY_SPLIT_VEC_FUNC_NAME.to_owned(),
vec![coin_type],
gas,
vec![
Expand Down Expand Up @@ -1585,8 +1585,8 @@ where
let data = TransactionData::new_move_call(
signer,
self.get_framework_object_ref().await?,
coin::COIN_MODULE_NAME.to_owned(),
coin::COIN_SPLIT_N_FUNC_NAME.to_owned(),
coin::PAY_MODULE_NAME.to_owned(),
coin::PAY_SPLIT_N_FUNC_NAME.to_owned(),
vec![coin_type],
gas,
vec![
Expand Down Expand Up @@ -1623,8 +1623,8 @@ where
let data = TransactionData::new_move_call(
signer,
self.get_framework_object_ref().await?,
coin::COIN_MODULE_NAME.to_owned(),
coin::COIN_JOIN_FUNC_NAME.to_owned(),
coin::PAY_MODULE_NAME.to_owned(),
coin::PAY_JOIN_FUNC_NAME.to_owned(),
vec![coin_type],
gas,
vec![
Expand Down
14 changes: 7 additions & 7 deletions crates/sui-cost/tests/empirical_transaction_cost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use sui_config::ValidatorInfo;
use sui_cost::estimator::estimate_transaction_computation_cost;
use sui_cost::estimator::CommonTransactionCosts;
use sui_types::base_types::SuiAddress;
use sui_types::coin::COIN_JOIN_FUNC_NAME;
use sui_types::coin::COIN_MODULE_NAME;
use sui_types::coin::COIN_SPLIT_VEC_FUNC_NAME;
use sui_types::coin::PAY_JOIN_FUNC_NAME;
use sui_types::coin::PAY_MODULE_NAME;
use sui_types::coin::PAY_SPLIT_VEC_FUNC_NAME;
use sui_types::crypto::AccountKeyPair;
use sui_types::messages::Transaction;
use sui_types::object::Object;
Expand Down Expand Up @@ -70,8 +70,8 @@ async fn split_n_tx(

move_transaction_with_type_tags(
gas.clone(),
COIN_MODULE_NAME.as_str(),
COIN_SPLIT_VEC_FUNC_NAME.as_str(),
PAY_MODULE_NAME.as_str(),
PAY_SPLIT_VEC_FUNC_NAME.as_str(),
get_framework_object(validator_info)
.await
.compute_object_reference(),
Expand Down Expand Up @@ -151,8 +151,8 @@ async fn create_txes(

let merge_tx = move_transaction_with_type_tags(
gas_objects.pop().unwrap(),
COIN_MODULE_NAME.as_str(),
COIN_JOIN_FUNC_NAME.as_str(),
PAY_MODULE_NAME.as_str(),
PAY_JOIN_FUNC_NAME.as_str(),
get_framework_object(configs.validator_set())
.await
.compute_object_reference(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ expression: common_costs_estimate
---
{
"MergeCoin": {
"computation_cost": 6244,
"storage_cost": 6256,
"computation_cost": 6289,
"storage_cost": 6324,
"storage_rebate": 0
},
"Publish": {
"computation_cost": 6233,
"storage_cost": 6192,
"computation_cost": 6279,
"storage_cost": 6260,
"storage_rebate": 0
},
"SharedCounterAssertValue": {
Expand All @@ -29,8 +29,8 @@ expression: common_costs_estimate
"storage_rebate": 0
},
"SplitCoin": {
"computation_cost": 6222,
"storage_cost": 6224,
"computation_cost": 6268,
"storage_cost": 6292,
"storage_rebate": 0
},
"TransferPortionSuiCoin": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ expression: common_costs_actual
---
{
"MergeCoin": {
"computation_cost": 2510,
"computation_cost": 2515,
"storage_cost": 30,
"storage_rebate": 0
},
"Publish": {
"computation_cost": 2546,
"computation_cost": 2551,
"storage_cost": 82,
"storage_rebate": 0
},
Expand All @@ -29,7 +29,7 @@ expression: common_costs_actual
"storage_rebate": 15
},
"SplitCoin": {
"computation_cost": 2520,
"computation_cost": 2525,
"storage_cost": 75,
"storage_rebate": 0
},
Expand Down
Loading

0 comments on commit 1b55e6a

Please sign in to comment.