Skip to content
This repository was archived by the owner on May 1, 2025. It is now read-only.

Commit c84db2e

Browse files
committed
Prepare testnet reverse migration
1 parent ad06e0c commit c84db2e

File tree

3 files changed

+16
-35
lines changed

3 files changed

+16
-35
lines changed

factory/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use mintbase_deps::constants::{
99
gas,
1010
storage_bytes,
1111
storage_stake,
12-
NO_DEPOSIT,
1312
YOCTO_PER_BYTE,
1413
};
1514
use mintbase_deps::interfaces::factory_self;

simple-market-contract

store/src/lib.rs

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -216,37 +216,31 @@ impl MintbaseStore {
216216
/// which should also be reversible
217217
/// - Will require partial reindexing
218218
#[private]
219-
pub fn prepend_base_uri(
219+
pub fn set_reference_media(
220220
&mut self,
221-
base_uri: String,
222-
token_ids_with_media: Vec<(String, Option<String>)>,
221+
specs: Vec<(String, Option<String>, Option<String>)>,
223222
) {
224-
for (token_id, media) in token_ids_with_media
225-
.iter()
226-
.map(|(id, media)| (id.parse::<u64>().unwrap(), media))
227-
{
228-
let metadata_id = self.tokens.get(&token_id).unwrap().metadata_id;
223+
for (token_id, reference, media) in specs {
224+
let metadata_id = self
225+
.tokens
226+
.get(&token_id.parse().unwrap())
227+
.unwrap()
228+
.metadata_id;
229229
let (n, mut metadata) = self.token_metadata.get(&metadata_id).unwrap();
230-
metadata.reference = concat_uri(&base_uri, &metadata.reference);
231-
metadata.media = concat_uri(&base_uri, &media);
230+
metadata.reference = reference;
231+
metadata.media = media;
232232
self.token_metadata.insert(&metadata_id, &(n, metadata));
233233
}
234234
}
235235

236236
/// Drops the base_uri after successfully migration all tokens with
237237
/// `prepend_base_uri`
238238
#[private]
239-
pub fn drop_base_uri(&mut self) {
240-
self.metadata.base_uri = None;
241-
}
242-
243-
/// While prepending and dropping base_uri, I destroyed
244-
/// nearcon2demo1.mintspace2.testnet, and one day I might wish to repair it
245-
/// using this method.
246-
#[private]
247-
pub fn repair_reference(&mut self) {
248-
// FIXME: repair nearcon2demo1.minstpace2.testnet -> remove `nan/` prefixes on reference
249-
self.metadata.base_uri = None;
239+
pub fn set_base_uri(
240+
&mut self,
241+
base_uri: Option<String>,
242+
) {
243+
self.metadata.base_uri = base_uri;
250244
}
251245

252246
// -------------------------- internal methods -------------------------
@@ -339,15 +333,3 @@ pub trait NonFungibleResolveTransfer {
339333
approved_account_ids: Option<Vec<String>>,
340334
);
341335
}
342-
343-
fn concat_uri(
344-
base: &str,
345-
uri: &Option<String>,
346-
) -> Option<String> {
347-
match uri {
348-
None => None,
349-
Some(uri) if uri.starts_with(base) => Some(uri.to_string()),
350-
Some(uri) if base.ends_with('/') => Some(format!("{}{}", base, uri)),
351-
Some(uri) => Some(format!("{}/{}", base, uri)),
352-
}
353-
}

0 commit comments

Comments
 (0)