The following code is used to retrieve all Sub-Domains of a Public-Key.
const getAllSNSProgramAccounts = async () => {
const accounts = await connection.getProgramAccounts(new PublicKey('namesLPneVptA9Z5rqUDD9tMTWEJwofgaYwp8cawRkX'), {
commitment: 'confirmed',
encoding: 'base64',
filters: [
{
memcmp: {
offset: 32,
bytes: wallet.publicKey.toBase58(),
}
},
],
});
console.log('All SNS Program Accounts (Domains+Subdomains): ', accounts);
}
Note: ATM I think one needs to manually resolve the the returned PKs to distinguish between domains and subdomains.