-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e58aeff
commit 4ac43e4
Showing
3 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from solana.rpc.async_api import AsyncClient | ||
from solders.pubkey import Pubkey | ||
from solders.address_lookup_table_account import AddressLookupTableAccount | ||
|
||
LOOKUP_TABLE_META_SIZE = 56 | ||
|
||
|
||
async def get_address_lookup_table( | ||
connection: AsyncClient, pubkey: Pubkey | ||
) -> AddressLookupTableAccount: | ||
account_info = await connection.get_account_info(pubkey) | ||
return decode_address_lookup_table(pubkey, account_info.value.data) | ||
|
||
|
||
def decode_address_lookup_table(pubkey: Pubkey, data: bytes): | ||
data_len = len(data) | ||
|
||
addresses = [] | ||
i = LOOKUP_TABLE_META_SIZE | ||
while i < data_len: | ||
addresses.append(Pubkey.from_bytes(data[i : i + 32])) | ||
i += 32 | ||
|
||
return AddressLookupTableAccount(pubkey, addresses) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters