Skip to content

Commit

Permalink
chore: replace FastPay -> Sui
Browse files Browse the repository at this point in the history
  • Loading branch information
huitseeker committed Feb 11, 2022
1 parent 71e5fc9 commit 39d9339
Show file tree
Hide file tree
Showing 35 changed files with 450 additions and 511 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $ cargo test

## Coding Guidelines for Rust code

For detailed guidance on how to contribute to the Rust code in the Fastpay repository refer to [Coding Guidelines](https://developers.libra.org/docs/coding-guidelines).
For detailed guidance on how to contribute to the Rust code in the Sui repository refer to [Coding Guidelines](https://developers.libra.org/docs/coding-guidelines).

## Pull Requests

Expand Down
6 changes: 3 additions & 3 deletions fastpay/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ use strum_macros::EnumString;

#[derive(Debug, Clone, StructOpt)]
#[structopt(
name = "FastPay Benchmark",
about = "Local end-to-end test and benchmark of the FastPay protocol"
name = "Sui Benchmark",
about = "Local end-to-end test and benchmark of the Sui protocol"
)]
struct ClientServerBenchmark {
/// Hostname
Expand All @@ -43,7 +43,7 @@ struct ClientServerBenchmark {
/// Base port number
#[structopt(long, default_value = "9555")]
port: u16,
/// Size of the FastPay committee
/// Size of the Sui committee
#[structopt(long, default_value = "10")]
committee_size: usize,
/// Maximum number of requests in flight (0 for blocking client)
Expand Down
20 changes: 10 additions & 10 deletions fastpay/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct AuthorityConfig {
serialize_with = "address_as_hex",
deserialize_with = "address_from_hex"
)]
pub address: FastPayAddress,
pub address: SuiAddress,
pub host: String,
pub base_port: u16,
pub database_path: String,
Expand Down Expand Up @@ -104,7 +104,7 @@ pub struct UserAccount {
serialize_with = "address_as_hex",
deserialize_with = "address_from_hex"
)]
pub address: FastPayAddress,
pub address: SuiAddress,
pub key: KeyPair,
pub object_refs: BTreeMap<ObjectID, ObjectRef>,
pub gas_object_ids: BTreeSet<ObjectID>, // Every id in gas_object_ids should also be in object_ids.
Expand All @@ -114,7 +114,7 @@ pub struct UserAccount {

impl UserAccount {
pub fn new(
address: FastPayAddress,
address: SuiAddress,
key: KeyPair,
object_refs: Vec<ObjectRef>,
gas_object_ids: Vec<ObjectID>,
Expand Down Expand Up @@ -195,13 +195,13 @@ impl MoveCallConfig {
}

pub struct AccountsConfig {
accounts: BTreeMap<FastPayAddress, UserAccount>,
accounts: BTreeMap<SuiAddress, UserAccount>,
}

impl AccountsConfig {
/// Beware: this removes the account from the `AccountConfig` map!
/// better make sure we only use this once per account!
pub fn remove(&mut self, address: &FastPayAddress) -> Option<UserAccount> {
pub fn remove(&mut self, address: &SuiAddress) -> Option<UserAccount> {
self.accounts.remove(address)
}

Expand All @@ -226,7 +226,7 @@ impl AccountsConfig {
self.accounts.values_mut()
}

pub fn addresses(&mut self) -> impl Iterator<Item = &FastPayAddress> {
pub fn addresses(&mut self) -> impl Iterator<Item = &SuiAddress> {
self.accounts.keys()
}

Expand Down Expand Up @@ -284,7 +284,7 @@ impl AccountsConfig {

#[derive(Serialize, Deserialize)]
pub struct InitialStateConfigEntry {
pub address: FastPayAddress,
pub address: SuiAddress,
pub objects: Vec<Object>,
}
#[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -334,7 +334,7 @@ pub struct AccountInfo {
serialize_with = "address_as_hex",
deserialize_with = "address_from_hex"
)]
pub address: FastPayAddress,
pub address: SuiAddress,
pub key_pair: KeyPair,
}

Expand All @@ -344,7 +344,7 @@ pub struct AuthorityInfo {
serialize_with = "address_as_hex",
deserialize_with = "address_from_hex"
)]
pub address: FastPayAddress,
pub address: SuiAddress,
pub host: String,
pub base_port: u16,
}
Expand All @@ -355,7 +355,7 @@ pub struct AuthorityPrivateInfo {
serialize_with = "address_as_hex",
deserialize_with = "address_from_hex"
)]
pub address: FastPayAddress,
pub address: SuiAddress,
pub key_pair: KeyPair,
pub host: String,
pub port: u16,
Expand Down
22 changes: 11 additions & 11 deletions fastpay/src/wallet_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ use fastpay_core::authority_client::AuthorityClient;
use fastpay_core::client::{Client, ClientState};
use fastx_network::network::NetworkClient;
use fastx_types::base_types::{
decode_address_hex, encode_address_hex, get_key_pair, AuthorityName, FastPayAddress, ObjectID,
PublicKeyBytes,
decode_address_hex, encode_address_hex, get_key_pair, AuthorityName, ObjectID, PublicKeyBytes,
SuiAddress,
};
use fastx_types::committee::Committee;
use fastx_types::messages::{ExecutionStatus, OrderEffects};

use crate::utils::Config;
use fastx_types::error::FastPayError;
use fastx_types::error::SuiError;
use move_core_types::identifier::Identifier;
use move_core_types::language_storage::TypeTag;
use move_core_types::parser::{parse_transaction_argument, parse_type_tag};
Expand Down Expand Up @@ -327,7 +327,7 @@ fn make_authority_clients(

pub struct WalletContext {
pub config: WalletConfig,
pub client_states: BTreeMap<FastPayAddress, ClientState<AuthorityClient>>,
pub client_states: BTreeMap<SuiAddress, ClientState<AuthorityClient>>,
}

impl WalletContext {
Expand All @@ -338,7 +338,7 @@ impl WalletContext {
}
}

pub fn find_owner(&self, object_id: &ObjectID) -> Result<FastPayAddress, FastPayError> {
pub fn find_owner(&self, object_id: &ObjectID) -> Result<SuiAddress, SuiError> {
self.client_states
.iter()
.find_map(|(owner, client_state)| {
Expand All @@ -349,14 +349,14 @@ impl WalletContext {
}
})
.copied()
.ok_or(FastPayError::ObjectNotFound {
.ok_or(SuiError::ObjectNotFound {
object_id: *object_id,
})
}

pub fn get_or_create_client_state(
&mut self,
owner: &FastPayAddress,
owner: &SuiAddress,
) -> Result<&mut ClientState<AuthorityClient>, anyhow::Error> {
Ok(if !self.client_states.contains_key(owner) {
let new_client = self.create_client_state(owner)?;
Expand All @@ -368,8 +368,8 @@ impl WalletContext {

fn create_client_state(
&self,
owner: &FastPayAddress,
) -> Result<ClientState<AuthorityClient>, FastPayError> {
owner: &SuiAddress,
) -> Result<ClientState<AuthorityClient>, SuiError> {
let client_info = self.get_account_info(owner)?;

let voting_rights = self
Expand All @@ -395,11 +395,11 @@ impl WalletContext {
)
}

pub fn get_account_info(&self, address: &FastPayAddress) -> Result<&AccountInfo, FastPayError> {
pub fn get_account_info(&self, address: &SuiAddress) -> Result<&AccountInfo, SuiError> {
self.config
.accounts
.iter()
.find(|info| &info.address == address)
.ok_or(FastPayError::AccountNotFound)
.ok_or(SuiError::AccountNotFound)
}
}
Loading

0 comments on commit 39d9339

Please sign in to comment.