Order token accounts by mint pubkey

This commit is contained in:
Nishad 2020-12-21 08:14:13 +08:00
parent 0bdf03b92f
commit 0dc1ae1590
1 changed files with 10 additions and 4 deletions

View File

@ -57,10 +57,16 @@ export class Wallet {
getTokenAccountInfo = async () => {
let accounts = await getOwnedTokenAccounts(this.connection, this.publicKey);
return accounts.map(({ publicKey, accountInfo }) => {
setInitialAccountInfo(this.connection, publicKey, accountInfo);
return { publicKey, parsed: parseTokenAccountData(accountInfo.data) };
});
return accounts
.map(({ publicKey, accountInfo }) => {
setInitialAccountInfo(this.connection, publicKey, accountInfo);
return { publicKey, parsed: parseTokenAccountData(accountInfo.data) };
})
.sort((account1, account2) =>
account1.parsed.mint
.toBase58()
.localeCompare(account2.parsed.mint.toBase58()),
);
};
createTokenAccount = async (tokenAddress) => {