diff --git a/js/src/index.ts b/js/src/index.ts index 85ba753..b6bf712 100644 --- a/js/src/index.ts +++ b/js/src/index.ts @@ -4,6 +4,7 @@ export * from "./twitter_bindings"; export * from "./utils"; export * from "./instructions"; export * from "./nft"; +export { getDomainMint } from "./nft/name-tokenizer"; export * from "./favorite-domain"; export * from "./constants"; export * from "./int"; diff --git a/js/src/nft/index.ts b/js/src/nft/index.ts index ff97f42..870e438 100644 --- a/js/src/nft/index.ts +++ b/js/src/nft/index.ts @@ -16,7 +16,6 @@ import { NftRecord, getRecordFromMint, } from "./name-tokenizer"; -import { reverseLookupBatch } from "../utils"; /** * This function can be used to retrieve the owner of a tokenized domain name @@ -27,12 +26,12 @@ import { reverseLookupBatch } from "../utils"; */ export const retrieveNftOwner = async ( connection: Connection, - nameAccount: PublicKey + nameAccount: PublicKey, ) => { try { const [mint] = await PublicKey.findProgramAddress( [MINT_PREFIX, nameAccount.toBuffer()], - NAME_TOKENIZER_ID + NAME_TOKENIZER_ID, ); const mintInfo = await getMint(connection, mint); @@ -91,7 +90,7 @@ export const retrieveNfts = async (connection: Connection) => { }); const offset = 1 + 1 + 32 + 32; return result.map( - (e) => new PublicKey(e.account.data.slice(offset, offset + 32)) + (e) => new PublicKey(e.account.data.slice(offset, offset + 32)), ); }; @@ -114,7 +113,7 @@ const closure = async (connection: Connection, acc: RawAccount) => { export const retrieveRecords = async ( connection: Connection, - owner: PublicKey + owner: PublicKey, ) => { const filters: GetProgramAccountsFilter[] = [ ...getFilter(owner.toBase58()), diff --git a/js/src/resolve.ts b/js/src/resolve.ts index cb1890c..886f769 100644 --- a/js/src/resolve.ts +++ b/js/src/resolve.ts @@ -60,7 +60,7 @@ export const resolve = async (connection: Connection, domain: string) => { return registry.owner; }; -const resolveSolRecordV1 = async ( +export const resolveSolRecordV1 = async ( connection: Connection, owner: PublicKey, domain: string, @@ -87,7 +87,7 @@ const resolveSolRecordV1 = async ( return new PublicKey(solRecord.data.slice(0, 32)); }; -const resolveSolRecordV2 = async ( +export const resolveSolRecordV2 = async ( connection: Connection, owner: PublicKey, domain: string, diff --git a/js/tests/records.test.ts b/js/tests/records.test.ts index 73b7d01..5f9245a 100644 --- a/js/tests/records.test.ts +++ b/js/tests/records.test.ts @@ -4,6 +4,7 @@ import * as record from "../src/record"; import { Connection, PublicKey, Transaction } from "@solana/web3.js"; import { Record } from "../src/types/record"; import { createRecordInstruction } from "../src/bindings"; +import { resolveSolRecordV1 } from "../src/resolve"; jest.setTimeout(20_000); @@ -75,7 +76,7 @@ test("Get multiple records", async () => { connection, "🍍", [Record.Telegram, Record.Github, Record.Backpack], - true + true, ); expect(records[0]).toBe("@🍍-tg"); expect(records[1]).toBe("@🍍_dev"); @@ -96,7 +97,7 @@ test("Create", async () => { Record.A, "192.168.0.1", owner, - owner + owner, ); const tx = new Transaction().add(ix); tx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash; @@ -105,3 +106,12 @@ test("Create", async () => { let res = await connection.simulateTransaction(tx); expect(res.value.err).toBe(null); }); + +test("Check sol record", async () => { + const domain = "wallet-guide-4"; + const owner = new PublicKey("Fxuoy3gFjfJALhwkRcuKjRdechcgffUApeYAfMWck6w8"); + const result = await resolveSolRecordV1(connection, owner, domain); + expect(result.toBase58()).toBe( + "Hf4daCT4tC2Vy9RCe9q8avT68yAsNJ1dQe6xiQqyGuqZ", + ); +});