fix: Empty token buffer decode error (#84)
This commit is contained in:
parent
80b0fa4605
commit
3f213aa5ae
|
@ -128,6 +128,8 @@ export function useOwnedTokenAccount(
|
||||||
listener = provider.connection.onAccountChange(
|
listener = provider.connection.onAccountChange(
|
||||||
tokenAccount.publicKey,
|
tokenAccount.publicKey,
|
||||||
(info) => {
|
(info) => {
|
||||||
|
if (info.data.length !== 0) {
|
||||||
|
try {
|
||||||
const token = parseTokenAccountData(info.data);
|
const token = parseTokenAccountData(info.data);
|
||||||
if (token.amount !== tokenAccount.account.amount) {
|
if (token.amount !== tokenAccount.account.amount) {
|
||||||
const index = _OWNED_TOKEN_ACCOUNTS_CACHE.indexOf(tokenAccount);
|
const index = _OWNED_TOKEN_ACCOUNTS_CACHE.indexOf(tokenAccount);
|
||||||
|
@ -135,6 +137,10 @@ export function useOwnedTokenAccount(
|
||||||
_OWNED_TOKEN_ACCOUNTS_CACHE[index].account = token;
|
_OWNED_TOKEN_ACCOUNTS_CACHE[index].account = token;
|
||||||
setRefresh((r) => r + 1);
|
setRefresh((r) => r + 1);
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Failed to decode token AccountInfo");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue