@@ -120,77 +120,71 @@ export function createRpcSubscriptions(rpcUrl?: string): RpcSubscriptions<Solana
120120 * @returns Promise with current authorities
121121 */
122122export async function getTokenAuthorities ( mintAddress : string , rpcUrl ?: string ) : Promise < TokenAuthorities > {
123- try {
124- const rpc = createRpcClient ( rpcUrl ) ;
123+ const rpc = createRpcClient ( rpcUrl ) ;
125124
126- // Fetch account using @solana /kit like inspect-mint does
127- const mintAddressTyped = mintAddress as Address ;
128- const encodedAccount = await fetchEncodedAccount ( rpc , mintAddressTyped ) ;
125+ // Fetch account using @solana /kit like inspect-mint does
126+ const mintAddressTyped = mintAddress as Address ;
127+ const encodedAccount = await fetchEncodedAccount ( rpc , mintAddressTyped ) ;
129128
130- if ( ! encodedAccount . exists ) {
131- throw new Error ( 'Mint account not found' ) ;
132- }
129+ if ( ! encodedAccount . exists ) {
130+ throw new Error ( 'Mint account not found' ) ;
131+ }
133132
134- // Check if this is a Token-2022 mint
135- if ( encodedAccount . programAddress !== TOKEN_2022_PROGRAM_ADDRESS ) {
136- throw new Error ( `Not a Token-2022 mint (owner: ${ encodedAccount . programAddress } )` ) ;
137- }
133+ // Check if this is a Token-2022 mint
134+ if ( encodedAccount . programAddress !== TOKEN_2022_PROGRAM_ADDRESS ) {
135+ throw new Error ( `Not a Token-2022 mint (owner: ${ encodedAccount . programAddress } )` ) ;
136+ }
138137
139- // Decode mint data using gill's decodeMint
140- const decodedMint = decodeMint ( encodedAccount ) ;
141-
142- // Extract basic authorities
143- const authorities : TokenAuthorities = {
144- mintAuthority :
145- decodedMint . data . mintAuthority ?. __option === 'Some' ? decodedMint . data . mintAuthority . value : undefined ,
146- freezeAuthority :
147- decodedMint . data . freezeAuthority ?. __option === 'Some'
148- ? decodedMint . data . freezeAuthority . value
149- : undefined ,
150- } ;
151-
152- // Extract extension authorities
153- if ( decodedMint . data . extensions && decodedMint . data . extensions . __option === 'Some' ) {
154- for ( const ext of decodedMint . data . extensions . value ) {
155- if ( ! ext . __kind ) continue ;
156-
157- switch ( ext . __kind ) {
158- case 'TokenMetadata' :
159- if ( 'updateAuthority' in ext && ext . updateAuthority ) {
160- authorities . metadataAuthority =
161- ext . updateAuthority . __option === 'Some' ? ext . updateAuthority . value : undefined ;
162- }
163- break ;
164- case 'PermanentDelegate' :
165- if ( 'delegate' in ext ) {
166- authorities . permanentDelegateAuthority = ext . delegate ;
167- }
168- break ;
169- case 'ConfidentialTransferMint' :
170- if ( 'authority' in ext && ext . authority ) {
171- authorities . confidentialBalancesAuthority =
172- ext . authority . __option === 'Some' ? ext . authority . value : undefined ;
173- }
174- break ;
175- case 'PausableConfig' :
176- if ( 'authority' in ext && ext . authority ) {
177- authorities . pausableAuthority =
178- ext . authority . __option === 'Some' ? ext . authority . value : undefined ;
179- }
180- break ;
181- case 'ScaledUiAmountConfig' :
182- if ( 'authority' in ext && ext . authority ) {
183- authorities . scaledUiAmountAuthority = ext . authority ;
184- }
185- break ;
186- }
138+ // Decode mint data using gill's decodeMint
139+ const decodedMint = decodeMint ( encodedAccount ) ;
140+
141+ // Extract basic authorities
142+ const authorities : TokenAuthorities = {
143+ mintAuthority :
144+ decodedMint . data . mintAuthority ?. __option === 'Some' ? decodedMint . data . mintAuthority . value : undefined ,
145+ freezeAuthority :
146+ decodedMint . data . freezeAuthority ?. __option === 'Some' ? decodedMint . data . freezeAuthority . value : undefined ,
147+ } ;
148+
149+ // Extract extension authorities
150+ if ( decodedMint . data . extensions && decodedMint . data . extensions . __option === 'Some' ) {
151+ for ( const ext of decodedMint . data . extensions . value ) {
152+ if ( ! ext . __kind ) continue ;
153+
154+ switch ( ext . __kind ) {
155+ case 'TokenMetadata' :
156+ if ( 'updateAuthority' in ext && ext . updateAuthority ) {
157+ authorities . metadataAuthority =
158+ ext . updateAuthority . __option === 'Some' ? ext . updateAuthority . value : undefined ;
159+ }
160+ break ;
161+ case 'PermanentDelegate' :
162+ if ( 'delegate' in ext ) {
163+ authorities . permanentDelegateAuthority = ext . delegate ;
164+ }
165+ break ;
166+ case 'ConfidentialTransferMint' :
167+ if ( 'authority' in ext && ext . authority ) {
168+ authorities . confidentialBalancesAuthority =
169+ ext . authority . __option === 'Some' ? ext . authority . value : undefined ;
170+ }
171+ break ;
172+ case 'PausableConfig' :
173+ if ( 'authority' in ext && ext . authority ) {
174+ authorities . pausableAuthority =
175+ ext . authority . __option === 'Some' ? ext . authority . value : undefined ;
176+ }
177+ break ;
178+ case 'ScaledUiAmountConfig' :
179+ if ( 'authority' in ext && ext . authority ) {
180+ authorities . scaledUiAmountAuthority = ext . authority ;
181+ }
182+ break ;
187183 }
188184 }
189-
190- return authorities ;
191- } catch ( error ) {
192- throw error ;
193185 }
186+
187+ return authorities ;
194188}
195189
196190/**
@@ -202,18 +196,14 @@ export async function getExtensionAuthorities(
202196 _mintAddress : string ,
203197 _rpcUrl ?: string ,
204198) : Promise < Partial < TokenAuthorities > > {
205- try {
206- // TODO: Implement extension-specific authority fetching
207- // This would require fetching each extension's account data
208- // For now, return empty object as placeholder
209-
210- return {
211- metadataAuthority : undefined ,
212- pausableAuthority : undefined ,
213- confidentialBalancesAuthority : undefined ,
214- permanentDelegateAuthority : undefined ,
215- } ;
216- } catch ( error ) {
217- throw error ;
218- }
199+ // TODO: Implement extension-specific authority fetching
200+ // This would require fetching each extension's account data
201+ // For now, return empty object as placeholder
202+
203+ return {
204+ metadataAuthority : undefined ,
205+ pausableAuthority : undefined ,
206+ confidentialBalancesAuthority : undefined ,
207+ permanentDelegateAuthority : undefined ,
208+ } ;
219209}
0 commit comments