11import { getAssociatedTokenAddress } from './read/associated-token-address' ;
2- import {
3- parseLightTokenCold ,
4- parseLightTokenHot ,
5- } from './read/get-account' ;
2+ import { parseLightTokenCold , parseLightTokenHot } from './read/get-account' ;
63import { Buffer } from 'buffer' ;
74import {
85 LIGHT_TOKEN_PROGRAM_ID ,
@@ -64,12 +61,8 @@ function buildParsedAta(
6461 address : PublicKey ,
6562 owner : PublicKey ,
6663 mint : PublicKey ,
67- hotParsed :
68- | ReturnType < typeof parseLightTokenHot > [ 'parsed' ]
69- | null ,
70- coldParsed :
71- | ReturnType < typeof parseLightTokenCold > [ 'parsed' ]
72- | null ,
64+ hotParsed : ReturnType < typeof parseLightTokenHot > [ 'parsed' ] | null ,
65+ coldParsed : ReturnType < typeof parseLightTokenCold > [ 'parsed' ] | null ,
7366) : TokenInterfaceParsedAta {
7467 const hotAmount = hotParsed ?. amount ?? ZERO ;
7568 const compressedAmount = coldParsed ?. amount ?? ZERO ;
@@ -103,23 +96,21 @@ function buildParsedAta(
10396 amount,
10497 delegate,
10598 delegatedAmount : clampDelegatedAmount ( amount , delegatedAmount ) ,
106- isInitialized :
107- hotParsed ?. isInitialized === true || coldParsed !== null ,
108- isFrozen :
109- hotParsed ?. isFrozen === true || coldParsed ?. isFrozen === true ,
99+ isInitialized : hotParsed ?. isInitialized === true || coldParsed !== null ,
100+ isFrozen : hotParsed ?. isFrozen === true || coldParsed ?. isFrozen === true ,
110101 } ;
111102}
112103
113- function selectPrimaryCompressedAccount (
114- accounts : ParsedTokenAccount [ ] ,
115- ) : {
104+ function selectPrimaryCompressedAccount ( accounts : ParsedTokenAccount [ ] ) : {
116105 selected : ParsedTokenAccount | null ;
117106 ignored : ParsedTokenAccount [ ] ;
118107} {
119108 const candidates = sortCompressedAccounts (
120109 accounts . filter ( account => {
121110 return (
122- account . compressedAccount . owner . equals ( LIGHT_TOKEN_PROGRAM_ID ) &&
111+ account . compressedAccount . owner . equals (
112+ LIGHT_TOKEN_PROGRAM_ID ,
113+ ) &&
123114 account . compressedAccount . data !== null &&
124115 account . compressedAccount . data . data . length > 0 &&
125116 toBigIntAmount ( account ) > ZERO
@@ -184,7 +175,9 @@ export async function getAtaOrNull({
184175 } ;
185176}
186177
187- export async function getAta ( input : GetAtaInput ) : Promise < TokenInterfaceAccount > {
178+ export async function getAta (
179+ input : GetAtaInput ,
180+ ) : Promise < TokenInterfaceAccount > {
188181 const account = await getAtaOrNull ( input ) ;
189182
190183 if ( ! account ) {
@@ -206,7 +199,10 @@ export function getSpendableAmount(
206199 account . parsed . delegate !== null &&
207200 authority . equals ( account . parsed . delegate )
208201 ) {
209- return clampDelegatedAmount ( account . amount , account . parsed . delegatedAmount ) ;
202+ return clampDelegatedAmount (
203+ account . amount ,
204+ account . parsed . delegatedAmount ,
205+ ) ;
210206 }
211207
212208 return ZERO ;
@@ -217,9 +213,7 @@ export function assertAccountNotFrozen(
217213 operation : 'load' | 'transfer' | 'approve' | 'revoke' | 'burn' | 'freeze' ,
218214) : void {
219215 if ( account . parsed . isFrozen ) {
220- throw new Error (
221- `Account is frozen; ${ operation } is not allowed.` ,
222- ) ;
216+ throw new Error ( `Account is frozen; ${ operation } is not allowed.` ) ;
223217 }
224218}
225219
@@ -228,9 +222,6 @@ export function assertAccountFrozen(
228222 operation : 'thaw' ,
229223) : void {
230224 if ( ! account . parsed . isFrozen ) {
231- throw new Error (
232- `Account is not frozen; ${ operation } is not allowed.` ,
233- ) ;
225+ throw new Error ( `Account is not frozen; ${ operation } is not allowed.` ) ;
234226 }
235227}
236-
0 commit comments