-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
197 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use crate::*; | ||
|
||
// registry/v1.3.0 | ||
#[derive(BorshDeserialize, PanicOnDefault)] | ||
pub struct OldState { | ||
pub metadata: LazyOption<ContractMetadata>, | ||
pub registry: AccountId, | ||
pub claim_ttl: u64, | ||
pub sbt_ttl_ms: u64, | ||
pub authority_pubkey: [u8; PUBLIC_KEY_LEN], | ||
pub used_identities: UnorderedSet<Vec<u8>>, | ||
pub admins: UnorderedSet<AccountId>, | ||
} | ||
|
||
#[near_bindgen] | ||
impl Contract { | ||
#[private] | ||
#[init(ignore_state)] | ||
/* pub */ | ||
pub fn migrate(class_metadata: Vec<(ClassId, ClassMetadata)>) -> Self { | ||
let old_state: OldState = env::state_read().expect("failed"); | ||
// new field in the smart contract : | ||
// + class_metadata: LookupMap<ClassId, ClassMetadata> | ||
|
||
let mut c_metadata = LookupMap::new(StorageKey::ClassMetadata); | ||
for (class_id, class_metadata) in class_metadata { | ||
c_metadata.insert(&class_id, &class_metadata); | ||
} | ||
|
||
Self { | ||
metadata: old_state.metadata, | ||
registry: old_state.registry, | ||
claim_ttl: old_state.claim_ttl, | ||
sbt_ttl_ms: old_state.sbt_ttl_ms, | ||
authority_pubkey: old_state.authority_pubkey, | ||
used_identities: old_state.used_identities, | ||
admins: old_state.admins, | ||
class_metadata: c_metadata, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ pub enum StorageKey { | |
ContractMetadata, | ||
UsedIdentities, | ||
Admins, | ||
ClassMetadata, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters