Skip to content

Commit

Permalink
First pre-auditing pass
Browse files Browse the repository at this point in the history
  • Loading branch information
tifrel committed Nov 21, 2022
1 parent c386962 commit 2781f2d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
9 changes: 6 additions & 3 deletions factory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ impl Default for MintbaseStoreFactory {

#[near_bindgen]
impl MintbaseStoreFactory {
pub fn assert_only_owner(&self) {
/// Panics if not called by the factory owner
fn assert_only_owner(&self) {
assert_one_yocto();
assert_eq!(
env::predecessor_account_id(),
Expand All @@ -76,7 +77,7 @@ impl MintbaseStoreFactory {

/// Sufficient attached deposit is defined as enough to deploy a `Store`,
/// plus enough left over for the mintbase deployment cost.
pub fn assert_sufficient_attached_deposit(&self) {
fn assert_sufficient_attached_deposit(&self) {
let min = storage_bytes::STORE as u128 * self.storage_price_per_byte + self.mintbase_fee;
assert!(
env::attached_deposit() >= min,
Expand All @@ -86,6 +87,7 @@ impl MintbaseStoreFactory {
);
}

/// Panics if a store with the requested ID already exists
pub fn assert_no_store_with_id(
&self,
store_id: String,
Expand Down Expand Up @@ -119,7 +121,7 @@ impl MintbaseStoreFactory {
(storage_bytes::STORE as u128 * self.storage_price_per_byte + self.mintbase_fee).into()
}

/// The sum of `mintbase_fee` and `STORE_STORAGE`.
/// Public key that will be attached to any created store.
pub fn get_admin_public_key(&self) -> &PublicKey {
&self.admin_public_key
}
Expand Down Expand Up @@ -213,6 +215,7 @@ impl MintbaseStoreFactory {
}
}

/// Initialization
#[init(ignore_state)]
pub fn new() -> Self {
assert!(!env::state_exists());
Expand Down
2 changes: 1 addition & 1 deletion simple-market-contract
2 changes: 1 addition & 1 deletion store/src/burning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl MintbaseStore {
log_nft_batch_burn(&token_ids, account_id.to_string());
}

/// Get info about the store.
/// Log store info.
pub fn get_info(&self) {
let s = format!("owner: {}", self.owner_id);
env::log_str(s.as_str());
Expand Down
25 changes: 25 additions & 0 deletions store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,25 @@ impl MintbaseStore {
Self { metadata, ..old }
}

/// Intended to introduce a consistent storage scheme to all stores.
/// This migration is currently paused because of problems with
/// MyNearWallet.
///
/// Pros for the migration:
///
/// - More flexibility
/// - Enables usage of multiple storage providers
/// - Reduces dependence on arweave
/// - Current inconsistency causes a lot of confusion, but all of the NEAR
/// NFT ecosystem is already fragmented in their usage of `base_uri`
///
/// Cons for the migration:
///
/// - Gas costs
/// - Permanently increased storage costs
/// - Very slim probability for data corruption (worked fine on testnet),
/// which should also be reversible
/// - Will require partial reindexing
#[private]
pub fn prepend_base_uri(
&mut self,
Expand All @@ -231,6 +250,12 @@ impl MintbaseStore {
self.metadata.base_uri = None;
}

#[private]
pub fn repair_reference(&mut self) {
// FIXME: repair nearcon2demo1.minstpace2.testnet -> remove `nan/` prefixes on reference
self.metadata.base_uri = None;
}

// -------------------------- internal methods -------------------------

/// If allow_moves is false, disallow token owners from calling
Expand Down

0 comments on commit 2781f2d

Please sign in to comment.