Explorar o código

contract/money/model/token_id: restore deprecated functions(with minor cleanup) and added clarification TODOs

skoupidi %!s(int64=2) %!d(string=hai) anos
pai
achega
b6c7b5ff3c
Modificáronse 1 ficheiros con 8 adicións e 7 borrados
  1. 8 7
      src/contract/money/src/model/token_id.rs

+ 8 - 7
src/contract/money/src/model/token_id.rs

@@ -45,20 +45,21 @@ pub struct TokenId(pallas::Base);
 
 
 impl TokenId {
 impl TokenId {
     /// Derives a `TokenId` from a `SecretKey` (mint authority)
     /// Derives a `TokenId` from a `SecretKey` (mint authority)
-    #[deprecated]
+    // TODO: this got deprected from DEP 0003, but why? ain't that mean
+    // we don't allow users to hold mint keys with their secret?
+    //#[deprecated]
     pub fn derive(mint_authority: SecretKey) -> Self {
     pub fn derive(mint_authority: SecretKey) -> Self {
         let public_key = PublicKey::from_secret(mint_authority);
         let public_key = PublicKey::from_secret(mint_authority);
-        let (x, y) = public_key.xy();
-        let hash = poseidon_hash([*TOKEN_ID_PREFIX, x, y]);
-        Self(hash)
+        Self::derive_public(public_key)
     }
     }
 
 
     /// Derives a `TokenId` from a `PublicKey`
     /// Derives a `TokenId` from a `PublicKey`
-    #[deprecated]
+    // TODO: this got deprected from DEP 0003, but why? ain't that mean
+    // we don't allow users to hold mint keys with their secret?
+    //#[deprecated]
     pub fn derive_public(public_key: PublicKey) -> Self {
     pub fn derive_public(public_key: PublicKey) -> Self {
         let (x, y) = public_key.xy();
         let (x, y) = public_key.xy();
-        let hash = poseidon_hash([*TOKEN_ID_PREFIX, x, y]);
-        Self(hash)
+        Self::derive_from(*TOKEN_ID_PREFIX, x, y)
     }
     }
 
 
     pub fn derive_from(
     pub fn derive_from(