Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor Cleanups #390

Merged
merged 1 commit into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fastpay_core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ pub struct AuthorityState {

/// The authority state encapsulates all state, drives execution, and ensures safety.
///
/// Note the authority operations can be accesessed through a read reaf (&) and do not
/// Note the authority operations can be accesessed through a read ref (&) and do not
/// require &mut. Internally a database is syncronized through a mutex lock.
///
/// Repeating commands should produce no changes and return no error.
/// Repeating valid commands should produce no changes and return no error.
impl AuthorityState {
/// The logic to check one object against a reference, and return the object if all is well
/// or an error if not.
Expand Down
2 changes: 1 addition & 1 deletion fastx_types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ pub enum FastPayError {
ModuleDeserializationFailure { error: String },
#[error("Failed to publish the Move module(s), reason: {error:?}.")]
ModulePublishFailure { error: String },
#[error("Failed to build Move modules")]
#[error("Failed to build Move modules: {error:?}.")]
ModuleBuildFailure { error: String },
#[error("Dependent package not found on-chain: {package_id:?}")]
DependentPackageNotFound { package_id: ObjectID },
Expand Down
16 changes: 0 additions & 16 deletions fastx_types/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,22 +387,6 @@ impl Order {
self.signature.check(&self.kind, *self.sender())
}

// TODO: support orders with multiple objects, each with their own sequence number (https://github.com/MystenLabs/fastnft/issues/8)
pub fn sequence_number(&self) -> SequenceNumber {
use OrderKind::*;
match &self.kind {
Transfer(t) => t.object_ref.1,
Publish(_) => SequenceNumber::new(), // modules are immutable, seq # is always 0
Call(c) => {
assert!(
c.object_arguments.is_empty(),
"Unimplemented: non-gas object arguments"
);
c.gas_payment.1
}
}
}

/// Return the metadata of each of the input objects for the order.
/// For a Move object, we attach the object reference;
/// for a Move package, we provide the object id only since they never change on chain.
Expand Down
48 changes: 0 additions & 48 deletions fastx_types/src/object.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Mysten Labs
// SPDX-License-Identifier: Apache-2.0

use move_core_types::ident_str;
use serde::{Deserialize, Serialize};
use serde_bytes::ByteBuf;
use serde_with::{serde_as, Bytes};
Expand All @@ -11,8 +10,6 @@ use std::convert::{TryFrom, TryInto};
use move_binary_format::CompiledModule;
use move_core_types::{account_address::AccountAddress, language_storage::StructTag};

use crate::id::ID;
use crate::FASTX_FRAMEWORK_ADDRESS;
use crate::{
base_types::{
sha3_hash, Authenticator, BcsSignable, FastPayAddress, ObjectDigest, ObjectID, ObjectRef,
Expand All @@ -21,10 +18,6 @@ use crate::{
gas_coin::GasCoin,
};

pub const OBJECT_BASICS_MODULE_NAME: &move_core_types::identifier::IdentStr =
ident_str!("ObjectBasics");
pub const OBJECT_BASICS_OBJECT_TYPE_NAME: &move_core_types::identifier::IdentStr =
ident_str!("Object");
pub const GAS_VALUE_FOR_TESTING: u64 = 100000_u64;
pub const OBJECT_START_VERSION: SequenceNumber = SequenceNumber::from_u64(1);

Expand All @@ -37,13 +30,6 @@ pub struct MoveObject {
read_only: bool,
}

/// ObjectBasics in the Framework uses an object of the following format
#[derive(Debug, Deserialize, Serialize)]
pub struct ObjectBasicsObject {
pub id: ID,
pub value: u64,
}

/// Byte encoding of a 64 byte unsigned integer in BCS
type BcsU64 = [u8; 8];
/// Index marking the end of the object's ID + the beginning of its version
Expand Down Expand Up @@ -313,40 +299,6 @@ impl Object {
Self::with_id_owner_gas_for_testing(id, SequenceNumber::new(), owner, GAS_VALUE_FOR_TESTING)
}

/// Create ObjectBasics object for use in Move object operation
pub fn with_id_owner_object_basics_object_for_testing(
id: ObjectID,
version: SequenceNumber,
owner: FastPayAddress,
value: u64,
) -> Self {
// Check ObjectBasics.move in Framework for details
// Create struct tag for ObjectBasics object
let struct_tag = StructTag {
address: FASTX_FRAMEWORK_ADDRESS,
name: OBJECT_BASICS_OBJECT_TYPE_NAME.to_owned(),
module: OBJECT_BASICS_MODULE_NAME.to_owned(),
type_params: Vec::new(),
};

// An object in ObjectBasics is a struct of an ID and a u64 value
let obj = ObjectBasicsObject {
id: ID::new(id, version),
value,
};

let data = Data::Move(MoveObject {
type_: struct_tag,
contents: bcs::to_bytes(&obj).unwrap(),
read_only: false,
});
Self {
owner: Authenticator::Address(owner),
data,
previous_transaction: TransactionDigest::genesis(),
}
}

/// Create Coin object for use in Move object operation
pub fn with_id_owner_gas_coin_object_for_testing(
id: ObjectID,
Expand Down