5
5
bytemuck:: { Pod , Zeroable } ,
6
6
solana_program:: { program_error:: ProgramError , pubkey:: Pubkey } ,
7
7
spl_discriminator:: SplDiscriminate ,
8
- spl_pod:: { error:: PodSliceError , optional_keys:: OptionalNonZeroPubkey , primitives:: PodU32 } ,
8
+ spl_pod:: { error:: PodSliceError , optional_keys:: OptionalNonZeroPubkey , primitives:: PodU64 } ,
9
9
} ;
10
10
11
11
/// Data struct for a `TokenGroup`
@@ -19,39 +19,39 @@ pub struct TokenGroup {
19
19
/// belongs to a particular mint
20
20
pub mint : Pubkey ,
21
21
/// The current number of group members
22
- pub size : PodU32 ,
22
+ pub size : PodU64 ,
23
23
/// The maximum number of group members
24
- pub max_size : PodU32 ,
24
+ pub max_size : PodU64 ,
25
25
}
26
26
27
27
impl TokenGroup {
28
28
/// Creates a new `TokenGroup` state
29
- pub fn new ( mint : & Pubkey , update_authority : OptionalNonZeroPubkey , max_size : u32 ) -> Self {
29
+ pub fn new ( mint : & Pubkey , update_authority : OptionalNonZeroPubkey , max_size : u64 ) -> Self {
30
30
Self {
31
31
mint : * mint,
32
32
update_authority,
33
- size : PodU32 :: default ( ) , // [0, 0, 0, 0]
33
+ size : PodU64 :: default ( ) , // [0, 0, 0, 0, 0, 0, 0, 0]
34
34
max_size : max_size. into ( ) ,
35
35
}
36
36
}
37
37
38
38
/// Updates the max size for a group
39
- pub fn update_max_size ( & mut self , new_max_size : u32 ) -> Result < ( ) , ProgramError > {
39
+ pub fn update_max_size ( & mut self , new_max_size : u64 ) -> Result < ( ) , ProgramError > {
40
40
// The new max size cannot be less than the current size
41
- if new_max_size < u32 :: from ( self . size ) {
41
+ if new_max_size < u64 :: from ( self . size ) {
42
42
return Err ( TokenGroupError :: SizeExceedsNewMaxSize . into ( ) ) ;
43
43
}
44
44
self . max_size = new_max_size. into ( ) ;
45
45
Ok ( ( ) )
46
46
}
47
47
48
48
/// Increment the size for a group, returning the new size
49
- pub fn increment_size ( & mut self ) -> Result < u32 , ProgramError > {
49
+ pub fn increment_size ( & mut self ) -> Result < u64 , ProgramError > {
50
50
// The new size cannot be greater than the max size
51
- let new_size = u32 :: from ( self . size )
51
+ let new_size = u64 :: from ( self . size )
52
52
. checked_add ( 1 )
53
53
. ok_or :: < ProgramError > ( PodSliceError :: CalculationFailure . into ( ) ) ?;
54
- if new_size > u32 :: from ( self . max_size ) {
54
+ if new_size > u64 :: from ( self . max_size ) {
55
55
return Err ( TokenGroupError :: SizeExceedsMaxSize . into ( ) ) ;
56
56
}
57
57
self . size = new_size. into ( ) ;
@@ -70,11 +70,11 @@ pub struct TokenGroupMember {
70
70
/// The pubkey of the `TokenGroup`
71
71
pub group : Pubkey ,
72
72
/// The member number
73
- pub member_number : PodU32 ,
73
+ pub member_number : PodU64 ,
74
74
}
75
75
impl TokenGroupMember {
76
76
/// Creates a new `TokenGroupMember` state
77
- pub fn new ( mint : & Pubkey , group : & Pubkey , member_number : u32 ) -> Self {
77
+ pub fn new ( mint : & Pubkey , group : & Pubkey , member_number : u64 ) -> Self {
78
78
Self {
79
79
mint : * mint,
80
80
group : * group,
@@ -156,7 +156,7 @@ mod tests {
156
156
157
157
let new_max_size = 30 ;
158
158
group. update_max_size ( new_max_size) . unwrap ( ) ;
159
- assert_eq ! ( u32 :: from( group. max_size) , new_max_size) ;
159
+ assert_eq ! ( u64 :: from( group. max_size) , new_max_size) ;
160
160
161
161
// Change the current size to 30
162
162
group. size = 30 . into ( ) ;
@@ -170,7 +170,7 @@ mod tests {
170
170
171
171
let new_max_size = 30 ;
172
172
group. update_max_size ( new_max_size) . unwrap ( ) ;
173
- assert_eq ! ( u32 :: from( group. max_size) , new_max_size) ;
173
+ assert_eq ! ( u64 :: from( group. max_size) , new_max_size) ;
174
174
}
175
175
176
176
#[ test]
@@ -183,7 +183,7 @@ mod tests {
183
183
} ;
184
184
185
185
group. increment_size ( ) . unwrap ( ) ;
186
- assert_eq ! ( u32 :: from( group. size) , 1 ) ;
186
+ assert_eq ! ( u64 :: from( group. size) , 1 ) ;
187
187
188
188
// Try to increase the current size to 2, which is greater than the max size
189
189
assert_eq ! (
0 commit comments