@@ -27,7 +27,7 @@ pub enum MaskImpl {
2727 Attached {
2828 parent : Mask ,
2929 owning_account : HashMap < AccountIndex , Account > ,
30- token_to_account : HashMap < TokenId , AccountId > ,
30+ token_owners : HashMap < TokenId , AccountId > ,
3131 id_to_addr : HashMap < AccountId , Address > ,
3232 last_location : Option < Address > ,
3333 depth : u8 ,
@@ -39,7 +39,7 @@ pub enum MaskImpl {
3939 depth : u8 ,
4040 childs : HashMap < Uuid , Mask > ,
4141 owning_account : HashMap < AccountIndex , Account > ,
42- token_to_account : HashMap < TokenId , AccountId > ,
42+ token_owners : HashMap < TokenId , AccountId > ,
4343 id_to_addr : HashMap < AccountId , Address > ,
4444 last_location : Option < Address > ,
4545 hashes : HashesMatrix ,
@@ -68,7 +68,7 @@ impl Clone for MaskImpl {
6868 Self :: Attached {
6969 parent,
7070 owning_account,
71- token_to_account ,
71+ token_owners ,
7272 id_to_addr,
7373 last_location,
7474 depth,
@@ -78,7 +78,7 @@ impl Clone for MaskImpl {
7878 } => Self :: Attached {
7979 parent : parent. clone ( ) ,
8080 owning_account : owning_account. clone ( ) ,
81- token_to_account : token_to_account . clone ( ) ,
81+ token_owners : token_owners . clone ( ) ,
8282 id_to_addr : id_to_addr. clone ( ) ,
8383 last_location : last_location. clone ( ) ,
8484 depth : * depth,
@@ -90,7 +90,7 @@ impl Clone for MaskImpl {
9090 depth,
9191 childs,
9292 owning_account,
93- token_to_account ,
93+ token_owners ,
9494 id_to_addr,
9595 last_location,
9696 hashes,
@@ -99,7 +99,7 @@ impl Clone for MaskImpl {
9999 depth : * depth,
100100 childs : childs. clone ( ) ,
101101 owning_account : owning_account. clone ( ) ,
102- token_to_account : token_to_account . clone ( ) ,
102+ token_owners : token_owners . clone ( ) ,
103103 id_to_addr : id_to_addr. clone ( ) ,
104104 last_location : last_location. clone ( ) ,
105105 hashes : hashes. clone ( ) ,
@@ -121,7 +121,7 @@ impl std::fmt::Debug for MaskImpl {
121121 Self :: Attached {
122122 parent,
123123 owning_account,
124- token_to_account ,
124+ token_owners ,
125125 id_to_addr,
126126 last_location,
127127 depth,
@@ -133,7 +133,7 @@ impl std::fmt::Debug for MaskImpl {
133133 . field ( "uuid" , uuid)
134134 . field ( "parent" , & parent. get_uuid ( ) )
135135 . field ( "owning_account" , & owning_account. len ( ) )
136- . field ( "token_to_account " , & token_to_account . len ( ) )
136+ . field ( "token_owners " , & token_owners . len ( ) )
137137 . field ( "id_to_addr" , & id_to_addr. len ( ) )
138138 . field ( "last_location" , last_location)
139139 . field ( "depth" , depth)
@@ -145,7 +145,7 @@ impl std::fmt::Debug for MaskImpl {
145145 depth,
146146 childs,
147147 owning_account,
148- token_to_account ,
148+ token_owners ,
149149 id_to_addr,
150150 last_location,
151151 hashes,
@@ -155,7 +155,7 @@ impl std::fmt::Debug for MaskImpl {
155155 . field ( "depth" , depth)
156156 . field ( "childs" , & childs. len ( ) )
157157 . field ( "owning_account" , & owning_account. len ( ) )
158- . field ( "token_to_account " , & token_to_account . len ( ) )
158+ . field ( "token_owners " , & token_owners . len ( ) )
159159 . field ( "id_to_addr" , & id_to_addr. len ( ) )
160160 . field ( "last_location" , last_location)
161161 . field ( "uuid" , uuid)
@@ -298,7 +298,7 @@ impl MaskImpl {
298298 childs,
299299 uuid,
300300 owning_account,
301- token_to_account ,
301+ token_owners ,
302302 id_to_addr,
303303 last_location,
304304 hashes,
@@ -308,7 +308,7 @@ impl MaskImpl {
308308 * self = Attached {
309309 parent,
310310 owning_account : take ( owning_account) ,
311- token_to_account : take ( token_to_account ) ,
311+ token_owners : take ( token_owners ) ,
312312 id_to_addr : take ( id_to_addr) ,
313313 last_location : take ( last_location) ,
314314 depth : * depth,
@@ -378,15 +378,15 @@ impl MaskImpl {
378378 Attached {
379379 parent,
380380 owning_account,
381- token_to_account ,
381+ token_owners ,
382382 id_to_addr,
383383 hashes,
384384 ..
385385 } => {
386386 assert_ne ! ( parent. get_uuid( ) , self_uuid) ;
387387
388388 let ( accounts, hashes) = {
389- token_to_account . clear ( ) ;
389+ token_owners . clear ( ) ;
390390 id_to_addr. clear ( ) ;
391391 ( std:: mem:: take ( owning_account) , hashes. take ( ) )
392392 } ;
@@ -485,7 +485,7 @@ impl MaskImpl {
485485 let Self :: Attached {
486486 parent,
487487 owning_account,
488- token_to_account ,
488+ token_owners ,
489489 id_to_addr,
490490 last_location,
491491 depth,
@@ -502,15 +502,15 @@ impl MaskImpl {
502502 let owning_account = std:: mem:: take ( owning_account) ;
503503 let depth = std:: mem:: take ( depth) ;
504504 let childs = std:: mem:: take ( childs) ;
505- let token_to_account = std:: mem:: take ( token_to_account ) ;
505+ let token_owners = std:: mem:: take ( token_owners ) ;
506506 let id_to_addr = std:: mem:: take ( id_to_addr) ;
507507 let last_location = std:: mem:: take ( last_location) ;
508508 let hashes = std:: mem:: replace ( hashes, HashesMatrix :: new ( depth as usize ) ) ;
509509 let uuid = std:: mem:: replace ( uuid, "temporary" . to_string ( ) ) ;
510510
511511 * self = Self :: Unattached {
512512 owning_account,
513- token_to_account ,
513+ token_owners ,
514514 id_to_addr,
515515 last_location,
516516 depth,
@@ -790,15 +790,15 @@ impl MaskImpl {
790790 Root { .. } => todo ! ( ) ,
791791 Unattached {
792792 owning_account,
793- token_to_account ,
793+ token_owners ,
794794 id_to_addr,
795795 last_location,
796796 hashes,
797797 ..
798798 }
799799 | Attached {
800800 owning_account,
801- token_to_account ,
801+ token_owners ,
802802 id_to_addr,
803803 last_location,
804804 hashes,
@@ -815,7 +815,9 @@ impl MaskImpl {
815815 hashes. invalidate_hashes ( account_index) ;
816816
817817 let account = owning_account. remove ( & account_index) . unwrap ( ) ;
818- token_to_account. remove ( & account. token_id ) . unwrap ( ) ;
818+ token_owners
819+ . remove ( & account. id ( ) . derive_token_id ( ) )
820+ . unwrap ( ) ;
819821
820822 if last_location
821823 . as_ref ( )
@@ -852,24 +854,23 @@ impl MaskImpl {
852854 Root { database, .. } => database. set ( addr, account) ,
853855 Unattached {
854856 owning_account,
855- token_to_account ,
857+ token_owners ,
856858 id_to_addr,
857859 last_location,
858860 ..
859861 }
860862 | Attached {
861863 owning_account,
862- token_to_account ,
864+ token_owners ,
863865 id_to_addr,
864866 last_location,
865867 ..
866868 } => {
867869 let account_id = account. id ( ) ;
868- let token_id = account. token_id . clone ( ) ;
869870
870871 owning_account. insert ( account_index, * account) ;
871872 id_to_addr. insert ( account_id. clone ( ) , addr. clone ( ) ) ;
872- token_to_account . insert ( token_id , account_id) ;
873+ token_owners . insert ( account_id . derive_token_id ( ) , account_id) ;
873874
874875 if last_location
875876 . as_ref ( )
@@ -1112,19 +1113,17 @@ impl BaseLedger for MaskImpl {
11121113 }
11131114
11141115 fn token_owner ( & self , token_id : TokenId ) -> Option < AccountId > {
1115- let ( parent, token_to_account ) = match self {
1116+ let ( parent, token_owners ) = match self {
11161117 Root { database, .. } => return database. token_owner ( token_id) ,
11171118 Attached {
11181119 parent,
1119- token_to_account ,
1120+ token_owners ,
11201121 ..
1121- } => ( Some ( parent) , token_to_account) ,
1122- Unattached {
1123- token_to_account, ..
1124- } => ( None , token_to_account) ,
1122+ } => ( Some ( parent) , token_owners) ,
1123+ Unattached { token_owners, .. } => ( None , token_owners) ,
11251124 } ;
11261125
1127- if let Some ( account_id) = token_to_account . get ( & token_id) . cloned ( ) {
1126+ if let Some ( account_id) = token_owners . get ( & token_id) . cloned ( ) {
11281127 return Some ( account_id) ;
11291128 } ;
11301129
@@ -1195,15 +1194,15 @@ impl BaseLedger for MaskImpl {
11951194 Root { database, .. } => database. get_or_create_account ( account_id, account) ?,
11961195 Unattached {
11971196 owning_account,
1198- token_to_account ,
1197+ token_owners ,
11991198 id_to_addr,
12001199 last_location,
12011200 depth,
12021201 ..
12031202 }
12041203 | Attached {
12051204 owning_account,
1206- token_to_account ,
1205+ token_owners ,
12071206 id_to_addr,
12081207 last_location,
12091208 depth,
@@ -1215,11 +1214,10 @@ impl BaseLedger for MaskImpl {
12151214 } ;
12161215
12171216 let account_index: AccountIndex = location. to_index ( ) ;
1218- let token_id = account. token_id . clone ( ) ;
12191217
12201218 id_to_addr. insert ( account_id. clone ( ) , location. clone ( ) ) ;
12211219 * last_location = Some ( location. clone ( ) ) ;
1222- token_to_account . insert ( token_id , account_id) ;
1220+ token_owners . insert ( account_id . derive_token_id ( ) , account_id) ;
12231221 owning_account. insert ( account_index, account) ;
12241222
12251223 self . invalidate_hashes ( account_index) ;
0 commit comments