@bonfida/spl-name-service 2.0.0-alpha.10 → 2.0.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -137,3 +137,5 @@ export declare const deleteRecordV2: (domain: string, record: Record, owner: Pub
137
137
  */
138
138
  export declare const createSolRecordInstruction: (connection: Connection, domain: string, content: PublicKey, signer: PublicKey, signature: Uint8Array, payer: PublicKey) => Promise<TransactionInstruction[]>;
139
139
  export declare const updateSolRecordInstruction: (connection: Connection, domain: string, content: PublicKey, signer: PublicKey, signature: Uint8Array, payer: PublicKey) => Promise<(TransactionInstruction | TransactionInstruction[])[]>;
140
+ export declare const burnDomain: (domain: string, owner: PublicKey, target: PublicKey) => TransactionInstruction;
141
+ export declare const registerWithNft: (name: string, space: number, nameAccount: PublicKey, reverseLookupAccount: PublicKey, buyer: PublicKey, nftSource: PublicKey, nftMetadata: PublicKey, nftMint: PublicKey, masterEdition: PublicKey) => TransactionInstruction;
@@ -46,3 +46,5 @@ export declare const TOKENS_SYM_MINT: Map<string, string>;
46
46
  export declare const PYTH_MAPPING_ACC: PublicKey;
47
47
  export declare const VAULT_OWNER: PublicKey;
48
48
  export declare const CUSTOM_BG_TLD: PublicKey;
49
+ export declare const WOLVES_COLLECTION_METADATA: PublicKey;
50
+ export declare const METAPLEX_ID: PublicKey;
package/dist/error.d.ts CHANGED
@@ -21,11 +21,11 @@ export declare enum ErrorType {
21
21
  NoAccountData = "NoAccountData",
22
22
  InvalidInput = "InvalidInput",
23
23
  InvalidDomain = "InvalidDomain",
24
+ InvalidCustomBg = "InvalidCustomBackground",
24
25
  UnsupportedSignature = "UnsupportedSignature",
25
26
  RecordDoestNotSupportGuardianSig = "RecordDoestNotSupportGuardianSig",
26
27
  RecordIsNotSigned = "RecordIsNotSigned",
27
- UnsupportedSignatureType = "UnsupportedSignatureType",
28
- InvalidCustomBg = "InvalidCustomBackground"
28
+ UnsupportedSignatureType = "UnsupportedSignatureType"
29
29
  }
30
30
  export declare class SNSError extends Error {
31
31
  type: ErrorType;
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("buffer"),r=require("@solana/web3.js"),t=require("@solana/spl-token"),o=require("bn.js"),n=require("borsh"),i=require("@ethersproject/sha2"),s=require("@pythnetwork/client"),a=require("bech32-buffer"),c=require("tweetnacl"),u=require("bs58"),p=require("ipaddr.js"),d=require("punycode"),f=require("@ethersproject/hash"),l=require("@ethersproject/transactions"),g=require("@ethersproject/address");function y(e){var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var w,x=y(c);exports.ErrorType=void 0,(w=exports.ErrorType||(exports.ErrorType={})).SymbolNotFound="SymbolNotFound",w.InvalidSubdomain="InvalidSubdomain",w.FavouriteDomainNotFound="FavouriteDomainNotFound",w.MissingParentOwner="MissingParentOwner",w.U32Overflow="U32Overflow",w.InvalidBufferLength="InvalidBufferLength",w.U64Overflow="U64Overflow",w.NoRecordData="NoRecordData",w.InvalidRecordData="InvalidRecordData",w.UnsupportedRecord="UnsupportedRecord",w.InvalidEvmAddress="InvalidEvmAddress",w.InvalidInjectiveAddress="InvalidInjectiveAddress",w.InvalidARecord="InvalidARecord",w.InvalidAAAARecord="InvalidAAAARecord",w.InvalidRecordInput="InvalidRecordInput",w.InvalidSignature="InvalidSignature",w.AccountDoesNotExist="AccountDoesNotExist",w.MultipleRegistries="MultipleRegistries",w.InvalidReverseTwitter="InvalidReverseTwitter",w.NoAccountData="NoAccountData",w.InvalidInput="InvalidInput",w.InvalidDomain="InvalidDomain",w.UnsupportedSignature="UnsupportedSignature",w.RecordDoestNotSupportGuardianSig="RecordDoestNotSupportGuardianSig",w.RecordIsNotSigned="RecordIsNotSigned",w.UnsupportedSignatureType="UnsupportedSignatureType",w.InvalidCustomBg="InvalidCustomBackground";class h extends Error{constructor(e,r){super(r),this.name="SNSError",this.type=e,Error.captureStackTrace&&Error.captureStackTrace(this,h)}}class m extends o{toBuffer(){const r=super.toArray().reverse(),t=e.Buffer.from(r);if(4===t.length)return t;if(t.length>4)throw new h(exports.ErrorType.U32Overflow);const o=e.Buffer.alloc(4);return t.copy(o),o}static fromBuffer(e){if(4!==e.length)throw new h(exports.ErrorType.InvalidBufferLength,`Invalid buffer length: ${e.length}`);return new o([...e].reverse().map((e=>`00${e.toString(16)}`.slice(-2))).join(""),16)}}class R extends o{toBuffer(){const r=super.toArray().reverse(),t=e.Buffer.from(r);if(8===t.length)return t;if(t.length>8)throw new h(exports.ErrorType.U64Overflow);const o=e.Buffer.alloc(8);return t.copy(o),o}static fromBuffer(e){if(8!==e.length)throw new h(exports.ErrorType.U64Overflow,`Invalid buffer length: ${e.length}`);return new o([...e].reverse().map((e=>`00${e.toString(16)}`.slice(-2))).join(""),16)}}function S(t,o,n,i,s,a,c,u,p,d,f){const l=[e.Buffer.from(Int8Array.from([0])),new m(a.length).toBuffer(),a,c.toBuffer(),u.toBuffer()],g=e.Buffer.concat(l),y=[{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!0,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!1}];return p?y.push({pubkey:p,isSigner:!0,isWritable:!1}):y.push({pubkey:new r.PublicKey(e.Buffer.alloc(32)),isSigner:!1,isWritable:!1}),d?y.push({pubkey:d,isSigner:!1,isWritable:!1}):y.push({pubkey:new r.PublicKey(e.Buffer.alloc(32)),isSigner:!1,isWritable:!1}),f&&y.push({pubkey:f,isSigner:!0,isWritable:!1}),new r.TransactionInstruction({keys:y,programId:t,data:g})}function b(t,o,n,i,s){const a=[e.Buffer.from(Int8Array.from([1])),n.toBuffer(),new m(i.length).toBuffer(),i],c=e.Buffer.concat(a),u=[{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1}];return new r.TransactionInstruction({keys:u,programId:t,data:c})}function v(t,o,n,i,s,a,c){const u=[e.Buffer.from(Int8Array.from([2])),n.toBuffer()],p=e.Buffer.concat(u),d=[{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:c||i,isSigner:!0,isWritable:!1}];return s&&d.push({pubkey:s,isSigner:!0,isWritable:!1}),c&&a&&(s||d.push({pubkey:r.PublicKey.default,isSigner:!1,isWritable:!1}),d.push({pubkey:a,isSigner:!1,isWritable:!1})),new r.TransactionInstruction({keys:d,programId:t,data:p})}function A(t,o,n,i){const s=[e.Buffer.from(Int8Array.from([3]))],a=e.Buffer.concat(s),c=[{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!1,isWritable:!0}];return new r.TransactionInstruction({keys:c,programId:t,data:a})}class E{constructor(e){this.tag=9,this.name=e.name,this.space=e.space}serialize(){return n.serialize(E.schema,this)}getInstruction(o,n,i,s,a,c,u,p,d,f,l){const g=e.Buffer.from(this.serialize()),y=[{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:r.SystemProgram.programId,isSigner:!1,isWritable:!1},{pubkey:u,isSigner:!1,isWritable:!1},{pubkey:p,isSigner:!0,isWritable:!0},{pubkey:d,isSigner:!1,isWritable:!0},{pubkey:f,isSigner:!1,isWritable:!0},{pubkey:t.TOKEN_PROGRAM_ID,isSigner:!1,isWritable:!1},{pubkey:l,isSigner:!1,isWritable:!1}];return new r.TransactionInstruction({keys:y,programId:o,data:g})}}E.schema=new Map([[E,{kind:"struct",fields:[["tag","u8"],["name","string"],["space","u32"]]}]]);class B{constructor(e){this.tag=12,this.name=e.name}serialize(){return n.serialize(B.schema,this)}getInstruction(t,o,n,i,s,a,c,u,p,d){const f=e.Buffer.from(this.serialize());let l=[];return l.push({pubkey:o,isSigner:!1,isWritable:!1}),l.push({pubkey:n,isSigner:!1,isWritable:!1}),l.push({pubkey:i,isSigner:!1,isWritable:!0}),l.push({pubkey:s,isSigner:!1,isWritable:!1}),l.push({pubkey:a,isSigner:!1,isWritable:!1}),l.push({pubkey:c,isSigner:!0,isWritable:!0}),l.push({pubkey:u,isSigner:!1,isWritable:!1}),p&&l.push({pubkey:p,isSigner:!1,isWritable:!0}),d&&l.push({pubkey:d,isSigner:!0,isWritable:!0}),new r.TransactionInstruction({keys:l,programId:t,data:f})}}B.schema=new Map([[B,{kind:"struct",fields:[["tag","u8"],["name","string"]]}]]);class I{constructor(e){this.tag=13,this.name=e.name,this.space=e.space,this.referrerIdxOpt=e.referrerIdxOpt}serialize(){return n.serialize(I.schema,this)}getInstruction(t,o,n,i,s,a,c,u,p,d,f,l,g,y,w,x,h){const m=e.Buffer.from(this.serialize());let R=[];return R.push({pubkey:o,isSigner:!1,isWritable:!1}),R.push({pubkey:n,isSigner:!1,isWritable:!1}),R.push({pubkey:i,isSigner:!1,isWritable:!0}),R.push({pubkey:s,isSigner:!1,isWritable:!0}),R.push({pubkey:a,isSigner:!1,isWritable:!1}),R.push({pubkey:c,isSigner:!1,isWritable:!1}),R.push({pubkey:u,isSigner:!0,isWritable:!0}),R.push({pubkey:p,isSigner:!1,isWritable:!0}),R.push({pubkey:d,isSigner:!1,isWritable:!1}),R.push({pubkey:f,isSigner:!1,isWritable:!1}),R.push({pubkey:l,isSigner:!1,isWritable:!1}),R.push({pubkey:g,isSigner:!1,isWritable:!0}),R.push({pubkey:y,isSigner:!1,isWritable:!1}),R.push({pubkey:w,isSigner:!1,isWritable:!1}),R.push({pubkey:x,isSigner:!1,isWritable:!1}),h&&R.push({pubkey:h,isSigner:!1,isWritable:!0}),new r.TransactionInstruction({keys:R,programId:t,data:m})}}I.schema=new Map([[I,{kind:"struct",fields:[["tag","u8"],["name","string"],["space","u32"],["referrerIdxOpt",{kind:"option",type:"u16"}]]}]]);const T=new r.PublicKey("nftD3vbNkNqfj2Sd3HZwbpw4BxxKWr4AjGb9X38JeZk"),k=e.Buffer.from("tokenized_name");var P;!function(e){e[e.Uninitialized=0]="Uninitialized",e[e.CentralState=1]="CentralState",e[e.ActiveRecord=2]="ActiveRecord",e[e.InactiveRecord=3]="InactiveRecord"}(P||(P={}));class N{constructor(e){this.tag=e.tag,this.nonce=e.nonce,this.nameAccount=new r.PublicKey(e.nameAccount),this.owner=new r.PublicKey(e.owner),this.nftMint=new r.PublicKey(e.nftMint)}static deserialize(e){return n.deserialize(this.schema,N,e)}static async retrieve(e,r){const t=await e.getAccountInfo(r);if(!t||!t.data)throw new Error("NFT record not found");return this.deserialize(t.data)}static async findKey(t,o){return await r.PublicKey.findProgramAddress([e.Buffer.from("nft_record"),t.toBuffer()],o)}}N.schema=new Map([[N,{kind:"struct",fields:[["tag","u8"],["nonce","u8"],["nameAccount",[32]],["owner",[32]],["nftMint",[32]]]}]]);const D=new r.PublicKey("namesLPneVptA9Z5rqUDD9tMTWEJwofgaYwp8cawRkX"),K="SPL Name Service",W=new r.PublicKey("58PwtjSDuFHuUkYjH9BYnnQKHfwo9reZhC2zMJv9JPkx"),C=new r.PublicKey("jCebN34bUfdeUYJT13J1yG16XWQpt5PDx6Mse9GUqhR"),U=new r.PublicKey("ETp9eKXVv1dWwHSpsXRUuXHmw24PwRkttCGVgpZEY9zF"),L=new r.PublicKey("AUoZ3YAhV3b2rZeEH93UMZHXUZcTramBvb4d9YEVySkc"),O=new r.PublicKey("33m47vH6Eav6jr5Ry86XjhRft2jRBLDnDgPSHoquXi2Z"),M=new r.PublicKey("FvPH7PrVrLGKPfqaf3xJodFTjZriqrAXXLTVWEorTFBi"),z=new r.PublicKey("4YcexoW3r78zz16J2aqmukBLRwGq6rAvWzJpkYAXqebv"),G=new r.PublicKey("DmSyHDSM9eSLyvoLsPvDr5fRRFZ7Bfr3h3ULvWpgQaq7"),_=new r.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),H=[new r.PublicKey("3ogYncmMM5CmytsGCqKHydmXmKUZ6sGWvizkzqwT7zb1"),new r.PublicKey("DM1jJCkZZEwY5tmWbgvKRxsDFzXCdbfrYCCH1CtwguEs"),new r.PublicKey("ADCp4QXFajHrhy4f43pD6GJFtQLkdBY2mjS9DfCk7tNW"),new r.PublicKey("2XTgjw8yi1E3Etgj4CUyRD7Zk49gynH2U9gA5N2MY4NP"),new r.PublicKey("5oDWj8vr3vbcq9JZTtwXqrkCMZggMsDzNietvbr1BNfe"),new r.PublicKey("8kJqxAbqbPLGLMgB6FhLcnw2SiUEavx2aEGM3WQGhtJF")],V=new Map([["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v","USDC"],["Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB","USDT"],["So11111111111111111111111111111111111111112","SOL"],["EchesyfXePKdLtoiZSL8pBe8Myagyy8ZRqsACNCFGnvp","FIDA"],["FeGn77dhg1KXRRFeSwwMiykZnZPw5JXW6naf2aQgZDQf","ETH"],["7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx","GMT"],["AFbX8oGjGpmVFywbVouvhQSRmiW2aR1mohfahi4Y2AdB","GST"],["mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So","MSOL"],["DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263","BONK"],["EPeUFDgHRxs9xxEPVaL6kfGQvCon7jmAWKVUHuux1Tpz","BAT"]]),j=new r.PublicKey("AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J"),F=new r.PublicKey("GcWEQ9K78FV7LEHteFVciYApERk5YvQuFDQPk1yYJVXi"),q=new r.PublicKey("BPeXUQDqGbzxeK1LJby6ugvCBuo7kRSEUkjD726mUVsz"),X=r=>{const t=K+r,o=i.sha256(e.Buffer.from(t,"utf8")).slice(2);return e.Buffer.from(o,"hex")},Y=(t,o,n)=>{const i=[t];o?i.push(o.toBuffer()):i.push(e.Buffer.alloc(32)),n?i.push(n.toBuffer()):i.push(e.Buffer.alloc(32));const[s]=r.PublicKey.findProgramAddressSync(i,D);return s};async function Z(e,r){const t=X(r.toBase58()),n=Y(t,O),{registry:i}=await ie.retrieve(e,n);if(!i.data)throw new h(exports.ErrorType.NoAccountData);const s=new o(i.data.slice(0,4),"le").toNumber();return i.data.slice(4,4+s).toString()}async function J(e,r){let t=[];for(let e of r){const r=X(e.toBase58()),o=Y(r,O);t.push(o)}return(await ie.retrieveBatch(e,t)).map((e=>{if(void 0===e||void 0===e.data)return;let r=new o(e.data.slice(0,4),"le").toNumber();return e.data.slice(4,4+r).toString()}))}const Q=(e,r=W)=>{let t=X(e);return{pubkey:Y(t,void 0,r),hashed:t}},$=(r,t)=>{r.endsWith(".sol")&&(r=r.slice(0,-4));const o=r.split(".");if(2===o.length){const r=e.Buffer.from([t||0]).toString().concat(o[0]),{pubkey:n}=Q(o[1]);return{...Q(r,n),isSub:!0,parent:n}}if(3===o.length&&t){const{pubkey:r}=Q(o[2]),{pubkey:t}=Q("\0".concat(o[1]),r),n=e.Buffer.from([1]).toString();return{...Q(n.concat(o[0]),t),isSub:!0,parent:r,isSubRecord:!0}}if(o.length>=3)throw new h(exports.ErrorType.InvalidInput);return{...Q(r,W),isSub:!1,parent:void 0}};const ee=(e,r)=>{const{pubkey:t,parent:o}=$(e),n=X(t.toBase58());return Y(n,O,r?o:void 0)},re=(e,r)=>{if(!e)throw new h(r)},te=async(e,o)=>{try{const[n]=await r.PublicKey.findProgramAddress([k,o.toBuffer()],T);if("0"===(await t.getMint(e,n)).supply.toString())return;const i=[{memcmp:{offset:0,bytes:n.toBase58()}},{memcmp:{offset:64,bytes:"2"}},{dataSize:165}],s=await e.getProgramAccounts(t.TOKEN_PROGRAM_ID,{filters:i});if(1!=s.length)return;return new r.PublicKey(s[0].account.data.slice(32,64))}catch{return}},oe=e=>[{memcmp:{offset:32,bytes:e}},{memcmp:{offset:64,bytes:"2"}}],ne=async(e,r)=>{const t=await(async(e,r)=>{const t=[{memcmp:{offset:0,bytes:"3"}},{memcmp:{offset:66,bytes:r.toBase58()}}];return await e.getProgramAccounts(T,{filters:t})})(e,r.mint);if(1===t.length)return N.deserialize(t[0].account.data)};class ie{constructor(e){this.parentName=new r.PublicKey(e.parentName),this.owner=new r.PublicKey(e.owner),this.class=new r.PublicKey(e.class)}static async retrieve(e,r){var t;const o=await e.getAccountInfo(r);if(!o)throw new h(exports.ErrorType.AccountDoesNotExist);let i=n.deserializeUnchecked(this.schema,ie,o.data);i.data=null===(t=o.data)||void 0===t?void 0:t.slice(this.HEADER_LEN);return{registry:i,nftOwner:await te(e,r)}}static async _retrieveBatch(e,r){const t=await e.getMultipleAccountsInfo(r),o=e=>{if(!e)return;const r=n.deserializeUnchecked(this.schema,ie,e);return r.data=null==e?void 0:e.slice(this.HEADER_LEN),r};return t.map((e=>o(null==e?void 0:e.data)))}static async retrieveBatch(e,r){let t=[];const o=[...r];for(;o.length>0;)t.push(...await this._retrieveBatch(e,o.splice(0,100)));return t}}async function se(e,r){if(!await e.getAccountInfo(r))throw new h(exports.ErrorType.AccountDoesNotExist);return ie.retrieve(e,r)}async function ae(r){const t=K+r,o=i.sha256(e.Buffer.from(t,"utf8")).slice(2);return e.Buffer.from(o,"hex")}async function ce(t,o,n){const i=[t];o?i.push(o.toBuffer()):i.push(e.Buffer.alloc(32)),n?i.push(n.toBuffer()):i.push(e.Buffer.alloc(32));const[s]=await r.PublicKey.findProgramAddress(i,D);return s}ie.HEADER_LEN=96,ie.schema=new Map([[ie,{kind:"struct",fields:[["parentName",[32]],["owner",[32]],["class",[32]]]}]]);const ue=async(e,r=W)=>{let t=await ae(e);return{pubkey:await ce(t,void 0,r),hashed:t}},pe=async(r,t=!1)=>{r.endsWith(".sol")&&(r=r.slice(0,-4));const o=r.split(".");if(2===o.length){const r=e.Buffer.from([t?1:0]).toString().concat(o[0]),{pubkey:n}=await ue(o[1]);return{...await ue(r,n),isSub:!0,parent:n}}if(3===o.length&&t){const{pubkey:r}=await ue(o[2]),{pubkey:t}=await ue("\0".concat(o[1]),r),n=e.Buffer.from([1]).toString();return{...await ue(n.concat(o[0]),t),isSub:!0,parent:r,isSubRecord:!0}}if(o.length>=3)throw new h(exports.ErrorType.InvalidInput);return{...await ue(r,W),isSub:!1,parent:void 0}};var de;exports.Record=void 0,(de=exports.Record||(exports.Record={})).IPFS="IPFS",de.ARWV="ARWV",de.SOL="SOL",de.ETH="ETH",de.BTC="BTC",de.LTC="LTC",de.DOGE="DOGE",de.Email="email",de.Url="url",de.Discord="discord",de.Github="github",de.Reddit="reddit",de.Twitter="twitter",de.Telegram="telegram",de.Pic="pic",de.SHDW="SHDW",de.POINT="POINT",de.BSC="BSC",de.Injective="INJ",de.Backpack="backpack",de.A="A",de.AAAA="AAAA",de.CNAME="CNAME",de.TXT="TXT",de.Background="background";const fe=new Map([[exports.Record.SOL,96],[exports.Record.ETH,20],[exports.Record.BSC,20],[exports.Record.Injective,20],[exports.Record.A,4],[exports.Record.AAAA,16],[exports.Record.Background,32]]);var le;exports.RecordVersion=void 0,(le=exports.RecordVersion||(exports.RecordVersion={}))[le.V1=1]="V1",le[le.V2=2]="V2";const ge=(e,r,t)=>x.sign.detached.verify(e,r,t.toBytes()),ye=(e,r)=>{const{pubkey:t}=$(r+"."+e,exports.RecordVersion.V1);return t};async function we(e,r,t,o){const n=ye(r,t);let{registry:i}=await ie.retrieve(e,n);if(!i.data)throw new h(exports.ErrorType.NoRecordData);if(o)return he(i,t,n);const s=fe.get(t);return i.data=i.data.slice(0,s),i}const xe=async(e,r)=>await we(e,r,exports.Record.SOL),he=(t,o,n)=>{const i=null==t?void 0:t.data;if(!i)return;if(0===i.compare(e.Buffer.alloc(i.length)))return;const s=fe.get(o),c=(e=>{const r=Array.from(e);return r.length-1-r.reverse().findIndex((e=>0!==e))+1})(i);if(!s)return i.slice(0,c).toString("utf-8");if(o===exports.Record.SOL){const r=new TextEncoder,o=e.Buffer.concat([i.slice(0,32),n.toBuffer()]),s=r.encode(o.toString("hex"));if(ge(s,i.slice(32,96),t.owner))return u.encode(i.slice(0,32))}if(s&&c!==s){const r=i.slice(0,c).toString("utf-8");if(o===exports.Record.Injective){const e=a.decode(r);if("inj"===e.prefix&&20===e.data.length)return r}else if(o===exports.Record.BSC||o===exports.Record.ETH){const t=r.slice(0,2),o=r.slice(2);if("0x"===t&&20===e.Buffer.from(o,"hex").length)return r}else if((o===exports.Record.A||o===exports.Record.AAAA)&&p.isValid(r))return r;throw new h(exports.ErrorType.InvalidRecordData)}if(o===exports.Record.ETH||o===exports.Record.BSC)return"0x"+i.slice(0,s).toString("hex");if(o===exports.Record.Injective)return a.encode("inj",i.slice(0,s),"bech32");if(o===exports.Record.A||o===exports.Record.AAAA)return p.fromByteArray([...i.slice(0,s)]).toString();if(o===exports.Record.Background)return new r.PublicKey(i.slice(0,s)).toString();throw new h(exports.ErrorType.InvalidRecordData)},me=(t,o)=>{if(!fe.get(o))return o!==exports.Record.CNAME&&o!==exports.Record.TXT||(t=d.encode(t)),e.Buffer.from(t,"utf-8");if(o===exports.Record.SOL)throw new h(exports.ErrorType.UnsupportedRecord,"Use `serializeSolRecord` for SOL record");if(o===exports.Record.ETH||o===exports.Record.BSC)return re("0x"===t.slice(0,2),exports.ErrorType.InvalidEvmAddress),e.Buffer.from(t.slice(2),"hex");if(o===exports.Record.Injective){const r=a.decode(t);return re("inj"===r.prefix,exports.ErrorType.InvalidInjectiveAddress),re(20===r.data.length,exports.ErrorType.InvalidInjectiveAddress),e.Buffer.from(r.data)}if(o===exports.Record.A){const r=p.parse(t).toByteArray();return re(4===r.length,exports.ErrorType.InvalidARecord),e.Buffer.from(r)}if(o===exports.Record.AAAA){const r=p.parse(t).toByteArray();return re(16===r.length,exports.ErrorType.InvalidAAAARecord),e.Buffer.from(r)}if(o===exports.Record.Background)return new r.PublicKey(t).toBuffer();throw new h(exports.ErrorType.InvalidRecordInput)},Re=(r,t,o,n)=>{const i=e.Buffer.concat([r.toBuffer(),t.toBuffer()]),s=(new TextEncoder).encode(i.toString("hex")),a=ge(s,n,o);return re(a,exports.ErrorType.InvalidSignature),e.Buffer.concat([r.toBuffer(),n])};async function Se(e,t,o,n,i,s,a,c){const u=await ae(t),p=await ce(u,a,c),d=s||await e.getMinimumBalanceForRentExemption(o);let f;if(c){const{registry:r}=await se(e,c);f=r.owner}return S(D,r.SystemProgram.programId,p,i,n,u,new R(d),new m(o),a,c,f)}async function be(e,r,t,o,n){const i=await ae(r),s=await ce(i,o,n);let a;a=o||(await ie.retrieve(e,s)).registry.owner;return A(D,s,t,a)}const ve=async(e,t,o,n,i)=>{let[s]=await r.PublicKey.findProgramAddress([C.toBuffer()],C),a=await ae(e.toBase58()),c=await ce(a,s,n);return[[],[new B({name:t}).getInstruction(C,D,W,c,r.SystemProgram.programId,s,o,r.SYSVAR_RENT_PUBKEY,n,i)]]},Ae=async(e,t,o,n,i,s)=>{re(o!==exports.Record.SOL,exports.ErrorType.UnsupportedRecord);const{pubkey:a,hashed:c,parent:u}=$(`${o}.${t}`,exports.RecordVersion.V1),p=me(n,o).length,d=await e.getMinimumBalanceForRentExemption(p+ie.HEADER_LEN);return S(D,r.SystemProgram.programId,a,i,s,c,new R(d),new m(p),void 0,u,i)},Ee=async(e,t,o,n,i,s)=>{const a=n.serialize().length,{pubkey:c,hashed:u,parent:p}=$(`${o}.${t}`,exports.RecordVersion.V2),d=await e.getMinimumBalanceForRentExemption(a+ie.HEADER_LEN);return S(D,r.SystemProgram.programId,c,i,s,u,new R(d),new m(a),void 0,p,i)},Be=async(e,t,o,n,i,s)=>{const{pubkey:a,hashed:c,parent:u}=$(`${exports.Record.SOL}.${t}`,exports.RecordVersion.V1),p=Re(o,a,n,i).length,d=await e.getMinimumBalanceForRentExemption(p+ie.HEADER_LEN);return[S(D,r.SystemProgram.programId,a,n,s,c,new R(d),new m(p),void 0,u,n)]};class Ie{constructor(e){this.twitterRegistryKey=e.twitterRegistryKey,this.twitterHandle=e.twitterHandle}static async retrieve(e,r){let t=await e.getAccountInfo(r,"processed");if(!t)throw new h(exports.ErrorType.InvalidReverseTwitter);return n.deserializeUnchecked(this.schema,Ie,t.data.slice(ie.HEADER_LEN))}}async function Te(t,o,i,s,a){const c=await ae(s.toString()),u=await ce(c,M,z);let p=n.serialize(Ie.schema,new Ie({twitterRegistryKey:i.toBytes(),twitterHandle:o}));return[S(D,r.SystemProgram.programId,u,s,a,c,new R(await t.getMinimumBalanceForRentExemption(p.length+ie.HEADER_LEN)),new m(p.length),M,z,M),b(D,u,new m(0),e.Buffer.from(p),M)]}Ie.schema=new Map([[Ie,{kind:"struct",fields:[["twitterRegistryKey",[32]],["twitterHandle","string"]]}]]);const ke=new r.PublicKey("85iDfUvr3HJyLM2zcq5BXSiDvUWfw6cSE1FfNBo8Ap29");class Pe{constructor(e){this.tag=e.tag,this.nameAccount=new r.PublicKey(e.nameAccount)}static deserialize(e){return n.deserialize(this.schema,Pe,e)}static async retrieve(e,r){const t=await e.getAccountInfo(r);if(!t||!t.data)throw new h(exports.ErrorType.FavouriteDomainNotFound);return this.deserialize(t.data)}static async getKey(t,o){return await r.PublicKey.findProgramAddress([e.Buffer.from("favourite_domain"),o.toBuffer()],t)}static getKeySync(t,o){return r.PublicKey.findProgramAddressSync([e.Buffer.from("favourite_domain"),o.toBuffer()],t)}}Pe.schema=new Map([[Pe,{kind:"struct",fields:[["tag","u8"],["nameAccount",[32]]]}]]);var Ne,De;exports.CustomBg=void 0,(exports.CustomBg||(exports.CustomBg={})).DegenPoet1="DegenPoet#1",exports.GuardianSig=void 0,(Ne=exports.GuardianSig||(exports.GuardianSig={}))[Ne.None=0]="None",Ne[Ne.Solana=1]="Solana",Ne[Ne.Ethereum=2]="Ethereum",Ne[Ne.Injective=3]="Injective",exports.UserSig=void 0,(De=exports.UserSig||(exports.UserSig={}))[De.None=0]="None",De[De.Solana=1]="Solana";const Ke={signatureType:exports.UserSig.None,signature:Buffer.alloc(0)},We={signatureType:exports.GuardianSig.None,signature:Buffer.alloc(0)},Ce=new Map([[exports.Record.Backpack,new r.PublicKey("ExXjtfdQe8JacoqP9Z535WzQKjF4CzW1TTRKRgpxvya3").toBuffer()]]),Ue=new Set([exports.Record.IPFS,exports.Record.ARWV,exports.Record.LTC,exports.Record.DOGE,exports.Record.Email,exports.Record.Url,exports.Record.Discord,exports.Record.Github,exports.Record.Reddit,exports.Record.Twitter,exports.Record.Telegram,exports.Record.Pic,exports.Record.SHDW,exports.Record.POINT,exports.Record.Backpack,exports.Record.TXT,exports.Record.CNAME,exports.Record.BTC]),Le=new Set([exports.Record.ETH,exports.Record.Injective,exports.Record.SOL]),Oe=e=>{switch(e){case exports.GuardianSig.None:return 0;case exports.GuardianSig.Solana:return 64;case exports.GuardianSig.Ethereum:case exports.GuardianSig.Injective:return 65;case exports.UserSig.None:return 0;case exports.UserSig.Solana:return 64;default:throw new h(exports.ErrorType.UnsupportedSignature,`Unsupported signature type: ${e}`)}},Me=e=>{const r=Ce.get(e);if(!r)throw new h(exports.ErrorType.RecordDoestNotSupportGuardianSig);return r},ze=(e,r,t)=>x.sign.detached.verify(e,r,t),Ge=(e,r,t)=>{const o=f.hashMessage(e);return l.recoverAddress(o,r)===g.getAddress(t)},_e=(e,r,t,o)=>{switch(o){case exports.GuardianSig.Ethereum:case exports.GuardianSig.Injective:return Ge(e.toString(),r.toString(),t.toString());case exports.GuardianSig.Solana:return ze(e,r,t);case exports.GuardianSig.None:throw new h(exports.ErrorType.RecordIsNotSigned);default:throw new h(exports.ErrorType.UnsupportedSignatureType)}},He=(e,r,t,o)=>{switch(o){case exports.UserSig.Solana:return ze(e,r,t);case exports.UserSig.None:throw new h(exports.ErrorType.RecordIsNotSigned);default:throw new h(exports.ErrorType.UnsupportedSignatureType)}};class Ve{constructor(e){this.userSignature=e.userSignature,this.guardianSignature=e.guardianSignature,this.contentLength=e.contentLength}serialize(){return n.serialize(Ve.schema,this)}static deserialize(e){return n.deserialize(this.schema,Ve,e)}}Ve.LEN=8,Ve.schema=new Map([[Ve,{kind:"struct",fields:[["userSignature","u16"],["guardianSignature","u16"],["contentLength","u32"]]}]]);class je{constructor(e){this.header=e.header,this.buffer=e.buffer}getLength(){return Ve.LEN+this.buffer.length}static deserializeUnchecked(e){const r=n.deserializeUnchecked(Ve.schema,Ve,e);return new je({header:r,buffer:Buffer.from(e.slice(Ve.LEN))})}serialize(){const e=this.header.serialize();return Buffer.concat([e,this.buffer])}deserializeContent(e){return Fe(this.getContent(),e)}getContent(){const e=Oe(this.header.guardianSignature)+Oe(this.header.userSignature);return Buffer.from(this.buffer.slice(e,e+this.header.contentLength))}static new(e,r,t=Ke,o=We){const n=qe(e,r),i=Buffer.concat([t.signature,o.signature,n]),s=new Ve({userSignature:t.signatureType,guardianSignature:o.signatureType,contentLength:n.length});return new je({header:s,buffer:i})}checkGuardianSignature(e,r){const t=Oe(this.header.guardianSignature),o=Oe(this.header.userSignature),n=Buffer.from(this.buffer.slice(o,o+t));return _e(e,n,r,this.header.guardianSignature)}checkUserSignature(e,r){const t=Oe(this.header.userSignature),o=Buffer.from(this.buffer.slice(0,t));return He(e,o,r,this.header.userSignature)}static async retrieve(e,r,t,o){const n=Xe(t,r),{registry:i}=await ie.retrieve(e,n);if(!i.data)throw new h(exports.ErrorType.InvalidRecordData);const s=this.deserializeUnchecked(i.data),a=s.getContent(),c=Buffer.concat([n.toBuffer(),a]);if(!(null==o?void 0:o.skipGuardianSig)){const e=Le.has(r)?Buffer.from(s.getContent().slice(32)):Me(r);s.checkGuardianSignature(c,e)}return(null==o?void 0:o.skipUserSig)||s.checkUserSignature(c,i.owner.toBuffer()),s}static async retrieveBatch(e,r,t){const o=r.map((e=>Xe(t,e))),n=await ie.retrieveBatch(e,o),i=[];for(let e of n)try{if(!(null==e?void 0:e.data)){i.push(void 0);continue}const r=je.deserializeUnchecked(null==e?void 0:e.data);i.push(r)}catch{i.push(void 0)}return i}}const Fe=(e,t)=>{if(Ue.has(t)){const r=e.toString("utf-8");return t===exports.Record.CNAME||t===exports.Record.TXT?d.decode(r):r}if(t===exports.Record.SOL)return new r.PublicKey(e).toBase58();if(t===exports.Record.ETH||t===exports.Record.BSC)return"0x"+e.toString("hex");if(t===exports.Record.Injective)return a.encode("inj",e,"bech32");if(t===exports.Record.A||t===exports.Record.AAAA)return p.fromByteArray([...e]).toString();throw new h(exports.ErrorType.InvalidARecord)},qe=(e,t)=>{if(Ue.has(t))return t!==exports.Record.CNAME&&t!==exports.Record.TXT||(e=d.encode(e)),Buffer.from(e,"utf-8");if(t===exports.Record.SOL)return new r.PublicKey(e).toBuffer();if(t===exports.Record.ETH||t===exports.Record.BSC)return re("0x"===e.slice(0,2),exports.ErrorType.InvalidEvmAddress),Buffer.from(e.slice(2),"hex");if(t===exports.Record.Injective){const r=a.decode(e);return re("inj"===r.prefix,exports.ErrorType.InvalidInjectiveAddress),re(20===r.data.length,exports.ErrorType.InvalidInjectiveAddress),Buffer.from(r.data)}if(t===exports.Record.A){const r=p.parse(e).toByteArray();return re(4===r.length,exports.ErrorType.InvalidARecord),Buffer.from(r)}if(t===exports.Record.AAAA){const r=p.parse(e).toByteArray();return re(16===r.length,exports.ErrorType.InvalidAAAARecord),Buffer.from(r)}throw new h(exports.ErrorType.InvalidARecord)},Xe=(e,r)=>{const{pubkey:t}=$(r+"."+e,exports.RecordVersion.V2);return t},Ye=new r.PublicKey("ART5dr4bDic2sQVZoFheEmUxwQq5VGSx9he7JxHcXNQD");exports.BONFIDA_FIDA_BNB=L,exports.BONFIDA_USDC_BNB=G,exports.CUSTOM_BG_TLD=q,exports.FavouriteDomain=Pe,exports.Guardians=Ce,exports.HASH_PREFIX=K,exports.NAME_OFFERS_ID=ke,exports.NAME_PROGRAM_ID=D,exports.NameRegistryState=ie,exports.NullGuardianSig=We,exports.NullUserSig=Ke,exports.Numberu32=m,exports.Numberu64=R,exports.PYTH_FIDA_PRICE_ACC=U,exports.PYTH_MAPPING_ACC=j,exports.RECORD_V1_SIZE=fe,exports.REFERRERS=H,exports.REGISTER_PROGRAM_ID=C,exports.REVERSE_LOOKUP_CLASS=O,exports.ROOT_DOMAIN_ACCOUNT=W,exports.RecordV2=je,exports.RecordV2Header=Ve,exports.ReverseTwitterRegistryState=Ie,exports.SELF_SIGNED=Le,exports.SNSError=h,exports.SOL_RECORD_SIG_LEN=96,exports.TOKENS_SYM_MINT=V,exports.TWITTER_ROOT_PARENT_REGISTRY_KEY=z,exports.TWITTER_VERIFICATION_AUTHORITY=M,exports.USDC_MINT=_,exports.UTF8_ENCODED=Ue,exports.VAULT_OWNER=F,exports.changeTwitterRegistryData=async function(e,r,t,o){const n=await ae(e),i=await ce(n,void 0,z);return[b(D,i,new m(t),o,r)]},exports.changeVerifiedPubkey=async function(e,r,t,o,n){const i=await ae(r),s=await ce(i,void 0,z);let a=[v(D,s,o,t,void 0)];const c=await ae(t.toString());return await ce(c,M,void 0),a.push(await be(e,t.toString(),n,M,z)),a=a.concat(await Te(e,r,s,o,n)),a},exports.check=re,exports.checkSolRecord=ge,exports.createInstruction=S,exports.createInstructionV3=I,exports.createNameRegistry=Se,exports.createRecordInstruction=Ae,exports.createRecordV2Instruction=Ee,exports.createReverseInstruction=B,exports.createReverseName=ve,exports.createReverseTwitterRegistry=Te,exports.createSolRecordInstruction=Be,exports.createSubdomain=async(e,r,t,o=2e3)=>{const n=[],i=r.split(".")[0];if(!i)throw new h(exports.ErrorType.InvalidSubdomain);const{parent:s,pubkey:a}=$(r),c=await e.getMinimumBalanceForRentExemption(o+ie.HEADER_LEN),u=await Se(e,"\0".concat(i),o,t,t,c,void 0,s);n.push(u);const p=ee(r,!0),d=await e.getAccountInfo(p);if(!(null==d?void 0:d.data)){const[,e]=await ve(a,"\0".concat(i),t,s,t);n.push(...e)}return[[],n]},exports.createV2Instruction=E,exports.createVerifiedTwitterRegistry=async function(e,t,o,n,i){const s=await ae(t),a=await ce(s,void 0,z),c=await e.getMinimumBalanceForRentExemption(n+ie.HEADER_LEN);let u=[S(D,r.SystemProgram.programId,a,o,i,s,new R(c),new m(n),void 0,z,M)];return u=u.concat(await Te(e,t,a,o,i)),u},exports.deleteInstruction=A,exports.deleteNameRegistry=be,exports.deleteRecordV2=async(e,r,t,o)=>{const{pubkey:n}=$(`${r}.${e}`,exports.RecordVersion.V2);return A(D,n,o,t)},exports.deleteTwitterRegistry=async function(e,r){const t=await ae(e),o=await ce(t,void 0,z),n=await ae(r.toString()),i=await ce(n,M,z);return[A(D,o,r,r),A(D,i,r,r)]},exports.deserializeRecord=he,exports.deserializeRecordV2Content=Fe,exports.findSubdomains=async(e,r)=>{const t=[{memcmp:{offset:0,bytes:r.toBase58()}},{memcmp:{offset:64,bytes:O.toBase58()}}],o=await e.getProgramAccounts(D,{filters:t}),n=await Z(e,r),i=o.map((e=>{var r;return null===(r=e.account.data.slice(97).toString("utf-8"))||void 0===r?void 0:r.split("\0").join("")})),s=i.map((e=>$(e+"."+n).pubkey)),a=await e.getMultipleAccountsInfo(s);return i.filter(((e,r)=>!!a[r]))},exports.getAllDomains=async function(e,r){const t=[{memcmp:{offset:32,bytes:r.toBase58()}},{memcmp:{offset:0,bytes:W.toBase58()}}];return(await e.getProgramAccounts(D,{filters:t})).map((e=>e.pubkey))},exports.getAllRegisteredDomains=async e=>{const r=[{memcmp:{offset:0,bytes:W.toBase58()}}];return await e.getProgramAccounts(D,{dataSlice:{offset:32,length:32},filters:r})},exports.getArtistPubkey=e=>{if(e===exports.CustomBg.DegenPoet1)return Ye;throw new h(exports.ErrorType.InvalidCustomBg)},exports.getArweaveRecord=async(e,r)=>await we(e,r,exports.Record.ARWV,!0),exports.getBackgroundRecord=async(e,r)=>await we(e,r,exports.Record.Background,!0),exports.getBackpackRecord=async(e,r)=>await we(e,r,exports.Record.Backpack,!0),exports.getBscRecord=async(e,r)=>await we(e,r,exports.Record.BSC,!0),exports.getBtcRecord=async(e,r)=>await we(e,r,exports.Record.BTC,!0),exports.getCustomBgKeys=(e,r)=>{const t=X(r),o=X(e),n=Y(o,void 0,q);return{domainKey:n,bgKey:Y(t,void 0,n)}},exports.getDiscordRecord=async(e,r)=>await we(e,r,exports.Record.Discord,!0),exports.getDogeRecord=async(e,r)=>await we(e,r,exports.Record.DOGE,!0),exports.getDomainKey=pe,exports.getDomainKeySync=$,exports.getEmailRecord=async(e,r)=>await we(e,r,exports.Record.Email,!0),exports.getEthRecord=async(e,r)=>await we(e,r,exports.Record.ETH,!0),exports.getFavoriteDomain=async(e,t)=>{const[o]=Pe.getKeySync(ke,new r.PublicKey(t)),n=await Pe.retrieve(e,o),i=await Z(e,n.nameAccount);return{domain:n.nameAccount,reverse:i}},exports.getGithubRecord=async(e,r)=>await we(e,r,exports.Record.Github,!0),exports.getGuardianPublickey=Me,exports.getHandleAndRegistryKey=async function(e,t){const o=await ae(t.toString()),n=await ce(o,M,z);let i=await Ie.retrieve(e,n);return[i.twitterHandle,new r.PublicKey(i.twitterRegistryKey)]},exports.getHashedName=ae,exports.getHashedNameSync=X,exports.getInjectiveRecord=async(e,r)=>await we(e,r,exports.Record.Injective,!0),exports.getIpfsRecord=async(e,r)=>await we(e,r,exports.Record.IPFS,!0),exports.getLtcRecord=async(e,r)=>await we(e,r,exports.Record.LTC,!0),exports.getMessageToSign=(e,r,t)=>{const o=qe(e,t),n=Xe(r,t),i=Buffer.concat([n.toBuffer(),o]).toString("hex");return Buffer.from(i)},exports.getNameAccountKey=ce,exports.getNameAccountKeySync=Y,exports.getNameOwner=se,exports.getPicRecord=async(e,r)=>await we(e,r,exports.Record.Pic,!0),exports.getPointRecord=async(e,r)=>await we(e,r,exports.Record.POINT,!0),exports.getRecord=we,exports.getRecordKeySync=ye,exports.getRecordV2Key=Xe,exports.getRecords=async function(e,r,t,o){const n=t.map((e=>ye(r,e))),i=await ie.retrieveBatch(e,n);return o?i.map(((e,o)=>{if(e)return he(e,t[o],ye(r,t[o]))})):i},exports.getRedditRecord=async(e,r)=>await we(e,r,exports.Record.Reddit,!0),exports.getReverseKey=async(e,r)=>{const{pubkey:t,parent:o}=await pe(e),n=await ae(t.toBase58());return await ce(n,O,r?o:void 0)},exports.getReverseKeySync=ee,exports.getShdwRecord=async(e,r)=>await we(e,r,exports.Record.SHDW,!0),exports.getSignatureByteLength=Oe,exports.getSolRecord=xe,exports.getTelegramRecord=async(e,r)=>await we(e,r,exports.Record.Telegram,!0),exports.getTokenizedDomains=async(e,r)=>{const o=await(async(e,r)=>{const o=[...oe(r.toBase58()),{dataSize:165}],n=(await e.getProgramAccounts(t.TOKEN_PROGRAM_ID,{filters:o})).map((e=>t.AccountLayout.decode(e.account.data))).map((r=>ne(e,r)));return(await Promise.all(n)).filter((e=>void 0!==e))})(e,r);return(await J(e,o.map((e=>e.nameAccount)))).map(((e,r)=>({key:o[r].nameAccount,mint:o[r].nftMint,reverse:e}))).filter((e=>!!e.reverse))},exports.getTwitterHandleandRegistryKeyViaFilters=async function(e,t){const o=[{memcmp:{offset:0,bytes:z.toBase58()}},{memcmp:{offset:32,bytes:t.toBase58()}},{memcmp:{offset:64,bytes:M.toBase58()}}],i=await e.getProgramAccounts(D,{filters:o});for(const e of i)if(e.account.data.length>ie.HEADER_LEN+32){let t=e.account.data.slice(ie.HEADER_LEN),o=n.deserializeUnchecked(Ie.schema,Ie,t);return[o.twitterHandle,new r.PublicKey(o.twitterRegistryKey)]}throw new h(exports.ErrorType.AccountDoesNotExist)},exports.getTwitterRecord=async(e,r)=>await we(e,r,exports.Record.Twitter,!0),exports.getTwitterRegistry=async function(e,r){const t=await ae(r),o=await ce(t,void 0,z),{registry:n}=await ie.retrieve(e,o);return n},exports.getTwitterRegistryData=async function(t,o){const n=[{memcmp:{offset:0,bytes:z.toBase58()}},{memcmp:{offset:32,bytes:o.toBase58()}},{memcmp:{offset:64,bytes:new r.PublicKey(e.Buffer.alloc(32,0)).toBase58()}}],i=await t.getProgramAccounts(D,{filters:n});if(i.length>1)throw new h(exports.ErrorType.MultipleRegistries);return i[0].account.data.slice(ie.HEADER_LEN)},exports.getTwitterRegistryKey=async function(e){const r=await ae(e);return await ce(r,void 0,z)},exports.getUrlRecord=async(e,r)=>await we(e,r,exports.Record.Url,!0),exports.performReverseLookup=async function(e,r){const t=await ae(r.toBase58()),n=await ce(t,O),{registry:i}=await ie.retrieve(e,n);if(!i.data)throw new h(exports.ErrorType.NoAccountData);const s=new o(i.data.slice(0,4),"le").toNumber();return i.data.slice(4,4+s).toString()},exports.performReverseLookupBatch=async function(e,r){let t=[];for(let e of r){const r=await ae(e.toBase58()),o=await ce(r,O);t.push(o)}return(await ie.retrieveBatch(e,t)).map((e=>{if(void 0===e||void 0===e.data)return;let r=new o(e.data.slice(0,4),"le").toNumber();return e.data.slice(4,4+r).toString()}))},exports.registerDomainName=async(e,o,n,i,a,c=_,u)=>{if(o.includes(".")||o.trim().toLowerCase()!==o)throw new h(exports.ErrorType.InvalidDomain);const[p]=r.PublicKey.findProgramAddressSync([C.toBuffer()],C),d=X(o),f=Y(d,void 0,W),l=X(f.toBase58()),g=Y(l,p),[y]=r.PublicKey.findProgramAddressSync([f.toBuffer()],C),w=H.findIndex((e=>null==u?void 0:u.equals(e)));let x;const m=[];if(-1!==w&&u){x=t.getAssociatedTokenAddressSync(c,u,!0);const r=await e.getAccountInfo(x);if(!(null==r?void 0:r.data)){const e=t.createAssociatedTokenAccountInstruction(i,x,u,c);m.push(e)}}const R=new s.PythHttpClient(e,s.getPythProgramKeyForCluster("mainnet-beta")),S=await R.getData(),b=V.get(c.toBase58());if(!b)throw new h(exports.ErrorType.SymbolNotFound,`No symbol found for mint ${c.toBase58()}`);const v=S.productPrice.get("Crypto."+b+"/USD"),A=S.productFromSymbol.get("Crypto."+b+"/USD"),E=t.getAssociatedTokenAddressSync(c,F),B=new I({name:o,space:n,referrerIdxOpt:-1!=w?w:null}).getInstruction(C,D,W,f,g,r.SystemProgram.programId,p,i,a,j,v.productAccountKey,new r.PublicKey(A.price_account),E,t.TOKEN_PROGRAM_ID,r.SYSVAR_RENT_PUBKEY,y,x);return m.push(B),[[],m]},exports.resolve=async(t,o)=>{const{pubkey:n}=$(o),{registry:i,nftOwner:s}=await ie.retrieve(t,n);if(s)return s;try{const n=ye(o,exports.Record.SOL),s=await xe(t,o);if(!(null==s?void 0:s.data))throw new h(exports.ErrorType.NoRecordData);const a=new TextEncoder,c=e.Buffer.concat([s.data.slice(0,32),n.toBuffer()]),u=a.encode(c.toString("hex"));if(!ge(u,s.data.slice(32),i.owner))throw new h(exports.ErrorType.InvalidSignature);return new r.PublicKey(s.data.slice(0,32))}catch(e){if(e instanceof Error&&"FetchError"===e.name)throw e}return i.owner},exports.retrieveNftOwner=te,exports.retrieveNfts=async e=>{const t=await e.getProgramAccounts(T,{filters:[{memcmp:{offset:0,bytes:"3"}}]});return t.map((e=>new r.PublicKey(e.account.data.slice(66,98))))},exports.reverseLookup=Z,exports.reverseLookupBatch=J,exports.serializeRecord=me,exports.serializeRecordV2Content=qe,exports.serializeSolRecord=Re,exports.transferInstruction=v,exports.transferNameOwnership=async function(e,r,t,o,n,i){const s=await ae(r),a=await ce(s,o,n);let c;return c=o||(await ie.retrieve(e,a)).registry.owner,v(D,a,t,c,o,n,i)},exports.updateInstruction=b,exports.updateNameRegistryData=async function(e,r,t,o,n,i){const s=await ae(r),a=await ce(s,n,i);let c;return c=n||(await ie.retrieve(e,a)).registry.owner,b(D,a,new m(t),o,c)},exports.updateRecordInstruction=async(e,r,t,o,n,i)=>{re(t!==exports.Record.SOL,exports.ErrorType.UnsupportedRecord);const{pubkey:s}=$(`${t}.${r}`,exports.RecordVersion.V1),a=await e.getAccountInfo(s);re(!!(null==a?void 0:a.data),exports.ErrorType.AccountDoesNotExist);const c=me(o,t);if((null==a?void 0:a.data.slice(96).length)!==c.length)return[A(D,s,i,n),await Ae(e,r,t,o,n,i)];return[b(D,s,new m(0),c,n)]},exports.updateRecordV2Instruction=async(r,t,o,n,i,s)=>{const{pubkey:a}=$(`${o}.${t}`,exports.RecordVersion.V2),c=await r.getAccountInfo(a),u=n.serialize();if(c&&(null==c?void 0:c.data.slice(96).length)!==u.length)return[A(D,a,s,i),await Ee(r,t,o,n,i,s),b(D,a,new m(0),e.Buffer.from(u),i)];return[b(D,a,new m(0),e.Buffer.from(u),i)]},exports.updateSolRecordInstruction=async(e,r,t,o,n,i)=>{const{pubkey:s}=$(`${exports.Record.SOL}.${r}`,exports.RecordVersion.V1),a=await e.getAccountInfo(s);if(re(!!(null==a?void 0:a.data),exports.ErrorType.AccountDoesNotExist),96!==(null==a?void 0:a.data.length))return[A(D,s,i,o),await Be(e,r,t,o,n,i)];const c=Re(t,s,o,n);return[b(D,s,new m(0),c,o)]},exports.verifyEthereumSignature=Ge,exports.verifyGuardianSignature=_e,exports.verifyInjectiveSignature=(e,r,t)=>{throw new Error("TODO")},exports.verifySolanaSignature=ze,exports.verifyUserSignature=He;
1
+ "use strict";var e=require("buffer"),r=require("@solana/web3.js"),t=require("@solana/spl-token"),i=require("bn.js"),s=require("borsh"),o=require("@ethersproject/sha2"),n=require("@pythnetwork/client"),a=require("bech32-buffer"),c=require("tweetnacl"),u=require("bs58"),p=require("ipaddr.js"),d=require("punycode"),f=require("@ethersproject/hash"),l=require("@ethersproject/transactions"),g=require("@ethersproject/address");function y(e){var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var w,h=y(c);exports.ErrorType=void 0,(w=exports.ErrorType||(exports.ErrorType={})).SymbolNotFound="SymbolNotFound",w.InvalidSubdomain="InvalidSubdomain",w.FavouriteDomainNotFound="FavouriteDomainNotFound",w.MissingParentOwner="MissingParentOwner",w.U32Overflow="U32Overflow",w.InvalidBufferLength="InvalidBufferLength",w.U64Overflow="U64Overflow",w.NoRecordData="NoRecordData",w.InvalidRecordData="InvalidRecordData",w.UnsupportedRecord="UnsupportedRecord",w.InvalidEvmAddress="InvalidEvmAddress",w.InvalidInjectiveAddress="InvalidInjectiveAddress",w.InvalidARecord="InvalidARecord",w.InvalidAAAARecord="InvalidAAAARecord",w.InvalidRecordInput="InvalidRecordInput",w.InvalidSignature="InvalidSignature",w.AccountDoesNotExist="AccountDoesNotExist",w.MultipleRegistries="MultipleRegistries",w.InvalidReverseTwitter="InvalidReverseTwitter",w.NoAccountData="NoAccountData",w.InvalidInput="InvalidInput",w.InvalidDomain="InvalidDomain",w.InvalidCustomBg="InvalidCustomBackground",w.UnsupportedSignature="UnsupportedSignature",w.RecordDoestNotSupportGuardianSig="RecordDoestNotSupportGuardianSig",w.RecordIsNotSigned="RecordIsNotSigned",w.UnsupportedSignatureType="UnsupportedSignatureType";class x extends Error{constructor(e,r){super(r),this.name="SNSError",this.type=e,Error.captureStackTrace&&Error.captureStackTrace(this,x)}}class m extends i{toBuffer(){const r=super.toArray().reverse(),t=e.Buffer.from(r);if(4===t.length)return t;if(t.length>4)throw new x(exports.ErrorType.U32Overflow);const i=e.Buffer.alloc(4);return t.copy(i),i}static fromBuffer(e){if(4!==e.length)throw new x(exports.ErrorType.InvalidBufferLength,`Invalid buffer length: ${e.length}`);return new i([...e].reverse().map((e=>`00${e.toString(16)}`.slice(-2))).join(""),16)}}class b extends i{toBuffer(){const r=super.toArray().reverse(),t=e.Buffer.from(r);if(8===t.length)return t;if(t.length>8)throw new x(exports.ErrorType.U64Overflow);const i=e.Buffer.alloc(8);return t.copy(i),i}static fromBuffer(e){if(8!==e.length)throw new x(exports.ErrorType.U64Overflow,`Invalid buffer length: ${e.length}`);return new i([...e].reverse().map((e=>`00${e.toString(16)}`.slice(-2))).join(""),16)}}function S(t,i,s,o,n,a,c,u,p,d,f){const l=[e.Buffer.from(Int8Array.from([0])),new m(a.length).toBuffer(),a,c.toBuffer(),u.toBuffer()],g=e.Buffer.concat(l),y=[{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!1}];return p?y.push({pubkey:p,isSigner:!0,isWritable:!1}):y.push({pubkey:new r.PublicKey(e.Buffer.alloc(32)),isSigner:!1,isWritable:!1}),d?y.push({pubkey:d,isSigner:!1,isWritable:!1}):y.push({pubkey:new r.PublicKey(e.Buffer.alloc(32)),isSigner:!1,isWritable:!1}),f&&y.push({pubkey:f,isSigner:!0,isWritable:!1}),new r.TransactionInstruction({keys:y,programId:t,data:g})}function R(t,i,s,o,n){const a=[e.Buffer.from(Int8Array.from([1])),s.toBuffer(),new m(o.length).toBuffer(),o],c=e.Buffer.concat(a),u=[{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return new r.TransactionInstruction({keys:u,programId:t,data:c})}function v(t,i,s,o,n,a,c){const u=[e.Buffer.from(Int8Array.from([2])),s.toBuffer()],p=e.Buffer.concat(u),d=[{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:c||o,isSigner:!0,isWritable:!1}];return n&&d.push({pubkey:n,isSigner:!0,isWritable:!1}),c&&a&&(n||d.push({pubkey:r.PublicKey.default,isSigner:!1,isWritable:!1}),d.push({pubkey:a,isSigner:!1,isWritable:!1})),new r.TransactionInstruction({keys:d,programId:t,data:p})}function A(t,i,s,o){const n=[e.Buffer.from(Int8Array.from([3]))],a=e.Buffer.concat(n),c=[{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!0,isWritable:!1},{pubkey:s,isSigner:!1,isWritable:!0}];return new r.TransactionInstruction({keys:c,programId:t,data:a})}class E{constructor(e){this.tag=9,this.name=e.name,this.space=e.space}serialize(){return s.serialize(E.schema,this)}getInstruction(i,s,o,n,a,c,u,p,d,f,l){const g=e.Buffer.from(this.serialize()),y=[{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:r.SystemProgram.programId,isSigner:!1,isWritable:!1},{pubkey:u,isSigner:!1,isWritable:!1},{pubkey:p,isSigner:!0,isWritable:!0},{pubkey:d,isSigner:!1,isWritable:!0},{pubkey:f,isSigner:!1,isWritable:!0},{pubkey:t.TOKEN_PROGRAM_ID,isSigner:!1,isWritable:!1},{pubkey:l,isSigner:!1,isWritable:!1}];return new r.TransactionInstruction({keys:y,programId:i,data:g})}}E.schema=new Map([[E,{kind:"struct",fields:[["tag","u8"],["name","string"],["space","u32"]]}]]);class B{constructor(e){this.tag=12,this.name=e.name}serialize(){return s.serialize(B.schema,this)}getInstruction(t,i,s,o,n,a,c,u,p,d){const f=e.Buffer.from(this.serialize());let l=[];return l.push({pubkey:i,isSigner:!1,isWritable:!1}),l.push({pubkey:s,isSigner:!1,isWritable:!1}),l.push({pubkey:o,isSigner:!1,isWritable:!0}),l.push({pubkey:n,isSigner:!1,isWritable:!1}),l.push({pubkey:a,isSigner:!1,isWritable:!1}),l.push({pubkey:c,isSigner:!0,isWritable:!0}),l.push({pubkey:u,isSigner:!1,isWritable:!1}),p&&l.push({pubkey:p,isSigner:!1,isWritable:!0}),d&&l.push({pubkey:d,isSigner:!0,isWritable:!0}),new r.TransactionInstruction({keys:l,programId:t,data:f})}}B.schema=new Map([[B,{kind:"struct",fields:[["tag","u8"],["name","string"]]}]]);class k{constructor(e){this.tag=13,this.name=e.name,this.space=e.space,this.referrerIdxOpt=e.referrerIdxOpt}serialize(){return s.serialize(k.schema,this)}getInstruction(t,i,s,o,n,a,c,u,p,d,f,l,g,y,w,h,x){const m=e.Buffer.from(this.serialize());let b=[];return b.push({pubkey:i,isSigner:!1,isWritable:!1}),b.push({pubkey:s,isSigner:!1,isWritable:!1}),b.push({pubkey:o,isSigner:!1,isWritable:!0}),b.push({pubkey:n,isSigner:!1,isWritable:!0}),b.push({pubkey:a,isSigner:!1,isWritable:!1}),b.push({pubkey:c,isSigner:!1,isWritable:!1}),b.push({pubkey:u,isSigner:!0,isWritable:!0}),b.push({pubkey:p,isSigner:!1,isWritable:!0}),b.push({pubkey:d,isSigner:!1,isWritable:!1}),b.push({pubkey:f,isSigner:!1,isWritable:!1}),b.push({pubkey:l,isSigner:!1,isWritable:!1}),b.push({pubkey:g,isSigner:!1,isWritable:!0}),b.push({pubkey:y,isSigner:!1,isWritable:!1}),b.push({pubkey:w,isSigner:!1,isWritable:!1}),b.push({pubkey:h,isSigner:!1,isWritable:!1}),x&&b.push({pubkey:x,isSigner:!1,isWritable:!0}),new r.TransactionInstruction({keys:b,programId:t,data:m})}}k.schema=new Map([[k,{kind:"struct",fields:[["tag","u8"],["name","string"],["space","u32"],["referrerIdxOpt",{kind:"option",type:"u16"}]]}]]);class I{constructor(e){this.tag=17,this.name=e.name,this.space=e.space}serialize(){return s.serialize(I.schema,this)}getInstruction(t,i,s,o,n,a,c,u,p,d,f,l,g,y,w,h,x){const m=e.Buffer.from(this.serialize());let b=[];return b.push({pubkey:i,isSigner:!1,isWritable:!1}),b.push({pubkey:s,isSigner:!1,isWritable:!1}),b.push({pubkey:o,isSigner:!1,isWritable:!0}),b.push({pubkey:n,isSigner:!1,isWritable:!0}),b.push({pubkey:a,isSigner:!1,isWritable:!1}),b.push({pubkey:c,isSigner:!1,isWritable:!1}),b.push({pubkey:u,isSigner:!0,isWritable:!0}),b.push({pubkey:p,isSigner:!1,isWritable:!0}),b.push({pubkey:d,isSigner:!1,isWritable:!0}),b.push({pubkey:f,isSigner:!1,isWritable:!0}),b.push({pubkey:l,isSigner:!1,isWritable:!0}),b.push({pubkey:g,isSigner:!1,isWritable:!0}),b.push({pubkey:y,isSigner:!1,isWritable:!1}),b.push({pubkey:w,isSigner:!1,isWritable:!1}),b.push({pubkey:h,isSigner:!1,isWritable:!1}),b.push({pubkey:x,isSigner:!1,isWritable:!1}),new r.TransactionInstruction({keys:b,programId:t,data:m})}}I.schema=new Map([[I,{kind:"struct",fields:[["tag","u8"],["name","string"],["space","u32"]]}]]);class T{constructor(){this.tag=16}serialize(){return s.serialize(T.schema,this)}getInstruction(t,i,s,o,n,a,c,u,p,d){const f=e.Buffer.from(this.serialize());let l=[];return l.push({pubkey:i,isSigner:!1,isWritable:!1}),l.push({pubkey:s,isSigner:!1,isWritable:!1}),l.push({pubkey:o,isSigner:!1,isWritable:!0}),l.push({pubkey:n,isSigner:!1,isWritable:!0}),l.push({pubkey:a,isSigner:!1,isWritable:!0}),l.push({pubkey:c,isSigner:!1,isWritable:!0}),l.push({pubkey:u,isSigner:!1,isWritable:!1}),l.push({pubkey:p,isSigner:!0,isWritable:!1}),l.push({pubkey:d,isSigner:!1,isWritable:!0}),new r.TransactionInstruction({keys:l,programId:t,data:f})}}T.schema=new Map([[T,{kind:"struct",fields:[["tag","u8"]]}]]);const P=new r.PublicKey("nftD3vbNkNqfj2Sd3HZwbpw4BxxKWr4AjGb9X38JeZk"),N=e.Buffer.from("tokenized_name");var D;!function(e){e[e.Uninitialized=0]="Uninitialized",e[e.CentralState=1]="CentralState",e[e.ActiveRecord=2]="ActiveRecord",e[e.InactiveRecord=3]="InactiveRecord"}(D||(D={}));class W{constructor(e){this.tag=e.tag,this.nonce=e.nonce,this.nameAccount=new r.PublicKey(e.nameAccount),this.owner=new r.PublicKey(e.owner),this.nftMint=new r.PublicKey(e.nftMint)}static deserialize(e){return s.deserialize(this.schema,W,e)}static async retrieve(e,r){const t=await e.getAccountInfo(r);if(!t||!t.data)throw new Error("NFT record not found");return this.deserialize(t.data)}static async findKey(t,i){return await r.PublicKey.findProgramAddress([e.Buffer.from("nft_record"),t.toBuffer()],i)}}W.schema=new Map([[W,{kind:"struct",fields:[["tag","u8"],["nonce","u8"],["nameAccount",[32]],["owner",[32]],["nftMint",[32]]]}]]);const K=new r.PublicKey("namesLPneVptA9Z5rqUDD9tMTWEJwofgaYwp8cawRkX"),C="SPL Name Service",L=new r.PublicKey("58PwtjSDuFHuUkYjH9BYnnQKHfwo9reZhC2zMJv9JPkx"),U=new r.PublicKey("jCebN34bUfdeUYJT13J1yG16XWQpt5PDx6Mse9GUqhR"),O=new r.PublicKey("ETp9eKXVv1dWwHSpsXRUuXHmw24PwRkttCGVgpZEY9zF"),z=new r.PublicKey("AUoZ3YAhV3b2rZeEH93UMZHXUZcTramBvb4d9YEVySkc"),M=new r.PublicKey("33m47vH6Eav6jr5Ry86XjhRft2jRBLDnDgPSHoquXi2Z"),_=new r.PublicKey("FvPH7PrVrLGKPfqaf3xJodFTjZriqrAXXLTVWEorTFBi"),G=new r.PublicKey("4YcexoW3r78zz16J2aqmukBLRwGq6rAvWzJpkYAXqebv"),V=new r.PublicKey("DmSyHDSM9eSLyvoLsPvDr5fRRFZ7Bfr3h3ULvWpgQaq7"),j=new r.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),H=[new r.PublicKey("3ogYncmMM5CmytsGCqKHydmXmKUZ6sGWvizkzqwT7zb1"),new r.PublicKey("DM1jJCkZZEwY5tmWbgvKRxsDFzXCdbfrYCCH1CtwguEs"),new r.PublicKey("ADCp4QXFajHrhy4f43pD6GJFtQLkdBY2mjS9DfCk7tNW"),new r.PublicKey("2XTgjw8yi1E3Etgj4CUyRD7Zk49gynH2U9gA5N2MY4NP"),new r.PublicKey("5oDWj8vr3vbcq9JZTtwXqrkCMZggMsDzNietvbr1BNfe"),new r.PublicKey("8kJqxAbqbPLGLMgB6FhLcnw2SiUEavx2aEGM3WQGhtJF"),new r.PublicKey("HemvJzwxvVpWBjPETpaseAH395WAxb2G73MeUfjVkK1u")],F=new Map([["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v","USDC"],["Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB","USDT"],["So11111111111111111111111111111111111111112","SOL"],["EchesyfXePKdLtoiZSL8pBe8Myagyy8ZRqsACNCFGnvp","FIDA"],["FeGn77dhg1KXRRFeSwwMiykZnZPw5JXW6naf2aQgZDQf","ETH"],["7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx","GMT"],["AFbX8oGjGpmVFywbVouvhQSRmiW2aR1mohfahi4Y2AdB","GST"],["mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So","MSOL"],["DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263","BONK"],["EPeUFDgHRxs9xxEPVaL6kfGQvCon7jmAWKVUHuux1Tpz","BAT"]]),q=new r.PublicKey("AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J"),X=new r.PublicKey("GcWEQ9K78FV7LEHteFVciYApERk5YvQuFDQPk1yYJVXi"),Y=new r.PublicKey("BPeXUQDqGbzxeK1LJby6ugvCBuo7kRSEUkjD726mUVsz"),Z=new r.PublicKey("72aLKvXeV4aansAQtxKymeXDevT5ed6sCuz9iN62ugPT"),J=new r.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Q=r=>{const t=C+r,i=o.sha256(e.Buffer.from(t,"utf8")).slice(2);return e.Buffer.from(i,"hex")},$=(t,i,s)=>{const o=[t];i?o.push(i.toBuffer()):o.push(e.Buffer.alloc(32)),s?o.push(s.toBuffer()):o.push(e.Buffer.alloc(32));const[n]=r.PublicKey.findProgramAddressSync(o,K);return n};async function ee(e,r){const t=Q(r.toBase58()),s=$(t,M),{registry:o}=await ue.retrieve(e,s);if(!o.data)throw new x(exports.ErrorType.NoAccountData);const n=new i(o.data.slice(0,4),"le").toNumber();return o.data.slice(4,4+n).toString()}async function re(e,r){let t=[];for(let e of r){const r=Q(e.toBase58()),i=$(r,M);t.push(i)}return(await ue.retrieveBatch(e,t)).map((e=>{if(void 0===e||void 0===e.data)return;let r=new i(e.data.slice(0,4),"le").toNumber();return e.data.slice(4,4+r).toString()}))}const te=(e,r=L)=>{let t=Q(e);return{pubkey:$(t,void 0,r),hashed:t}},ie=(r,t)=>{r.endsWith(".sol")&&(r=r.slice(0,-4));const i=r.split(".");if(2===i.length){const r=e.Buffer.from([t||0]).toString().concat(i[0]),{pubkey:s}=te(i[1]);return{...te(r,s),isSub:!0,parent:s}}if(3===i.length&&t){const{pubkey:r}=te(i[2]),{pubkey:t}=te("\0".concat(i[1]),r),s=e.Buffer.from([1]).toString();return{...te(s.concat(i[0]),t),isSub:!0,parent:r,isSubRecord:!0}}if(i.length>=3)throw new x(exports.ErrorType.InvalidInput);return{...te(r,L),isSub:!1,parent:void 0}};const se=(e,r)=>{const{pubkey:t,parent:i}=ie(e),s=Q(t.toBase58());return $(s,M,r?i:void 0)},oe=(e,r)=>{if(!e)throw new x(r)},ne=async(e,i)=>{try{const[s]=await r.PublicKey.findProgramAddress([N,i.toBuffer()],P);if("0"===(await t.getMint(e,s)).supply.toString())return;const o=[{memcmp:{offset:0,bytes:s.toBase58()}},{memcmp:{offset:64,bytes:"2"}},{dataSize:165}],n=await e.getProgramAccounts(t.TOKEN_PROGRAM_ID,{filters:o});if(1!=n.length)return;return new r.PublicKey(n[0].account.data.slice(32,64))}catch{return}},ae=e=>[{memcmp:{offset:32,bytes:e}},{memcmp:{offset:64,bytes:"2"}}],ce=async(e,r)=>{const t=await(async(e,r)=>{const t=[{memcmp:{offset:0,bytes:"3"}},{memcmp:{offset:66,bytes:r.toBase58()}}];return await e.getProgramAccounts(P,{filters:t})})(e,r.mint);if(1===t.length)return W.deserialize(t[0].account.data)};class ue{constructor(e){this.parentName=new r.PublicKey(e.parentName),this.owner=new r.PublicKey(e.owner),this.class=new r.PublicKey(e.class)}static async retrieve(e,r){var t;const i=await e.getAccountInfo(r);if(!i)throw new x(exports.ErrorType.AccountDoesNotExist);let o=s.deserializeUnchecked(this.schema,ue,i.data);o.data=null===(t=i.data)||void 0===t?void 0:t.slice(this.HEADER_LEN);return{registry:o,nftOwner:await ne(e,r)}}static async _retrieveBatch(e,r){const t=await e.getMultipleAccountsInfo(r),i=e=>{if(!e)return;const r=s.deserializeUnchecked(this.schema,ue,e);return r.data=null==e?void 0:e.slice(this.HEADER_LEN),r};return t.map((e=>i(null==e?void 0:e.data)))}static async retrieveBatch(e,r){let t=[];const i=[...r];for(;i.length>0;)t.push(...await this._retrieveBatch(e,i.splice(0,100)));return t}}async function pe(e,r){if(!await e.getAccountInfo(r))throw new x(exports.ErrorType.AccountDoesNotExist);return ue.retrieve(e,r)}async function de(r){const t=C+r,i=o.sha256(e.Buffer.from(t,"utf8")).slice(2);return e.Buffer.from(i,"hex")}async function fe(t,i,s){const o=[t];i?o.push(i.toBuffer()):o.push(e.Buffer.alloc(32)),s?o.push(s.toBuffer()):o.push(e.Buffer.alloc(32));const[n]=await r.PublicKey.findProgramAddress(o,K);return n}ue.HEADER_LEN=96,ue.schema=new Map([[ue,{kind:"struct",fields:[["parentName",[32]],["owner",[32]],["class",[32]]]}]]);const le=async(e,r=L)=>{let t=await de(e);return{pubkey:await fe(t,void 0,r),hashed:t}},ge=async(r,t=!1)=>{r.endsWith(".sol")&&(r=r.slice(0,-4));const i=r.split(".");if(2===i.length){const r=e.Buffer.from([t?1:0]).toString().concat(i[0]),{pubkey:s}=await le(i[1]);return{...await le(r,s),isSub:!0,parent:s}}if(3===i.length&&t){const{pubkey:r}=await le(i[2]),{pubkey:t}=await le("\0".concat(i[1]),r),s=e.Buffer.from([1]).toString();return{...await le(s.concat(i[0]),t),isSub:!0,parent:r,isSubRecord:!0}}if(i.length>=3)throw new x(exports.ErrorType.InvalidInput);return{...await le(r,L),isSub:!1,parent:void 0}};var ye;exports.Record=void 0,(ye=exports.Record||(exports.Record={})).IPFS="IPFS",ye.ARWV="ARWV",ye.SOL="SOL",ye.ETH="ETH",ye.BTC="BTC",ye.LTC="LTC",ye.DOGE="DOGE",ye.Email="email",ye.Url="url",ye.Discord="discord",ye.Github="github",ye.Reddit="reddit",ye.Twitter="twitter",ye.Telegram="telegram",ye.Pic="pic",ye.SHDW="SHDW",ye.POINT="POINT",ye.BSC="BSC",ye.Injective="INJ",ye.Backpack="backpack",ye.A="A",ye.AAAA="AAAA",ye.CNAME="CNAME",ye.TXT="TXT",ye.Background="background";const we=new Map([[exports.Record.SOL,96],[exports.Record.ETH,20],[exports.Record.BSC,20],[exports.Record.Injective,20],[exports.Record.A,4],[exports.Record.AAAA,16],[exports.Record.Background,32]]);var he;exports.RecordVersion=void 0,(he=exports.RecordVersion||(exports.RecordVersion={}))[he.V1=1]="V1",he[he.V2=2]="V2";const xe=(e,r,t)=>h.sign.detached.verify(e,r,t.toBytes()),me=(e,r)=>{const{pubkey:t}=ie(r+"."+e,exports.RecordVersion.V1);return t};async function be(e,r,t,i){const s=me(r,t);let{registry:o}=await ue.retrieve(e,s);if(!o.data)throw new x(exports.ErrorType.NoRecordData);if(i)return Re(o,t,s);const n=we.get(t);return o.data=o.data.slice(0,n),o}const Se=async(e,r)=>await be(e,r,exports.Record.SOL),Re=(t,i,s)=>{const o=null==t?void 0:t.data;if(!o)return;if(0===o.compare(e.Buffer.alloc(o.length)))return;const n=we.get(i),c=(e=>{const r=Array.from(e);return r.length-1-r.reverse().findIndex((e=>0!==e))+1})(o);if(!n)return o.slice(0,c).toString("utf-8");if(i===exports.Record.SOL){const r=new TextEncoder,i=e.Buffer.concat([o.slice(0,32),s.toBuffer()]),n=r.encode(i.toString("hex"));if(xe(n,o.slice(32,96),t.owner))return u.encode(o.slice(0,32))}if(n&&c!==n){const r=o.slice(0,c).toString("utf-8");if(i===exports.Record.Injective){const e=a.decode(r);if("inj"===e.prefix&&20===e.data.length)return r}else if(i===exports.Record.BSC||i===exports.Record.ETH){const t=r.slice(0,2),i=r.slice(2);if("0x"===t&&20===e.Buffer.from(i,"hex").length)return r}else if((i===exports.Record.A||i===exports.Record.AAAA)&&p.isValid(r))return r;throw new x(exports.ErrorType.InvalidRecordData)}if(i===exports.Record.ETH||i===exports.Record.BSC)return"0x"+o.slice(0,n).toString("hex");if(i===exports.Record.Injective)return a.encode("inj",o.slice(0,n),"bech32");if(i===exports.Record.A||i===exports.Record.AAAA)return p.fromByteArray([...o.slice(0,n)]).toString();if(i===exports.Record.Background)return new r.PublicKey(o.slice(0,n)).toString();throw new x(exports.ErrorType.InvalidRecordData)},ve=(t,i)=>{if(!we.get(i))return i!==exports.Record.CNAME&&i!==exports.Record.TXT||(t=d.encode(t)),e.Buffer.from(t,"utf-8");if(i===exports.Record.SOL)throw new x(exports.ErrorType.UnsupportedRecord,"Use `serializeSolRecord` for SOL record");if(i===exports.Record.ETH||i===exports.Record.BSC)return oe("0x"===t.slice(0,2),exports.ErrorType.InvalidEvmAddress),e.Buffer.from(t.slice(2),"hex");if(i===exports.Record.Injective){const r=a.decode(t);return oe("inj"===r.prefix,exports.ErrorType.InvalidInjectiveAddress),oe(20===r.data.length,exports.ErrorType.InvalidInjectiveAddress),e.Buffer.from(r.data)}if(i===exports.Record.A){const r=p.parse(t).toByteArray();return oe(4===r.length,exports.ErrorType.InvalidARecord),e.Buffer.from(r)}if(i===exports.Record.AAAA){const r=p.parse(t).toByteArray();return oe(16===r.length,exports.ErrorType.InvalidAAAARecord),e.Buffer.from(r)}if(i===exports.Record.Background)return new r.PublicKey(t).toBuffer();throw new x(exports.ErrorType.InvalidRecordInput)},Ae=(r,t,i,s)=>{const o=e.Buffer.concat([r.toBuffer(),t.toBuffer()]),n=(new TextEncoder).encode(o.toString("hex")),a=xe(n,s,i);return oe(a,exports.ErrorType.InvalidSignature),e.Buffer.concat([r.toBuffer(),s])};async function Ee(e,t,i,s,o,n,a,c){const u=await de(t),p=await fe(u,a,c),d=n||await e.getMinimumBalanceForRentExemption(i);let f;if(c){const{registry:r}=await pe(e,c);f=r.owner}return S(K,r.SystemProgram.programId,p,o,s,u,new b(d),new m(i),a,c,f)}async function Be(e,r,t,i,s){const o=await de(r),n=await fe(o,i,s);let a;a=i||(await ue.retrieve(e,n)).registry.owner;return A(K,n,t,a)}const ke=async(e,t,i,s,o)=>{let[n]=await r.PublicKey.findProgramAddress([U.toBuffer()],U),a=await de(e.toBase58()),c=await fe(a,n,s);return[[],[new B({name:t}).getInstruction(U,K,L,c,r.SystemProgram.programId,n,i,r.SYSVAR_RENT_PUBKEY,s,o)]]},Ie=async(e,t,i,s,o,n)=>{oe(i!==exports.Record.SOL,exports.ErrorType.UnsupportedRecord);const{pubkey:a,hashed:c,parent:u}=ie(`${i}.${t}`,exports.RecordVersion.V1),p=ve(s,i).length,d=await e.getMinimumBalanceForRentExemption(p+ue.HEADER_LEN);return S(K,r.SystemProgram.programId,a,o,n,c,new b(d),new m(p),void 0,u,o)},Te=async(e,t,i,s,o,n)=>{const a=s.serialize().length,{pubkey:c,hashed:u,parent:p}=ie(`${i}.${t}`,exports.RecordVersion.V2),d=await e.getMinimumBalanceForRentExemption(a+ue.HEADER_LEN);return S(K,r.SystemProgram.programId,c,o,n,u,new b(d),new m(a),void 0,p,o)},Pe=async(e,t,i,s,o,n)=>{const{pubkey:a,hashed:c,parent:u}=ie(`${exports.Record.SOL}.${t}`,exports.RecordVersion.V1),p=Ae(i,a,s,o).length,d=await e.getMinimumBalanceForRentExemption(p+ue.HEADER_LEN);return[S(K,r.SystemProgram.programId,a,s,n,c,new b(d),new m(p),void 0,u,s)]};class Ne{constructor(e){this.twitterRegistryKey=e.twitterRegistryKey,this.twitterHandle=e.twitterHandle}static async retrieve(e,r){let t=await e.getAccountInfo(r,"processed");if(!t)throw new x(exports.ErrorType.InvalidReverseTwitter);return s.deserializeUnchecked(this.schema,Ne,t.data.slice(ue.HEADER_LEN))}}async function De(t,i,o,n,a){const c=await de(n.toString()),u=await fe(c,_,G);let p=s.serialize(Ne.schema,new Ne({twitterRegistryKey:o.toBytes(),twitterHandle:i}));return[S(K,r.SystemProgram.programId,u,n,a,c,new b(await t.getMinimumBalanceForRentExemption(p.length+ue.HEADER_LEN)),new m(p.length),_,G,_),R(K,u,new m(0),e.Buffer.from(p),_)]}Ne.schema=new Map([[Ne,{kind:"struct",fields:[["twitterRegistryKey",[32]],["twitterHandle","string"]]}]]);const We=new r.PublicKey("85iDfUvr3HJyLM2zcq5BXSiDvUWfw6cSE1FfNBo8Ap29");class Ke{constructor(e){this.tag=e.tag,this.nameAccount=new r.PublicKey(e.nameAccount)}static deserialize(e){return s.deserialize(this.schema,Ke,e)}static async retrieve(e,r){const t=await e.getAccountInfo(r);if(!t||!t.data)throw new x(exports.ErrorType.FavouriteDomainNotFound);return this.deserialize(t.data)}static async getKey(t,i){return await r.PublicKey.findProgramAddress([e.Buffer.from("favourite_domain"),i.toBuffer()],t)}static getKeySync(t,i){return r.PublicKey.findProgramAddressSync([e.Buffer.from("favourite_domain"),i.toBuffer()],t)}}Ke.schema=new Map([[Ke,{kind:"struct",fields:[["tag","u8"],["nameAccount",[32]]]}]]);exports.CustomBg=void 0,(exports.CustomBg||(exports.CustomBg={})).DegenPoet1="DegenPoet#1";const Ce=new r.PublicKey("ART5dr4bDic2sQVZoFheEmUxwQq5VGSx9he7JxHcXNQD");var Le,Ue;exports.GuardianSig=void 0,(Le=exports.GuardianSig||(exports.GuardianSig={}))[Le.None=0]="None",Le[Le.Solana=1]="Solana",Le[Le.Ethereum=2]="Ethereum",Le[Le.Injective=3]="Injective",exports.UserSig=void 0,(Ue=exports.UserSig||(exports.UserSig={}))[Ue.None=0]="None",Ue[Ue.Solana=1]="Solana";const Oe={signatureType:exports.UserSig.None,signature:Buffer.alloc(0)},ze={signatureType:exports.GuardianSig.None,signature:Buffer.alloc(0)},Me=new Map([[exports.Record.Backpack,new r.PublicKey("ExXjtfdQe8JacoqP9Z535WzQKjF4CzW1TTRKRgpxvya3").toBuffer()]]),_e=new Set([exports.Record.IPFS,exports.Record.ARWV,exports.Record.LTC,exports.Record.DOGE,exports.Record.Email,exports.Record.Url,exports.Record.Discord,exports.Record.Github,exports.Record.Reddit,exports.Record.Twitter,exports.Record.Telegram,exports.Record.Pic,exports.Record.SHDW,exports.Record.POINT,exports.Record.Backpack,exports.Record.TXT,exports.Record.CNAME,exports.Record.BTC]),Ge=new Set([exports.Record.ETH,exports.Record.Injective,exports.Record.SOL]),Ve=e=>{switch(e){case exports.GuardianSig.None:return 0;case exports.GuardianSig.Solana:return 64;case exports.GuardianSig.Ethereum:case exports.GuardianSig.Injective:return 65;case exports.UserSig.None:return 0;case exports.UserSig.Solana:return 64;default:throw new x(exports.ErrorType.UnsupportedSignature,`Unsupported signature type: ${e}`)}},je=e=>{const r=Me.get(e);if(!r)throw new x(exports.ErrorType.RecordDoestNotSupportGuardianSig);return r},He=(e,r,t)=>h.sign.detached.verify(e,r,t),Fe=(e,r,t)=>{const i=f.hashMessage(e);return l.recoverAddress(i,r)===g.getAddress(t)},qe=(e,r,t,i)=>{switch(i){case exports.GuardianSig.Ethereum:case exports.GuardianSig.Injective:return Fe(e.toString(),r.toString(),t.toString());case exports.GuardianSig.Solana:return He(e,r,t);case exports.GuardianSig.None:throw new x(exports.ErrorType.RecordIsNotSigned);default:throw new x(exports.ErrorType.UnsupportedSignatureType)}},Xe=(e,r,t,i)=>{switch(i){case exports.UserSig.Solana:return He(e,r,t);case exports.UserSig.None:throw new x(exports.ErrorType.RecordIsNotSigned);default:throw new x(exports.ErrorType.UnsupportedSignatureType)}};class Ye{constructor(e){this.userSignature=e.userSignature,this.guardianSignature=e.guardianSignature,this.contentLength=e.contentLength}serialize(){return s.serialize(Ye.schema,this)}static deserialize(e){return s.deserialize(this.schema,Ye,e)}}Ye.LEN=8,Ye.schema=new Map([[Ye,{kind:"struct",fields:[["userSignature","u16"],["guardianSignature","u16"],["contentLength","u32"]]}]]);class Ze{constructor(e){this.header=e.header,this.buffer=e.buffer}getLength(){return Ye.LEN+this.buffer.length}static deserializeUnchecked(e){const r=s.deserializeUnchecked(Ye.schema,Ye,e);return new Ze({header:r,buffer:Buffer.from(e.slice(Ye.LEN))})}serialize(){const e=this.header.serialize();return Buffer.concat([e,this.buffer])}deserializeContent(e){return Je(this.getContent(),e)}getContent(){const e=Ve(this.header.guardianSignature)+Ve(this.header.userSignature);return Buffer.from(this.buffer.slice(e,e+this.header.contentLength))}static new(e,r,t=Oe,i=ze){const s=Qe(e,r),o=Buffer.concat([t.signature,i.signature,s]),n=new Ye({userSignature:t.signatureType,guardianSignature:i.signatureType,contentLength:s.length});return new Ze({header:n,buffer:o})}checkGuardianSignature(e,r){const t=Ve(this.header.guardianSignature),i=Ve(this.header.userSignature),s=Buffer.from(this.buffer.slice(i,i+t));return qe(e,s,r,this.header.guardianSignature)}checkUserSignature(e,r){const t=Ve(this.header.userSignature),i=Buffer.from(this.buffer.slice(0,t));return Xe(e,i,r,this.header.userSignature)}static async retrieve(e,r,t,i){const s=$e(t,r),{registry:o}=await ue.retrieve(e,s);if(!o.data)throw new x(exports.ErrorType.InvalidRecordData);const n=this.deserializeUnchecked(o.data),a=n.getContent(),c=Buffer.concat([s.toBuffer(),a]);if(!(null==i?void 0:i.skipGuardianSig)){const e=Ge.has(r)?Buffer.from(n.getContent().slice(32)):je(r);n.checkGuardianSignature(c,e)}return(null==i?void 0:i.skipUserSig)||n.checkUserSignature(c,o.owner.toBuffer()),n}static async retrieveBatch(e,r,t){const i=r.map((e=>$e(t,e))),s=await ue.retrieveBatch(e,i),o=[];for(let e of s)try{if(!(null==e?void 0:e.data)){o.push(void 0);continue}const r=Ze.deserializeUnchecked(null==e?void 0:e.data);o.push(r)}catch{o.push(void 0)}return o}}const Je=(e,t)=>{if(_e.has(t)){const r=e.toString("utf-8");return t===exports.Record.CNAME||t===exports.Record.TXT?d.decode(r):r}if(t===exports.Record.SOL)return new r.PublicKey(e).toBase58();if(t===exports.Record.ETH||t===exports.Record.BSC)return"0x"+e.toString("hex");if(t===exports.Record.Injective)return a.encode("inj",e,"bech32");if(t===exports.Record.A||t===exports.Record.AAAA)return p.fromByteArray([...e]).toString();throw new x(exports.ErrorType.InvalidARecord)},Qe=(e,t)=>{if(_e.has(t))return t!==exports.Record.CNAME&&t!==exports.Record.TXT||(e=d.encode(e)),Buffer.from(e,"utf-8");if(t===exports.Record.SOL)return new r.PublicKey(e).toBuffer();if(t===exports.Record.ETH||t===exports.Record.BSC)return oe("0x"===e.slice(0,2),exports.ErrorType.InvalidEvmAddress),Buffer.from(e.slice(2),"hex");if(t===exports.Record.Injective){const r=a.decode(e);return oe("inj"===r.prefix,exports.ErrorType.InvalidInjectiveAddress),oe(20===r.data.length,exports.ErrorType.InvalidInjectiveAddress),Buffer.from(r.data)}if(t===exports.Record.A){const r=p.parse(e).toByteArray();return oe(4===r.length,exports.ErrorType.InvalidARecord),Buffer.from(r)}if(t===exports.Record.AAAA){const r=p.parse(e).toByteArray();return oe(16===r.length,exports.ErrorType.InvalidAAAARecord),Buffer.from(r)}throw new x(exports.ErrorType.InvalidARecord)},$e=(e,r)=>{const{pubkey:t}=ie(r+"."+e,exports.RecordVersion.V2);return t};exports.BONFIDA_FIDA_BNB=z,exports.BONFIDA_USDC_BNB=V,exports.CUSTOM_BG_TLD=Y,exports.FavouriteDomain=Ke,exports.Guardians=Me,exports.HASH_PREFIX=C,exports.METAPLEX_ID=J,exports.NAME_OFFERS_ID=We,exports.NAME_PROGRAM_ID=K,exports.NameRegistryState=ue,exports.NullGuardianSig=ze,exports.NullUserSig=Oe,exports.Numberu32=m,exports.Numberu64=b,exports.PYTH_FIDA_PRICE_ACC=O,exports.PYTH_MAPPING_ACC=q,exports.RECORD_V1_SIZE=we,exports.REFERRERS=H,exports.REGISTER_PROGRAM_ID=U,exports.REVERSE_LOOKUP_CLASS=M,exports.ROOT_DOMAIN_ACCOUNT=L,exports.RecordV2=Ze,exports.RecordV2Header=Ye,exports.ReverseTwitterRegistryState=Ne,exports.SELF_SIGNED=Ge,exports.SNSError=x,exports.SOL_RECORD_SIG_LEN=96,exports.TOKENS_SYM_MINT=F,exports.TWITTER_ROOT_PARENT_REGISTRY_KEY=G,exports.TWITTER_VERIFICATION_AUTHORITY=_,exports.USDC_MINT=j,exports.UTF8_ENCODED=_e,exports.VAULT_OWNER=X,exports.WOLVES_COLLECTION_METADATA=Z,exports.burnDomain=(e,t,i)=>{const{pubkey:s}=ie(e),[o]=r.PublicKey.findProgramAddressSync([s.toBuffer()],U),[n]=r.PublicKey.findProgramAddressSync([s.toBuffer(),Uint8Array.from([1,1])],U);return(new T).getInstruction(U,K,r.SystemProgram.programId,s,se(e),n,o,M,t,i)},exports.burnInstruction=T,exports.changeTwitterRegistryData=async function(e,r,t,i){const s=await de(e),o=await fe(s,void 0,G);return[R(K,o,new m(t),i,r)]},exports.changeVerifiedPubkey=async function(e,r,t,i,s){const o=await de(r),n=await fe(o,void 0,G);let a=[v(K,n,i,t,void 0)];const c=await de(t.toString());return await fe(c,_,void 0),a.push(await Be(e,t.toString(),s,_,G)),a=a.concat(await De(e,r,n,i,s)),a},exports.check=oe,exports.checkSolRecord=xe,exports.createInstruction=S,exports.createInstructionV3=k,exports.createNameRegistry=Ee,exports.createRecordInstruction=Ie,exports.createRecordV2Instruction=Te,exports.createReverseInstruction=B,exports.createReverseName=ke,exports.createReverseTwitterRegistry=De,exports.createSolRecordInstruction=Pe,exports.createSubdomain=async(e,r,t,i=2e3)=>{const s=[],o=r.split(".")[0];if(!o)throw new x(exports.ErrorType.InvalidSubdomain);const{parent:n,pubkey:a}=ie(r),c=await e.getMinimumBalanceForRentExemption(i+ue.HEADER_LEN),u=await Ee(e,"\0".concat(o),i,t,t,c,void 0,n);s.push(u);const p=se(r,!0),d=await e.getAccountInfo(p);if(!(null==d?void 0:d.data)){const[,e]=await ke(a,"\0".concat(o),t,n,t);s.push(...e)}return[[],s]},exports.createV2Instruction=E,exports.createVerifiedTwitterRegistry=async function(e,t,i,s,o){const n=await de(t),a=await fe(n,void 0,G),c=await e.getMinimumBalanceForRentExemption(s+ue.HEADER_LEN);let u=[S(K,r.SystemProgram.programId,a,i,o,n,new b(c),new m(s),void 0,G,_)];return u=u.concat(await De(e,t,a,i,o)),u},exports.createWithNftInstruction=I,exports.deleteInstruction=A,exports.deleteNameRegistry=Be,exports.deleteRecordV2=async(e,r,t,i)=>{const{pubkey:s}=ie(`${r}.${e}`,exports.RecordVersion.V2);return A(K,s,i,t)},exports.deleteTwitterRegistry=async function(e,r){const t=await de(e),i=await fe(t,void 0,G),s=await de(r.toString()),o=await fe(s,_,G);return[A(K,i,r,r),A(K,o,r,r)]},exports.deserializeRecord=Re,exports.deserializeRecordV2Content=Je,exports.findSubdomains=async(e,r)=>{const t=[{memcmp:{offset:0,bytes:r.toBase58()}},{memcmp:{offset:64,bytes:M.toBase58()}}],i=await e.getProgramAccounts(K,{filters:t}),s=await ee(e,r),o=i.map((e=>{var r;return null===(r=e.account.data.slice(97).toString("utf-8"))||void 0===r?void 0:r.split("\0").join("")})),n=o.map((e=>ie(e+"."+s).pubkey)),a=await e.getMultipleAccountsInfo(n);return o.filter(((e,r)=>!!a[r]))},exports.getAllDomains=async function(e,r){const t=[{memcmp:{offset:32,bytes:r.toBase58()}},{memcmp:{offset:0,bytes:L.toBase58()}}];return(await e.getProgramAccounts(K,{filters:t})).map((e=>e.pubkey))},exports.getAllRegisteredDomains=async e=>{const r=[{memcmp:{offset:0,bytes:L.toBase58()}}];return await e.getProgramAccounts(K,{dataSlice:{offset:32,length:32},filters:r})},exports.getArtistPubkey=e=>{if(e===exports.CustomBg.DegenPoet1)return Ce;throw new x(exports.ErrorType.InvalidCustomBg)},exports.getArweaveRecord=async(e,r)=>await be(e,r,exports.Record.ARWV,!0),exports.getBackgroundRecord=async(e,r)=>await be(e,r,exports.Record.Background,!0),exports.getBackpackRecord=async(e,r)=>await be(e,r,exports.Record.Backpack,!0),exports.getBscRecord=async(e,r)=>await be(e,r,exports.Record.BSC,!0),exports.getBtcRecord=async(e,r)=>await be(e,r,exports.Record.BTC,!0),exports.getCustomBgKeys=(e,r)=>{const t=Q(r),i=Q(e),s=$(i,void 0,Y);return{domainKey:s,bgKey:$(t,void 0,s)}},exports.getDiscordRecord=async(e,r)=>await be(e,r,exports.Record.Discord,!0),exports.getDogeRecord=async(e,r)=>await be(e,r,exports.Record.DOGE,!0),exports.getDomainKey=ge,exports.getDomainKeySync=ie,exports.getEmailRecord=async(e,r)=>await be(e,r,exports.Record.Email,!0),exports.getEthRecord=async(e,r)=>await be(e,r,exports.Record.ETH,!0),exports.getFavoriteDomain=async(e,t)=>{const[i]=Ke.getKeySync(We,new r.PublicKey(t)),s=await Ke.retrieve(e,i),o=await ee(e,s.nameAccount);return{domain:s.nameAccount,reverse:o}},exports.getGithubRecord=async(e,r)=>await be(e,r,exports.Record.Github,!0),exports.getGuardianPublickey=je,exports.getHandleAndRegistryKey=async function(e,t){const i=await de(t.toString()),s=await fe(i,_,G);let o=await Ne.retrieve(e,s);return[o.twitterHandle,new r.PublicKey(o.twitterRegistryKey)]},exports.getHashedName=de,exports.getHashedNameSync=Q,exports.getInjectiveRecord=async(e,r)=>await be(e,r,exports.Record.Injective,!0),exports.getIpfsRecord=async(e,r)=>await be(e,r,exports.Record.IPFS,!0),exports.getLtcRecord=async(e,r)=>await be(e,r,exports.Record.LTC,!0),exports.getMessageToSign=(e,r,t)=>{const i=Qe(e,t),s=$e(r,t),o=Buffer.concat([s.toBuffer(),i]).toString("hex");return Buffer.from(o)},exports.getNameAccountKey=fe,exports.getNameAccountKeySync=$,exports.getNameOwner=pe,exports.getPicRecord=async(e,r)=>await be(e,r,exports.Record.Pic,!0),exports.getPointRecord=async(e,r)=>await be(e,r,exports.Record.POINT,!0),exports.getRecord=be,exports.getRecordKeySync=me,exports.getRecordV2Key=$e,exports.getRecords=async function(e,r,t,i){const s=t.map((e=>me(r,e))),o=await ue.retrieveBatch(e,s);return i?o.map(((e,i)=>{if(e)return Re(e,t[i],me(r,t[i]))})):o},exports.getRedditRecord=async(e,r)=>await be(e,r,exports.Record.Reddit,!0),exports.getReverseKey=async(e,r)=>{const{pubkey:t,parent:i}=await ge(e),s=await de(t.toBase58());return await fe(s,M,r?i:void 0)},exports.getReverseKeySync=se,exports.getShdwRecord=async(e,r)=>await be(e,r,exports.Record.SHDW,!0),exports.getSignatureByteLength=Ve,exports.getSolRecord=Se,exports.getTelegramRecord=async(e,r)=>await be(e,r,exports.Record.Telegram,!0),exports.getTokenizedDomains=async(e,r)=>{const i=await(async(e,r)=>{const i=[...ae(r.toBase58()),{dataSize:165}],s=(await e.getProgramAccounts(t.TOKEN_PROGRAM_ID,{filters:i})).map((e=>t.AccountLayout.decode(e.account.data))).map((r=>ce(e,r)));return(await Promise.all(s)).filter((e=>void 0!==e))})(e,r);return(await re(e,i.map((e=>e.nameAccount)))).map(((e,r)=>({key:i[r].nameAccount,mint:i[r].nftMint,reverse:e}))).filter((e=>!!e.reverse))},exports.getTwitterHandleandRegistryKeyViaFilters=async function(e,t){const i=[{memcmp:{offset:0,bytes:G.toBase58()}},{memcmp:{offset:32,bytes:t.toBase58()}},{memcmp:{offset:64,bytes:_.toBase58()}}],o=await e.getProgramAccounts(K,{filters:i});for(const e of o)if(e.account.data.length>ue.HEADER_LEN+32){let t=e.account.data.slice(ue.HEADER_LEN),i=s.deserializeUnchecked(Ne.schema,Ne,t);return[i.twitterHandle,new r.PublicKey(i.twitterRegistryKey)]}throw new x(exports.ErrorType.AccountDoesNotExist)},exports.getTwitterRecord=async(e,r)=>await be(e,r,exports.Record.Twitter,!0),exports.getTwitterRegistry=async function(e,r){const t=await de(r),i=await fe(t,void 0,G),{registry:s}=await ue.retrieve(e,i);return s},exports.getTwitterRegistryData=async function(t,i){const s=[{memcmp:{offset:0,bytes:G.toBase58()}},{memcmp:{offset:32,bytes:i.toBase58()}},{memcmp:{offset:64,bytes:new r.PublicKey(e.Buffer.alloc(32,0)).toBase58()}}],o=await t.getProgramAccounts(K,{filters:s});if(o.length>1)throw new x(exports.ErrorType.MultipleRegistries);return o[0].account.data.slice(ue.HEADER_LEN)},exports.getTwitterRegistryKey=async function(e){const r=await de(e);return await fe(r,void 0,G)},exports.getUrlRecord=async(e,r)=>await be(e,r,exports.Record.Url,!0),exports.performReverseLookup=async function(e,r){const t=await de(r.toBase58()),s=await fe(t,M),{registry:o}=await ue.retrieve(e,s);if(!o.data)throw new x(exports.ErrorType.NoAccountData);const n=new i(o.data.slice(0,4),"le").toNumber();return o.data.slice(4,4+n).toString()},exports.performReverseLookupBatch=async function(e,r){let t=[];for(let e of r){const r=await de(e.toBase58()),i=await fe(r,M);t.push(i)}return(await ue.retrieveBatch(e,t)).map((e=>{if(void 0===e||void 0===e.data)return;let r=new i(e.data.slice(0,4),"le").toNumber();return e.data.slice(4,4+r).toString()}))},exports.registerDomainName=async(e,i,s,o,a,c=j,u)=>{if(i.includes(".")||i.trim().toLowerCase()!==i)throw new x(exports.ErrorType.InvalidDomain);const[p]=r.PublicKey.findProgramAddressSync([U.toBuffer()],U),d=Q(i),f=$(d,void 0,L),l=Q(f.toBase58()),g=$(l,p),[y]=r.PublicKey.findProgramAddressSync([f.toBuffer()],U),w=H.findIndex((e=>null==u?void 0:u.equals(e)));let h;const m=[];if(-1!==w&&u){h=t.getAssociatedTokenAddressSync(c,u,!0);const r=await e.getAccountInfo(h);if(!(null==r?void 0:r.data)){const e=t.createAssociatedTokenAccountInstruction(o,h,u,c);m.push(e)}}const b=new n.PythHttpClient(e,n.getPythProgramKeyForCluster("mainnet-beta")),S=await b.getData(),R=F.get(c.toBase58());if(!R)throw new x(exports.ErrorType.SymbolNotFound,`No symbol found for mint ${c.toBase58()}`);const v=S.productPrice.get("Crypto."+R+"/USD"),A=S.productFromSymbol.get("Crypto."+R+"/USD"),E=t.getAssociatedTokenAddressSync(c,X),B=new k({name:i,space:s,referrerIdxOpt:-1!=w?w:null}).getInstruction(U,K,L,f,g,r.SystemProgram.programId,p,o,a,q,v.productAccountKey,new r.PublicKey(A.price_account),E,t.TOKEN_PROGRAM_ID,r.SYSVAR_RENT_PUBKEY,y,h);return m.push(B),[[],m]},exports.registerWithNft=(e,i,s,o,n,a,c,u,p)=>{const[d]=r.PublicKey.findProgramAddressSync([s.toBuffer()],U);return new I({space:i,name:e}).getInstruction(U,K,L,s,o,r.SystemProgram.programId,M,n,a,c,u,p,Z,t.TOKEN_PROGRAM_ID,r.SYSVAR_RENT_PUBKEY,d,J)},exports.resolve=async(t,i)=>{const{pubkey:s}=ie(i),{registry:o,nftOwner:n}=await ue.retrieve(t,s);if(n)return n;try{const s=me(i,exports.Record.SOL),n=await Se(t,i);if(!(null==n?void 0:n.data))throw new x(exports.ErrorType.NoRecordData);const a=new TextEncoder,c=e.Buffer.concat([n.data.slice(0,32),s.toBuffer()]),u=a.encode(c.toString("hex"));if(!xe(u,n.data.slice(32),o.owner))throw new x(exports.ErrorType.InvalidSignature);return new r.PublicKey(n.data.slice(0,32))}catch(e){if(e instanceof Error&&"FetchError"===e.name)throw e}return o.owner},exports.retrieveNftOwner=ne,exports.retrieveNfts=async e=>{const t=await e.getProgramAccounts(P,{filters:[{memcmp:{offset:0,bytes:"3"}}]});return t.map((e=>new r.PublicKey(e.account.data.slice(66,98))))},exports.reverseLookup=ee,exports.reverseLookupBatch=re,exports.serializeRecord=ve,exports.serializeRecordV2Content=Qe,exports.serializeSolRecord=Ae,exports.transferInstruction=v,exports.transferNameOwnership=async function(e,r,t,i,s,o){const n=await de(r),a=await fe(n,i,s);let c;return c=i||(await ue.retrieve(e,a)).registry.owner,v(K,a,t,c,i,s,o)},exports.updateInstruction=R,exports.updateNameRegistryData=async function(e,r,t,i,s,o){const n=await de(r),a=await fe(n,s,o);let c;return c=s||(await ue.retrieve(e,a)).registry.owner,R(K,a,new m(t),i,c)},exports.updateRecordInstruction=async(e,r,t,i,s,o)=>{oe(t!==exports.Record.SOL,exports.ErrorType.UnsupportedRecord);const{pubkey:n}=ie(`${t}.${r}`,exports.RecordVersion.V1),a=await e.getAccountInfo(n);oe(!!(null==a?void 0:a.data),exports.ErrorType.AccountDoesNotExist);const c=ve(i,t);if((null==a?void 0:a.data.slice(96).length)!==c.length)return[A(K,n,o,s),await Ie(e,r,t,i,s,o)];return[R(K,n,new m(0),c,s)]},exports.updateRecordV2Instruction=async(r,t,i,s,o,n)=>{const{pubkey:a}=ie(`${i}.${t}`,exports.RecordVersion.V2),c=await r.getAccountInfo(a),u=s.serialize();if(c&&(null==c?void 0:c.data.slice(96).length)!==u.length)return[A(K,a,n,o),await Te(r,t,i,s,o,n),R(K,a,new m(0),e.Buffer.from(u),o)];return[R(K,a,new m(0),e.Buffer.from(u),o)]},exports.updateSolRecordInstruction=async(e,r,t,i,s,o)=>{const{pubkey:n}=ie(`${exports.Record.SOL}.${r}`,exports.RecordVersion.V1),a=await e.getAccountInfo(n);if(oe(!!(null==a?void 0:a.data),exports.ErrorType.AccountDoesNotExist),96!==(null==a?void 0:a.data.length))return[A(K,n,o,i),await Pe(e,r,t,i,s,o)];const c=Ae(t,n,i,s);return[R(K,n,new m(0),c,i)]},exports.verifyEthereumSignature=Fe,exports.verifyGuardianSignature=qe,exports.verifyInjectiveSignature=(e,r,t)=>{throw new Error("TODO")},exports.verifySolanaSignature=He,exports.verifyUserSignature=Xe;
package/dist/index.d.ts CHANGED
@@ -13,5 +13,5 @@ export * from "./types/custom-bg";
13
13
  export * from "./resolve";
14
14
  export * from "./deprecated/utils";
15
15
  export * from "./error";
16
- export * from "./record_v2";
17
16
  export * from "./custom-bg";
17
+ export * from "./record_v2";
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{Buffer as e}from"buffer";import{PublicKey as t,TransactionInstruction as r,SystemProgram as n,SYSVAR_RENT_PUBKEY as i}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as a,getMint as s,AccountLayout as o,getAssociatedTokenAddressSync as c,createAssociatedTokenAccountInstruction as u}from"@solana/spl-token";import f from"bn.js";import{serialize as d,deserialize as l,deserializeUnchecked as w}from"borsh";import{sha256 as p}from"@ethersproject/sha2";import{PythHttpClient as g,getPythProgramKeyForCluster as h}from"@pythnetwork/client";import{decode as m,encode as y}from"bech32-buffer";import*as S from"tweetnacl";import b from"bs58";import v from"ipaddr.js";import{encode as A,decode as k}from"punycode";import{hashMessage as B}from"@ethersproject/hash";import{recoverAddress as I}from"@ethersproject/transactions";import{getAddress as E}from"@ethersproject/address";var R;!function(e){e.SymbolNotFound="SymbolNotFound",e.InvalidSubdomain="InvalidSubdomain",e.FavouriteDomainNotFound="FavouriteDomainNotFound",e.MissingParentOwner="MissingParentOwner",e.U32Overflow="U32Overflow",e.InvalidBufferLength="InvalidBufferLength",e.U64Overflow="U64Overflow",e.NoRecordData="NoRecordData",e.InvalidRecordData="InvalidRecordData",e.UnsupportedRecord="UnsupportedRecord",e.InvalidEvmAddress="InvalidEvmAddress",e.InvalidInjectiveAddress="InvalidInjectiveAddress",e.InvalidARecord="InvalidARecord",e.InvalidAAAARecord="InvalidAAAARecord",e.InvalidRecordInput="InvalidRecordInput",e.InvalidSignature="InvalidSignature",e.AccountDoesNotExist="AccountDoesNotExist",e.MultipleRegistries="MultipleRegistries",e.InvalidReverseTwitter="InvalidReverseTwitter",e.NoAccountData="NoAccountData",e.InvalidInput="InvalidInput",e.InvalidDomain="InvalidDomain",e.UnsupportedSignature="UnsupportedSignature",e.RecordDoestNotSupportGuardianSig="RecordDoestNotSupportGuardianSig",e.RecordIsNotSigned="RecordIsNotSigned",e.UnsupportedSignatureType="UnsupportedSignatureType",e.InvalidCustomBg="InvalidCustomBackground"}(R||(R={}));class D extends Error{constructor(e,t){super(t),this.name="SNSError",this.type=e,Error.captureStackTrace&&Error.captureStackTrace(this,D)}}class N extends f{toBuffer(){const t=super.toArray().reverse(),r=e.from(t);if(4===r.length)return r;if(r.length>4)throw new D(R.U32Overflow);const n=e.alloc(4);return r.copy(n),n}static fromBuffer(e){if(4!==e.length)throw new D(R.InvalidBufferLength,`Invalid buffer length: ${e.length}`);return new f([...e].reverse().map((e=>`00${e.toString(16)}`.slice(-2))).join(""),16)}}class W extends f{toBuffer(){const t=super.toArray().reverse(),r=e.from(t);if(8===r.length)return r;if(r.length>8)throw new D(R.U64Overflow);const n=e.alloc(8);return r.copy(n),n}static fromBuffer(e){if(8!==e.length)throw new D(R.U64Overflow,`Invalid buffer length: ${e.length}`);return new f([...e].reverse().map((e=>`00${e.toString(16)}`.slice(-2))).join(""),16)}}function T(n,i,a,s,o,c,u,f,d,l,w){const p=[e.from(Int8Array.from([0])),new N(c.length).toBuffer(),c,u.toBuffer(),f.toBuffer()],g=e.concat(p),h=[{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!0,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1}];return d?h.push({pubkey:d,isSigner:!0,isWritable:!1}):h.push({pubkey:new t(e.alloc(32)),isSigner:!1,isWritable:!1}),l?h.push({pubkey:l,isSigner:!1,isWritable:!1}):h.push({pubkey:new t(e.alloc(32)),isSigner:!1,isWritable:!1}),w&&h.push({pubkey:w,isSigner:!0,isWritable:!1}),new r({keys:h,programId:n,data:g})}function x(t,n,i,a,s){const o=[e.from(Int8Array.from([1])),i.toBuffer(),new N(a.length).toBuffer(),a],c=e.concat(o);return new r({keys:[{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1}],programId:t,data:c})}function L(n,i,a,s,o,c,u){const f=[e.from(Int8Array.from([2])),a.toBuffer()],d=e.concat(f),l=[{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:u||s,isSigner:!0,isWritable:!1}];return o&&l.push({pubkey:o,isSigner:!0,isWritable:!1}),u&&c&&(o||l.push({pubkey:t.default,isSigner:!1,isWritable:!1}),l.push({pubkey:c,isSigner:!1,isWritable:!1})),new r({keys:l,programId:n,data:d})}function C(t,n,i,a){const s=[e.from(Int8Array.from([3]))],o=e.concat(s);return new r({keys:[{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!0,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!0}],programId:t,data:o})}class P{constructor(e){this.tag=9,this.name=e.name,this.space=e.space}serialize(){return d(P.schema,this)}getInstruction(t,i,s,o,c,u,f,d,l,w,p){const g=e.from(this.serialize()),h=[{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:u,isSigner:!1,isWritable:!0},{pubkey:n.programId,isSigner:!1,isWritable:!1},{pubkey:f,isSigner:!1,isWritable:!1},{pubkey:d,isSigner:!0,isWritable:!0},{pubkey:l,isSigner:!1,isWritable:!0},{pubkey:w,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!1},{pubkey:p,isSigner:!1,isWritable:!1}];return new r({keys:h,programId:t,data:g})}}P.schema=new Map([[P,{kind:"struct",fields:[["tag","u8"],["name","string"],["space","u32"]]}]]);class j{constructor(e){this.tag=12,this.name=e.name}serialize(){return d(j.schema,this)}getInstruction(t,n,i,a,s,o,c,u,f,d){const l=e.from(this.serialize());let w=[];return w.push({pubkey:n,isSigner:!1,isWritable:!1}),w.push({pubkey:i,isSigner:!1,isWritable:!1}),w.push({pubkey:a,isSigner:!1,isWritable:!0}),w.push({pubkey:s,isSigner:!1,isWritable:!1}),w.push({pubkey:o,isSigner:!1,isWritable:!1}),w.push({pubkey:c,isSigner:!0,isWritable:!0}),w.push({pubkey:u,isSigner:!1,isWritable:!1}),f&&w.push({pubkey:f,isSigner:!1,isWritable:!0}),d&&w.push({pubkey:d,isSigner:!0,isWritable:!0}),new r({keys:w,programId:t,data:l})}}j.schema=new Map([[j,{kind:"struct",fields:[["tag","u8"],["name","string"]]}]]);class U{constructor(e){this.tag=13,this.name=e.name,this.space=e.space,this.referrerIdxOpt=e.referrerIdxOpt}serialize(){return d(U.schema,this)}getInstruction(t,n,i,a,s,o,c,u,f,d,l,w,p,g,h,m,y){const S=e.from(this.serialize());let b=[];return b.push({pubkey:n,isSigner:!1,isWritable:!1}),b.push({pubkey:i,isSigner:!1,isWritable:!1}),b.push({pubkey:a,isSigner:!1,isWritable:!0}),b.push({pubkey:s,isSigner:!1,isWritable:!0}),b.push({pubkey:o,isSigner:!1,isWritable:!1}),b.push({pubkey:c,isSigner:!1,isWritable:!1}),b.push({pubkey:u,isSigner:!0,isWritable:!0}),b.push({pubkey:f,isSigner:!1,isWritable:!0}),b.push({pubkey:d,isSigner:!1,isWritable:!1}),b.push({pubkey:l,isSigner:!1,isWritable:!1}),b.push({pubkey:w,isSigner:!1,isWritable:!1}),b.push({pubkey:p,isSigner:!1,isWritable:!0}),b.push({pubkey:g,isSigner:!1,isWritable:!1}),b.push({pubkey:h,isSigner:!1,isWritable:!1}),b.push({pubkey:m,isSigner:!1,isWritable:!1}),y&&b.push({pubkey:y,isSigner:!1,isWritable:!0}),new r({keys:b,programId:t,data:S})}}U.schema=new Map([[U,{kind:"struct",fields:[["tag","u8"],["name","string"],["space","u32"],["referrerIdxOpt",{kind:"option",type:"u16"}]]}]]);const H=new t("nftD3vbNkNqfj2Sd3HZwbpw4BxxKWr4AjGb9X38JeZk"),M=e.from("tokenized_name");var z;!function(e){e[e.Uninitialized=0]="Uninitialized",e[e.CentralState=1]="CentralState",e[e.ActiveRecord=2]="ActiveRecord",e[e.InactiveRecord=3]="InactiveRecord"}(z||(z={}));class F{constructor(e){this.tag=e.tag,this.nonce=e.nonce,this.nameAccount=new t(e.nameAccount),this.owner=new t(e.owner),this.nftMint=new t(e.nftMint)}static deserialize(e){return l(this.schema,F,e)}static async retrieve(e,t){const r=await e.getAccountInfo(t);if(!r||!r.data)throw new Error("NFT record not found");return this.deserialize(r.data)}static async findKey(r,n){return await t.findProgramAddress([e.from("nft_record"),r.toBuffer()],n)}}F.schema=new Map([[F,{kind:"struct",fields:[["tag","u8"],["nonce","u8"],["nameAccount",[32]],["owner",[32]],["nftMint",[32]]]}]]);const G=new t("namesLPneVptA9Z5rqUDD9tMTWEJwofgaYwp8cawRkX"),O="SPL Name Service",V=new t("58PwtjSDuFHuUkYjH9BYnnQKHfwo9reZhC2zMJv9JPkx"),X=new t("jCebN34bUfdeUYJT13J1yG16XWQpt5PDx6Mse9GUqhR"),K=new t("ETp9eKXVv1dWwHSpsXRUuXHmw24PwRkttCGVgpZEY9zF"),Z=new t("AUoZ3YAhV3b2rZeEH93UMZHXUZcTramBvb4d9YEVySkc"),q=new t("33m47vH6Eav6jr5Ry86XjhRft2jRBLDnDgPSHoquXi2Z"),J=new t("FvPH7PrVrLGKPfqaf3xJodFTjZriqrAXXLTVWEorTFBi"),Y=new t("4YcexoW3r78zz16J2aqmukBLRwGq6rAvWzJpkYAXqebv"),Q=96,$=new t("DmSyHDSM9eSLyvoLsPvDr5fRRFZ7Bfr3h3ULvWpgQaq7"),_=new t("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),ee=[new t("3ogYncmMM5CmytsGCqKHydmXmKUZ6sGWvizkzqwT7zb1"),new t("DM1jJCkZZEwY5tmWbgvKRxsDFzXCdbfrYCCH1CtwguEs"),new t("ADCp4QXFajHrhy4f43pD6GJFtQLkdBY2mjS9DfCk7tNW"),new t("2XTgjw8yi1E3Etgj4CUyRD7Zk49gynH2U9gA5N2MY4NP"),new t("5oDWj8vr3vbcq9JZTtwXqrkCMZggMsDzNietvbr1BNfe"),new t("8kJqxAbqbPLGLMgB6FhLcnw2SiUEavx2aEGM3WQGhtJF")],te=new Map([["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v","USDC"],["Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB","USDT"],["So11111111111111111111111111111111111111112","SOL"],["EchesyfXePKdLtoiZSL8pBe8Myagyy8ZRqsACNCFGnvp","FIDA"],["FeGn77dhg1KXRRFeSwwMiykZnZPw5JXW6naf2aQgZDQf","ETH"],["7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx","GMT"],["AFbX8oGjGpmVFywbVouvhQSRmiW2aR1mohfahi4Y2AdB","GST"],["mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So","MSOL"],["DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263","BONK"],["EPeUFDgHRxs9xxEPVaL6kfGQvCon7jmAWKVUHuux1Tpz","BAT"]]),re=new t("AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J"),ne=new t("GcWEQ9K78FV7LEHteFVciYApERk5YvQuFDQPk1yYJVXi"),ie=new t("BPeXUQDqGbzxeK1LJby6ugvCBuo7kRSEUkjD726mUVsz"),ae=t=>{const r=O+t,n=p(e.from(r,"utf8")).slice(2);return e.from(n,"hex")},se=(r,n,i)=>{const a=[r];n?a.push(n.toBuffer()):a.push(e.alloc(32)),i?a.push(i.toBuffer()):a.push(e.alloc(32));const[s]=t.findProgramAddressSync(a,G);return s};async function oe(e,t){const r=ae(t.toBase58()),n=se(r,q),{registry:i}=await ve.retrieve(e,n);if(!i.data)throw new D(R.NoAccountData);const a=new f(i.data.slice(0,4),"le").toNumber();return i.data.slice(4,4+a).toString()}async function ce(e,t){let r=[];for(let e of t){const t=ae(e.toBase58()),n=se(t,q);r.push(n)}return(await ve.retrieveBatch(e,r)).map((e=>{if(void 0===e||void 0===e.data)return;let t=new f(e.data.slice(0,4),"le").toNumber();return e.data.slice(4,4+t).toString()}))}const ue=async(e,t)=>{const r=[{memcmp:{offset:0,bytes:t.toBase58()}},{memcmp:{offset:64,bytes:q.toBase58()}}],n=await e.getProgramAccounts(G,{filters:r}),i=await oe(e,t),a=n.map((e=>{var t;return null===(t=e.account.data.slice(97).toString("utf-8"))||void 0===t?void 0:t.split("\0").join("")})),s=a.map((e=>de(e+"."+i).pubkey)),o=await e.getMultipleAccountsInfo(s);return a.filter(((e,t)=>!!o[t]))},fe=(e,t=V)=>{let r=ae(e);return{pubkey:se(r,void 0,t),hashed:r}},de=(t,r)=>{t.endsWith(".sol")&&(t=t.slice(0,-4));const n=t.split(".");if(2===n.length){const t=e.from([r||0]).toString().concat(n[0]),{pubkey:i}=fe(n[1]);return{...fe(t,i),isSub:!0,parent:i}}if(3===n.length&&r){const{pubkey:t}=fe(n[2]),{pubkey:r}=fe("\0".concat(n[1]),t),i=e.from([1]).toString();return{...fe(i.concat(n[0]),r),isSub:!0,parent:t,isSubRecord:!0}}if(n.length>=3)throw new D(R.InvalidInput);return{...fe(t,V),isSub:!1,parent:void 0}};async function le(e,t){const r=[{memcmp:{offset:32,bytes:t.toBase58()}},{memcmp:{offset:0,bytes:V.toBase58()}}];return(await e.getProgramAccounts(G,{filters:r})).map((e=>e.pubkey))}const we=async e=>{const t=[{memcmp:{offset:0,bytes:V.toBase58()}}];return await e.getProgramAccounts(G,{dataSlice:{offset:32,length:32},filters:t})},pe=(e,t)=>{const{pubkey:r,parent:n}=de(e),i=ae(r.toBase58());return se(i,q,t?n:void 0)},ge=(e,t)=>{if(!e)throw new D(t)},he=async(e,r)=>{try{const[n]=await t.findProgramAddress([M,r.toBuffer()],H);if("0"===(await s(e,n)).supply.toString())return;const i=[{memcmp:{offset:0,bytes:n.toBase58()}},{memcmp:{offset:64,bytes:"2"}},{dataSize:165}],o=await e.getProgramAccounts(a,{filters:i});if(1!=o.length)return;return new t(o[0].account.data.slice(32,64))}catch{return}},me=async e=>{const r=await e.getProgramAccounts(H,{filters:[{memcmp:{offset:0,bytes:"3"}}]});return r.map((e=>new t(e.account.data.slice(66,98))))},ye=e=>[{memcmp:{offset:32,bytes:e}},{memcmp:{offset:64,bytes:"2"}}],Se=async(e,t)=>{const r=await(async(e,t)=>{const r=[{memcmp:{offset:0,bytes:"3"}},{memcmp:{offset:66,bytes:t.toBase58()}}];return await e.getProgramAccounts(H,{filters:r})})(e,t.mint);if(1===r.length)return F.deserialize(r[0].account.data)},be=async(e,t)=>{const r=await(async(e,t)=>{const r=[...ye(t.toBase58()),{dataSize:165}],n=(await e.getProgramAccounts(a,{filters:r})).map((e=>o.decode(e.account.data))).map((t=>Se(e,t)));return(await Promise.all(n)).filter((e=>void 0!==e))})(e,t);return(await ce(e,r.map((e=>e.nameAccount)))).map(((e,t)=>({key:r[t].nameAccount,mint:r[t].nftMint,reverse:e}))).filter((e=>!!e.reverse))};class ve{constructor(e){this.parentName=new t(e.parentName),this.owner=new t(e.owner),this.class=new t(e.class)}static async retrieve(e,t){var r;const n=await e.getAccountInfo(t);if(!n)throw new D(R.AccountDoesNotExist);let i=w(this.schema,ve,n.data);i.data=null===(r=n.data)||void 0===r?void 0:r.slice(this.HEADER_LEN);return{registry:i,nftOwner:await he(e,t)}}static async _retrieveBatch(e,t){const r=await e.getMultipleAccountsInfo(t),n=e=>{if(!e)return;const t=w(this.schema,ve,e);return t.data=null==e?void 0:e.slice(this.HEADER_LEN),t};return r.map((e=>n(null==e?void 0:e.data)))}static async retrieveBatch(e,t){let r=[];const n=[...t];for(;n.length>0;)r.push(...await this._retrieveBatch(e,n.splice(0,100)));return r}}async function Ae(e,t){if(!await e.getAccountInfo(t))throw new D(R.AccountDoesNotExist);return ve.retrieve(e,t)}async function ke(t){const r=O+t,n=p(e.from(r,"utf8")).slice(2);return e.from(n,"hex")}async function Be(r,n,i){const a=[r];n?a.push(n.toBuffer()):a.push(e.alloc(32)),i?a.push(i.toBuffer()):a.push(e.alloc(32));const[s]=await t.findProgramAddress(a,G);return s}async function Ie(e,t){const r=await ke(t.toBase58()),n=await Be(r,q),{registry:i}=await ve.retrieve(e,n);if(!i.data)throw new D(R.NoAccountData);const a=new f(i.data.slice(0,4),"le").toNumber();return i.data.slice(4,4+a).toString()}async function Ee(e,t){let r=[];for(let e of t){const t=await ke(e.toBase58()),n=await Be(t,q);r.push(n)}return(await ve.retrieveBatch(e,r)).map((e=>{if(void 0===e||void 0===e.data)return;let t=new f(e.data.slice(0,4),"le").toNumber();return e.data.slice(4,4+t).toString()}))}ve.HEADER_LEN=96,ve.schema=new Map([[ve,{kind:"struct",fields:[["parentName",[32]],["owner",[32]],["class",[32]]]}]]);const Re=async(e,t=V)=>{let r=await ke(e);return{pubkey:await Be(r,void 0,t),hashed:r}},De=async(t,r=!1)=>{t.endsWith(".sol")&&(t=t.slice(0,-4));const n=t.split(".");if(2===n.length){const t=e.from([r?1:0]).toString().concat(n[0]),{pubkey:i}=await Re(n[1]);return{...await Re(t,i),isSub:!0,parent:i}}if(3===n.length&&r){const{pubkey:t}=await Re(n[2]),{pubkey:r}=await Re("\0".concat(n[1]),t),i=e.from([1]).toString();return{...await Re(i.concat(n[0]),r),isSub:!0,parent:t,isSubRecord:!0}}if(n.length>=3)throw new D(R.InvalidInput);return{...await Re(t,V),isSub:!1,parent:void 0}},Ne=async(e,t)=>{const{pubkey:r,parent:n}=await De(e),i=await ke(r.toBase58());return await Be(i,q,t?n:void 0)};var We;!function(e){e.IPFS="IPFS",e.ARWV="ARWV",e.SOL="SOL",e.ETH="ETH",e.BTC="BTC",e.LTC="LTC",e.DOGE="DOGE",e.Email="email",e.Url="url",e.Discord="discord",e.Github="github",e.Reddit="reddit",e.Twitter="twitter",e.Telegram="telegram",e.Pic="pic",e.SHDW="SHDW",e.POINT="POINT",e.BSC="BSC",e.Injective="INJ",e.Backpack="backpack",e.A="A",e.AAAA="AAAA",e.CNAME="CNAME",e.TXT="TXT",e.Background="background"}(We||(We={}));const Te=new Map([[We.SOL,96],[We.ETH,20],[We.BSC,20],[We.Injective,20],[We.A,4],[We.AAAA,16],[We.Background,32]]);var xe;!function(e){e[e.V1=1]="V1",e[e.V2=2]="V2"}(xe||(xe={}));const Le=(e,t,r)=>S.sign.detached.verify(e,t,r.toBytes()),Ce=async(r,n)=>{const{pubkey:i}=de(n),{registry:a,nftOwner:s}=await ve.retrieve(r,i);if(s)return s;try{const i=Pe(n,We.SOL),s=await _e(r,n);if(!(null==s?void 0:s.data))throw new D(R.NoRecordData);const o=new TextEncoder,c=e.concat([s.data.slice(0,32),i.toBuffer()]),u=o.encode(c.toString("hex"));if(!Le(u,s.data.slice(32),a.owner))throw new D(R.InvalidSignature);return new t(s.data.slice(0,32))}catch(e){if(e instanceof Error&&"FetchError"===e.name)throw e}return a.owner},Pe=(e,t)=>{const{pubkey:r}=de(t+"."+e,xe.V1);return r};async function je(e,t,r,n){const i=Pe(t,r);let{registry:a}=await ve.retrieve(e,i);if(!a.data)throw new D(R.NoRecordData);if(n)return at(a,r,i);const s=Te.get(r);return a.data=a.data.slice(0,s),a}async function Ue(e,t,r,n){const i=r.map((e=>Pe(t,e))),a=await ve.retrieveBatch(e,i);return n?a.map(((e,n)=>{if(e)return at(e,r[n],Pe(t,r[n]))})):a}const He=async(e,t)=>await je(e,t,We.IPFS,!0),Me=async(e,t)=>await je(e,t,We.ARWV,!0),ze=async(e,t)=>await je(e,t,We.ETH,!0),Fe=async(e,t)=>await je(e,t,We.BTC,!0),Ge=async(e,t)=>await je(e,t,We.LTC,!0),Oe=async(e,t)=>await je(e,t,We.DOGE,!0),Ve=async(e,t)=>await je(e,t,We.Email,!0),Xe=async(e,t)=>await je(e,t,We.Url,!0),Ke=async(e,t)=>await je(e,t,We.Discord,!0),Ze=async(e,t)=>await je(e,t,We.Github,!0),qe=async(e,t)=>await je(e,t,We.Reddit,!0),Je=async(e,t)=>await je(e,t,We.Twitter,!0),Ye=async(e,t)=>await je(e,t,We.Telegram,!0),Qe=async(e,t)=>await je(e,t,We.Pic,!0),$e=async(e,t)=>await je(e,t,We.SHDW,!0),_e=async(e,t)=>await je(e,t,We.SOL),et=async(e,t)=>await je(e,t,We.POINT,!0),tt=async(e,t)=>await je(e,t,We.BSC,!0),rt=async(e,t)=>await je(e,t,We.Injective,!0),nt=async(e,t)=>await je(e,t,We.Backpack,!0),it=async(e,t)=>await je(e,t,We.Background,!0),at=(r,n,i)=>{const a=null==r?void 0:r.data;if(!a)return;if(0===a.compare(e.alloc(a.length)))return;const s=Te.get(n),o=(e=>{const t=Array.from(e);return t.length-1-t.reverse().findIndex((e=>0!==e))+1})(a);if(!s)return a.slice(0,o).toString("utf-8");if(n===We.SOL){const t=new TextEncoder,n=e.concat([a.slice(0,32),i.toBuffer()]),s=t.encode(n.toString("hex"));if(Le(s,a.slice(32,96),r.owner))return b.encode(a.slice(0,32))}if(s&&o!==s){const t=a.slice(0,o).toString("utf-8");if(n===We.Injective){const e=m(t);if("inj"===e.prefix&&20===e.data.length)return t}else if(n===We.BSC||n===We.ETH){const r=t.slice(0,2),n=t.slice(2);if("0x"===r&&20===e.from(n,"hex").length)return t}else if((n===We.A||n===We.AAAA)&&v.isValid(t))return t;throw new D(R.InvalidRecordData)}if(n===We.ETH||n===We.BSC)return"0x"+a.slice(0,s).toString("hex");if(n===We.Injective)return y("inj",a.slice(0,s),"bech32");if(n===We.A||n===We.AAAA)return v.fromByteArray([...a.slice(0,s)]).toString();if(n===We.Background)return new t(a.slice(0,s)).toString();throw new D(R.InvalidRecordData)},st=(r,n)=>{if(!Te.get(n))return n!==We.CNAME&&n!==We.TXT||(r=A(r)),e.from(r,"utf-8");if(n===We.SOL)throw new D(R.UnsupportedRecord,"Use `serializeSolRecord` for SOL record");if(n===We.ETH||n===We.BSC)return ge("0x"===r.slice(0,2),R.InvalidEvmAddress),e.from(r.slice(2),"hex");if(n===We.Injective){const t=m(r);return ge("inj"===t.prefix,R.InvalidInjectiveAddress),ge(20===t.data.length,R.InvalidInjectiveAddress),e.from(t.data)}if(n===We.A){const t=v.parse(r).toByteArray();return ge(4===t.length,R.InvalidARecord),e.from(t)}if(n===We.AAAA){const t=v.parse(r).toByteArray();return ge(16===t.length,R.InvalidAAAARecord),e.from(t)}if(n===We.Background)return new t(r).toBuffer();throw new D(R.InvalidRecordInput)},ot=(t,r,n,i)=>{const a=e.concat([t.toBuffer(),r.toBuffer()]),s=(new TextEncoder).encode(a.toString("hex")),o=Le(s,i,n);return ge(o,R.InvalidSignature),e.concat([t.toBuffer(),i])};async function ct(e,t,r,i,a,s,o,c){const u=await ke(t),f=await Be(u,o,c),d=s||await e.getMinimumBalanceForRentExemption(r);let l;if(c){const{registry:t}=await Ae(e,c);l=t.owner}return T(G,n.programId,f,a,i,u,new W(d),new N(r),o,c,l)}async function ut(e,t,r,n,i,a){const s=await ke(t),o=await Be(s,i,a);let c;c=i||(await ve.retrieve(e,o)).registry.owner;return x(G,o,new N(r),n,c)}async function ft(e,t,r,n,i,a){const s=await ke(t),o=await Be(s,n,i);let c;c=n||(await ve.retrieve(e,o)).registry.owner;return L(G,o,r,c,n,i,a)}async function dt(e,t,r,n,i){const a=await ke(t),s=await Be(a,n,i);let o;o=n||(await ve.retrieve(e,s)).registry.owner;return C(G,s,r,o)}const lt=async(e,r,s,o,f,d=_,l)=>{if(r.includes(".")||r.trim().toLowerCase()!==r)throw new D(R.InvalidDomain);const[w]=t.findProgramAddressSync([X.toBuffer()],X),p=ae(r),m=se(p,void 0,V),y=ae(m.toBase58()),S=se(y,w),[b]=t.findProgramAddressSync([m.toBuffer()],X),v=ee.findIndex((e=>null==l?void 0:l.equals(e)));let A;const k=[];if(-1!==v&&l){A=c(d,l,!0);const t=await e.getAccountInfo(A);if(!(null==t?void 0:t.data)){const e=u(o,A,l,d);k.push(e)}}const B=new g(e,h("mainnet-beta")),I=await B.getData(),E=te.get(d.toBase58());if(!E)throw new D(R.SymbolNotFound,`No symbol found for mint ${d.toBase58()}`);const N=I.productPrice.get("Crypto."+E+"/USD"),W=I.productFromSymbol.get("Crypto."+E+"/USD"),T=c(d,ne),x=new U({name:r,space:s,referrerIdxOpt:-1!=v?v:null}).getInstruction(X,G,V,m,S,n.programId,w,o,f,re,N.productAccountKey,new t(W.price_account),T,a,i,b,A);return k.push(x),[[],k]},wt=async(e,r,a,s,o)=>{let[c]=await t.findProgramAddress([X.toBuffer()],X),u=await ke(e.toBase58()),f=await Be(u,c,s);return[[],[new j({name:r}).getInstruction(X,G,V,f,n.programId,c,a,i,s,o)]]},pt=async(e,t,r,n=2e3)=>{const i=[],a=t.split(".")[0];if(!a)throw new D(R.InvalidSubdomain);const{parent:s,pubkey:o}=de(t),c=await e.getMinimumBalanceForRentExemption(n+ve.HEADER_LEN),u=await ct(e,"\0".concat(a),n,r,r,c,void 0,s);i.push(u);const f=pe(t,!0),d=await e.getAccountInfo(f);if(!(null==d?void 0:d.data)){const[,e]=await wt(o,"\0".concat(a),r,s,r);i.push(...e)}return[[],i]},gt=async(e,t,r,i,a,s)=>{ge(r!==We.SOL,R.UnsupportedRecord);const{pubkey:o,hashed:c,parent:u}=de(`${r}.${t}`,xe.V1),f=st(i,r).length,d=await e.getMinimumBalanceForRentExemption(f+ve.HEADER_LEN);return T(G,n.programId,o,a,s,c,new W(d),new N(f),void 0,u,a)},ht=async(e,t,r,i,a,s)=>{const o=i.serialize().length,{pubkey:c,hashed:u,parent:f}=de(`${r}.${t}`,xe.V2),d=await e.getMinimumBalanceForRentExemption(o+ve.HEADER_LEN);return T(G,n.programId,c,a,s,u,new W(d),new N(o),void 0,f,a)},mt=async(e,t,r,n,i,a)=>{ge(r!==We.SOL,R.UnsupportedRecord);const{pubkey:s}=de(`${r}.${t}`,xe.V1),o=await e.getAccountInfo(s);ge(!!(null==o?void 0:o.data),R.AccountDoesNotExist);const c=st(n,r);if((null==o?void 0:o.data.slice(96).length)!==c.length)return[C(G,s,a,i),await gt(e,t,r,n,i,a)];return[x(G,s,new N(0),c,i)]},yt=async(t,r,n,i,a,s)=>{const{pubkey:o}=de(`${n}.${r}`,xe.V2),c=await t.getAccountInfo(o),u=i.serialize();if(c&&(null==c?void 0:c.data.slice(96).length)!==u.length)return[C(G,o,s,a),await ht(t,r,n,i,a,s),x(G,o,new N(0),e.from(u),a)];return[x(G,o,new N(0),e.from(u),a)]},St=async(e,t,r,n)=>{const{pubkey:i}=de(`${t}.${e}`,xe.V2);return C(G,i,n,r)},bt=async(e,t,r,i,a,s)=>{const{pubkey:o,hashed:c,parent:u}=de(`${We.SOL}.${t}`,xe.V1),f=ot(r,o,i,a).length,d=await e.getMinimumBalanceForRentExemption(f+ve.HEADER_LEN);return[T(G,n.programId,o,i,s,c,new W(d),new N(f),void 0,u,i)]},vt=async(e,t,r,n,i,a)=>{const{pubkey:s}=de(`${We.SOL}.${t}`,xe.V1),o=await e.getAccountInfo(s);if(ge(!!(null==o?void 0:o.data),R.AccountDoesNotExist),96!==(null==o?void 0:o.data.length))return[C(G,s,a,n),await bt(e,t,r,n,i,a)];const c=ot(r,s,n,i);return[x(G,s,new N(0),c,n)]};async function At(e,t,r,i,a){const s=await ke(t),o=await Be(s,void 0,Y),c=await e.getMinimumBalanceForRentExemption(i+ve.HEADER_LEN);let u=[T(G,n.programId,o,r,a,s,new W(c),new N(i),void 0,Y,J)];return u=u.concat(await xt(e,t,o,r,a)),u}async function kt(e,t,r,n){const i=await ke(e),a=await Be(i,void 0,Y);return[x(G,a,new N(r),n,t)]}async function Bt(e,t,r,n,i){const a=await ke(t),s=await Be(a,void 0,Y);let o=[L(G,s,n,r,void 0)];const c=await ke(r.toString());return await Be(c,J,void 0),o.push(await dt(e,r.toString(),i,J,Y)),o=o.concat(await xt(e,t,s,n,i)),o}async function It(e,t){const r=await ke(e),n=await Be(r,void 0,Y),i=await ke(t.toString()),a=await Be(i,J,Y);return[C(G,n,t,t),C(G,a,t,t)]}async function Et(e){const t=await ke(e);return await Be(t,void 0,Y)}async function Rt(e,t){const r=await ke(t),n=await Be(r,void 0,Y),{registry:i}=await ve.retrieve(e,n);return i}async function Dt(e,r){const n=await ke(r.toString()),i=await Be(n,J,Y);let a=await Tt.retrieve(e,i);return[a.twitterHandle,new t(a.twitterRegistryKey)]}async function Nt(e,r){const n=[{memcmp:{offset:0,bytes:Y.toBase58()}},{memcmp:{offset:32,bytes:r.toBase58()}},{memcmp:{offset:64,bytes:J.toBase58()}}],i=await e.getProgramAccounts(G,{filters:n});for(const e of i)if(e.account.data.length>ve.HEADER_LEN+32){let r=e.account.data.slice(ve.HEADER_LEN),n=w(Tt.schema,Tt,r);return[n.twitterHandle,new t(n.twitterRegistryKey)]}throw new D(R.AccountDoesNotExist)}async function Wt(r,n){const i=[{memcmp:{offset:0,bytes:Y.toBase58()}},{memcmp:{offset:32,bytes:n.toBase58()}},{memcmp:{offset:64,bytes:new t(e.alloc(32,0)).toBase58()}}],a=await r.getProgramAccounts(G,{filters:i});if(a.length>1)throw new D(R.MultipleRegistries);return a[0].account.data.slice(ve.HEADER_LEN)}class Tt{constructor(e){this.twitterRegistryKey=e.twitterRegistryKey,this.twitterHandle=e.twitterHandle}static async retrieve(e,t){let r=await e.getAccountInfo(t,"processed");if(!r)throw new D(R.InvalidReverseTwitter);return w(this.schema,Tt,r.data.slice(ve.HEADER_LEN))}}async function xt(t,r,i,a,s){const o=await ke(a.toString()),c=await Be(o,J,Y);let u=d(Tt.schema,new Tt({twitterRegistryKey:i.toBytes(),twitterHandle:r}));return[T(G,n.programId,c,a,s,o,new W(await t.getMinimumBalanceForRentExemption(u.length+ve.HEADER_LEN)),new N(u.length),J,Y,J),x(G,c,new N(0),e.from(u),J)]}Tt.schema=new Map([[Tt,{kind:"struct",fields:[["twitterRegistryKey",[32]],["twitterHandle","string"]]}]]);const Lt=new t("85iDfUvr3HJyLM2zcq5BXSiDvUWfw6cSE1FfNBo8Ap29");class Ct{constructor(e){this.tag=e.tag,this.nameAccount=new t(e.nameAccount)}static deserialize(e){return l(this.schema,Ct,e)}static async retrieve(e,t){const r=await e.getAccountInfo(t);if(!r||!r.data)throw new D(R.FavouriteDomainNotFound);return this.deserialize(r.data)}static async getKey(r,n){return await t.findProgramAddress([e.from("favourite_domain"),n.toBuffer()],r)}static getKeySync(r,n){return t.findProgramAddressSync([e.from("favourite_domain"),n.toBuffer()],r)}}Ct.schema=new Map([[Ct,{kind:"struct",fields:[["tag","u8"],["nameAccount",[32]]]}]]);const Pt=async(e,r)=>{const[n]=Ct.getKeySync(Lt,new t(r)),i=await Ct.retrieve(e,n),a=await oe(e,i.nameAccount);return{domain:i.nameAccount,reverse:a}};var jt,Ut,Ht;!function(e){e.DegenPoet1="DegenPoet#1"}(jt||(jt={})),function(e){e[e.None=0]="None",e[e.Solana=1]="Solana",e[e.Ethereum=2]="Ethereum",e[e.Injective=3]="Injective"}(Ut||(Ut={})),function(e){e[e.None=0]="None",e[e.Solana=1]="Solana"}(Ht||(Ht={}));const Mt={signatureType:Ht.None,signature:Buffer.alloc(0)},zt={signatureType:Ut.None,signature:Buffer.alloc(0)},Ft=new Map([[We.Backpack,new t("ExXjtfdQe8JacoqP9Z535WzQKjF4CzW1TTRKRgpxvya3").toBuffer()]]),Gt=new Set([We.IPFS,We.ARWV,We.LTC,We.DOGE,We.Email,We.Url,We.Discord,We.Github,We.Reddit,We.Twitter,We.Telegram,We.Pic,We.SHDW,We.POINT,We.Backpack,We.TXT,We.CNAME,We.BTC]),Ot=new Set([We.ETH,We.Injective,We.SOL]),Vt=e=>{switch(e){case Ut.None:return 0;case Ut.Solana:return 64;case Ut.Ethereum:case Ut.Injective:return 65;case Ht.None:return 0;case Ht.Solana:return 64;default:throw new D(R.UnsupportedSignature,`Unsupported signature type: ${e}`)}},Xt=e=>{const t=Ft.get(e);if(!t)throw new D(R.RecordDoestNotSupportGuardianSig);return t},Kt=(e,t,r)=>S.sign.detached.verify(e,t,r),Zt=(e,t,r)=>{const n=B(e);return I(n,t)===E(r)},qt=(e,t,r)=>{throw new Error("TODO")},Jt=(e,t,r,n)=>{switch(n){case Ut.Ethereum:case Ut.Injective:return Zt(e.toString(),t.toString(),r.toString());case Ut.Solana:return Kt(e,t,r);case Ut.None:throw new D(R.RecordIsNotSigned);default:throw new D(R.UnsupportedSignatureType)}},Yt=(e,t,r,n)=>{switch(n){case Ht.Solana:return Kt(e,t,r);case Ht.None:throw new D(R.RecordIsNotSigned);default:throw new D(R.UnsupportedSignatureType)}};class Qt{constructor(e){this.userSignature=e.userSignature,this.guardianSignature=e.guardianSignature,this.contentLength=e.contentLength}serialize(){return d(Qt.schema,this)}static deserialize(e){return l(this.schema,Qt,e)}}Qt.LEN=8,Qt.schema=new Map([[Qt,{kind:"struct",fields:[["userSignature","u16"],["guardianSignature","u16"],["contentLength","u32"]]}]]);class $t{constructor(e){this.header=e.header,this.buffer=e.buffer}getLength(){return Qt.LEN+this.buffer.length}static deserializeUnchecked(e){const t=w(Qt.schema,Qt,e);return new $t({header:t,buffer:Buffer.from(e.slice(Qt.LEN))})}serialize(){const e=this.header.serialize();return Buffer.concat([e,this.buffer])}deserializeContent(e){return _t(this.getContent(),e)}getContent(){const e=Vt(this.header.guardianSignature)+Vt(this.header.userSignature);return Buffer.from(this.buffer.slice(e,e+this.header.contentLength))}static new(e,t,r=Mt,n=zt){const i=er(e,t),a=Buffer.concat([r.signature,n.signature,i]),s=new Qt({userSignature:r.signatureType,guardianSignature:n.signatureType,contentLength:i.length});return new $t({header:s,buffer:a})}checkGuardianSignature(e,t){const r=Vt(this.header.guardianSignature),n=Vt(this.header.userSignature),i=Buffer.from(this.buffer.slice(n,n+r));return Jt(e,i,t,this.header.guardianSignature)}checkUserSignature(e,t){const r=Vt(this.header.userSignature),n=Buffer.from(this.buffer.slice(0,r));return Yt(e,n,t,this.header.userSignature)}static async retrieve(e,t,r,n){const i=rr(r,t),{registry:a}=await ve.retrieve(e,i);if(!a.data)throw new D(R.InvalidRecordData);const s=this.deserializeUnchecked(a.data),o=s.getContent(),c=Buffer.concat([i.toBuffer(),o]);if(!(null==n?void 0:n.skipGuardianSig)){const e=Ot.has(t)?Buffer.from(s.getContent().slice(32)):Xt(t);s.checkGuardianSignature(c,e)}return(null==n?void 0:n.skipUserSig)||s.checkUserSignature(c,a.owner.toBuffer()),s}static async retrieveBatch(e,t,r){const n=t.map((e=>rr(r,e))),i=await ve.retrieveBatch(e,n),a=[];for(let e of i)try{if(!(null==e?void 0:e.data)){a.push(void 0);continue}const t=$t.deserializeUnchecked(null==e?void 0:e.data);a.push(t)}catch{a.push(void 0)}return a}}const _t=(e,r)=>{if(Gt.has(r)){const t=e.toString("utf-8");return r===We.CNAME||r===We.TXT?k(t):t}if(r===We.SOL)return new t(e).toBase58();if(r===We.ETH||r===We.BSC)return"0x"+e.toString("hex");if(r===We.Injective)return y("inj",e,"bech32");if(r===We.A||r===We.AAAA)return v.fromByteArray([...e]).toString();throw new D(R.InvalidARecord)},er=(e,r)=>{if(Gt.has(r))return r!==We.CNAME&&r!==We.TXT||(e=A(e)),Buffer.from(e,"utf-8");if(r===We.SOL)return new t(e).toBuffer();if(r===We.ETH||r===We.BSC)return ge("0x"===e.slice(0,2),R.InvalidEvmAddress),Buffer.from(e.slice(2),"hex");if(r===We.Injective){const t=m(e);return ge("inj"===t.prefix,R.InvalidInjectiveAddress),ge(20===t.data.length,R.InvalidInjectiveAddress),Buffer.from(t.data)}if(r===We.A){const t=v.parse(e).toByteArray();return ge(4===t.length,R.InvalidARecord),Buffer.from(t)}if(r===We.AAAA){const t=v.parse(e).toByteArray();return ge(16===t.length,R.InvalidAAAARecord),Buffer.from(t)}throw new D(R.InvalidARecord)},tr=(e,t,r)=>{const n=er(e,r),i=rr(t,r),a=Buffer.concat([i.toBuffer(),n]).toString("hex");return Buffer.from(a)},rr=(e,t)=>{const{pubkey:r}=de(t+"."+e,xe.V2);return r},nr=new t("ART5dr4bDic2sQVZoFheEmUxwQq5VGSx9he7JxHcXNQD"),ir=(e,t)=>{const r=ae(t),n=ae(e),i=se(n,void 0,ie);return{domainKey:i,bgKey:se(r,void 0,i)}},ar=e=>{if(e===jt.DegenPoet1)return nr;throw new D(R.InvalidCustomBg)};export{Z as BONFIDA_FIDA_BNB,$ as BONFIDA_USDC_BNB,ie as CUSTOM_BG_TLD,jt as CustomBg,R as ErrorType,Ct as FavouriteDomain,Ut as GuardianSig,Ft as Guardians,O as HASH_PREFIX,Lt as NAME_OFFERS_ID,G as NAME_PROGRAM_ID,ve as NameRegistryState,zt as NullGuardianSig,Mt as NullUserSig,N as Numberu32,W as Numberu64,K as PYTH_FIDA_PRICE_ACC,re as PYTH_MAPPING_ACC,Te as RECORD_V1_SIZE,ee as REFERRERS,X as REGISTER_PROGRAM_ID,q as REVERSE_LOOKUP_CLASS,V as ROOT_DOMAIN_ACCOUNT,We as Record,$t as RecordV2,Qt as RecordV2Header,xe as RecordVersion,Tt as ReverseTwitterRegistryState,Ot as SELF_SIGNED,D as SNSError,Q as SOL_RECORD_SIG_LEN,te as TOKENS_SYM_MINT,Y as TWITTER_ROOT_PARENT_REGISTRY_KEY,J as TWITTER_VERIFICATION_AUTHORITY,_ as USDC_MINT,Gt as UTF8_ENCODED,Ht as UserSig,ne as VAULT_OWNER,kt as changeTwitterRegistryData,Bt as changeVerifiedPubkey,ge as check,Le as checkSolRecord,T as createInstruction,U as createInstructionV3,ct as createNameRegistry,gt as createRecordInstruction,ht as createRecordV2Instruction,j as createReverseInstruction,wt as createReverseName,xt as createReverseTwitterRegistry,bt as createSolRecordInstruction,pt as createSubdomain,P as createV2Instruction,At as createVerifiedTwitterRegistry,C as deleteInstruction,dt as deleteNameRegistry,St as deleteRecordV2,It as deleteTwitterRegistry,at as deserializeRecord,_t as deserializeRecordV2Content,ue as findSubdomains,le as getAllDomains,we as getAllRegisteredDomains,ar as getArtistPubkey,Me as getArweaveRecord,it as getBackgroundRecord,nt as getBackpackRecord,tt as getBscRecord,Fe as getBtcRecord,ir as getCustomBgKeys,Ke as getDiscordRecord,Oe as getDogeRecord,De as getDomainKey,de as getDomainKeySync,Ve as getEmailRecord,ze as getEthRecord,Pt as getFavoriteDomain,Ze as getGithubRecord,Xt as getGuardianPublickey,Dt as getHandleAndRegistryKey,ke as getHashedName,ae as getHashedNameSync,rt as getInjectiveRecord,He as getIpfsRecord,Ge as getLtcRecord,tr as getMessageToSign,Be as getNameAccountKey,se as getNameAccountKeySync,Ae as getNameOwner,Qe as getPicRecord,et as getPointRecord,je as getRecord,Pe as getRecordKeySync,rr as getRecordV2Key,Ue as getRecords,qe as getRedditRecord,Ne as getReverseKey,pe as getReverseKeySync,$e as getShdwRecord,Vt as getSignatureByteLength,_e as getSolRecord,Ye as getTelegramRecord,be as getTokenizedDomains,Nt as getTwitterHandleandRegistryKeyViaFilters,Je as getTwitterRecord,Rt as getTwitterRegistry,Wt as getTwitterRegistryData,Et as getTwitterRegistryKey,Xe as getUrlRecord,Ie as performReverseLookup,Ee as performReverseLookupBatch,lt as registerDomainName,Ce as resolve,he as retrieveNftOwner,me as retrieveNfts,oe as reverseLookup,ce as reverseLookupBatch,st as serializeRecord,er as serializeRecordV2Content,ot as serializeSolRecord,L as transferInstruction,ft as transferNameOwnership,x as updateInstruction,ut as updateNameRegistryData,mt as updateRecordInstruction,yt as updateRecordV2Instruction,vt as updateSolRecordInstruction,Zt as verifyEthereumSignature,Jt as verifyGuardianSignature,qt as verifyInjectiveSignature,Kt as verifySolanaSignature,Yt as verifyUserSignature};
1
+ import{Buffer as e}from"buffer";import{PublicKey as t,TransactionInstruction as r,SystemProgram as n,SYSVAR_RENT_PUBKEY as i}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as a,getMint as s,AccountLayout as o,getAssociatedTokenAddressSync as c,createAssociatedTokenAccountInstruction as u}from"@solana/spl-token";import f from"bn.js";import{serialize as d,deserialize as l,deserializeUnchecked as p}from"borsh";import{sha256 as g}from"@ethersproject/sha2";import{PythHttpClient as w,getPythProgramKeyForCluster as h}from"@pythnetwork/client";import{decode as m,encode as y}from"bech32-buffer";import*as b from"tweetnacl";import S from"bs58";import v from"ipaddr.js";import{encode as A,decode as k}from"punycode";import{hashMessage as B}from"@ethersproject/hash";import{recoverAddress as I}from"@ethersproject/transactions";import{getAddress as E}from"@ethersproject/address";var W;!function(e){e.SymbolNotFound="SymbolNotFound",e.InvalidSubdomain="InvalidSubdomain",e.FavouriteDomainNotFound="FavouriteDomainNotFound",e.MissingParentOwner="MissingParentOwner",e.U32Overflow="U32Overflow",e.InvalidBufferLength="InvalidBufferLength",e.U64Overflow="U64Overflow",e.NoRecordData="NoRecordData",e.InvalidRecordData="InvalidRecordData",e.UnsupportedRecord="UnsupportedRecord",e.InvalidEvmAddress="InvalidEvmAddress",e.InvalidInjectiveAddress="InvalidInjectiveAddress",e.InvalidARecord="InvalidARecord",e.InvalidAAAARecord="InvalidAAAARecord",e.InvalidRecordInput="InvalidRecordInput",e.InvalidSignature="InvalidSignature",e.AccountDoesNotExist="AccountDoesNotExist",e.MultipleRegistries="MultipleRegistries",e.InvalidReverseTwitter="InvalidReverseTwitter",e.NoAccountData="NoAccountData",e.InvalidInput="InvalidInput",e.InvalidDomain="InvalidDomain",e.InvalidCustomBg="InvalidCustomBackground",e.UnsupportedSignature="UnsupportedSignature",e.RecordDoestNotSupportGuardianSig="RecordDoestNotSupportGuardianSig",e.RecordIsNotSigned="RecordIsNotSigned",e.UnsupportedSignatureType="UnsupportedSignatureType"}(W||(W={}));class R extends Error{constructor(e,t){super(t),this.name="SNSError",this.type=e,Error.captureStackTrace&&Error.captureStackTrace(this,R)}}class D extends f{toBuffer(){const t=super.toArray().reverse(),r=e.from(t);if(4===r.length)return r;if(r.length>4)throw new R(W.U32Overflow);const n=e.alloc(4);return r.copy(n),n}static fromBuffer(e){if(4!==e.length)throw new R(W.InvalidBufferLength,`Invalid buffer length: ${e.length}`);return new f([...e].reverse().map((e=>`00${e.toString(16)}`.slice(-2))).join(""),16)}}class N extends f{toBuffer(){const t=super.toArray().reverse(),r=e.from(t);if(8===r.length)return r;if(r.length>8)throw new R(W.U64Overflow);const n=e.alloc(8);return r.copy(n),n}static fromBuffer(e){if(8!==e.length)throw new R(W.U64Overflow,`Invalid buffer length: ${e.length}`);return new f([...e].reverse().map((e=>`00${e.toString(16)}`.slice(-2))).join(""),16)}}function T(n,i,a,s,o,c,u,f,d,l,p){const g=[e.from(Int8Array.from([0])),new D(c.length).toBuffer(),c,u.toBuffer(),f.toBuffer()],w=e.concat(g),h=[{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!0,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1}];return d?h.push({pubkey:d,isSigner:!0,isWritable:!1}):h.push({pubkey:new t(e.alloc(32)),isSigner:!1,isWritable:!1}),l?h.push({pubkey:l,isSigner:!1,isWritable:!1}):h.push({pubkey:new t(e.alloc(32)),isSigner:!1,isWritable:!1}),p&&h.push({pubkey:p,isSigner:!0,isWritable:!1}),new r({keys:h,programId:n,data:w})}function x(t,n,i,a,s){const o=[e.from(Int8Array.from([1])),i.toBuffer(),new D(a.length).toBuffer(),a],c=e.concat(o);return new r({keys:[{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1}],programId:t,data:c})}function L(n,i,a,s,o,c,u){const f=[e.from(Int8Array.from([2])),a.toBuffer()],d=e.concat(f),l=[{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:u||s,isSigner:!0,isWritable:!1}];return o&&l.push({pubkey:o,isSigner:!0,isWritable:!1}),u&&c&&(o||l.push({pubkey:t.default,isSigner:!1,isWritable:!1}),l.push({pubkey:c,isSigner:!1,isWritable:!1})),new r({keys:l,programId:n,data:d})}function P(t,n,i,a){const s=[e.from(Int8Array.from([3]))],o=e.concat(s);return new r({keys:[{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!0,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!0}],programId:t,data:o})}class j{constructor(e){this.tag=9,this.name=e.name,this.space=e.space}serialize(){return d(j.schema,this)}getInstruction(t,i,s,o,c,u,f,d,l,p,g){const w=e.from(this.serialize()),h=[{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:u,isSigner:!1,isWritable:!0},{pubkey:n.programId,isSigner:!1,isWritable:!1},{pubkey:f,isSigner:!1,isWritable:!1},{pubkey:d,isSigner:!0,isWritable:!0},{pubkey:l,isSigner:!1,isWritable:!0},{pubkey:p,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!1},{pubkey:g,isSigner:!1,isWritable:!1}];return new r({keys:h,programId:t,data:w})}}j.schema=new Map([[j,{kind:"struct",fields:[["tag","u8"],["name","string"],["space","u32"]]}]]);class C{constructor(e){this.tag=12,this.name=e.name}serialize(){return d(C.schema,this)}getInstruction(t,n,i,a,s,o,c,u,f,d){const l=e.from(this.serialize());let p=[];return p.push({pubkey:n,isSigner:!1,isWritable:!1}),p.push({pubkey:i,isSigner:!1,isWritable:!1}),p.push({pubkey:a,isSigner:!1,isWritable:!0}),p.push({pubkey:s,isSigner:!1,isWritable:!1}),p.push({pubkey:o,isSigner:!1,isWritable:!1}),p.push({pubkey:c,isSigner:!0,isWritable:!0}),p.push({pubkey:u,isSigner:!1,isWritable:!1}),f&&p.push({pubkey:f,isSigner:!1,isWritable:!0}),d&&p.push({pubkey:d,isSigner:!0,isWritable:!0}),new r({keys:p,programId:t,data:l})}}C.schema=new Map([[C,{kind:"struct",fields:[["tag","u8"],["name","string"]]}]]);class U{constructor(e){this.tag=13,this.name=e.name,this.space=e.space,this.referrerIdxOpt=e.referrerIdxOpt}serialize(){return d(U.schema,this)}getInstruction(t,n,i,a,s,o,c,u,f,d,l,p,g,w,h,m,y){const b=e.from(this.serialize());let S=[];return S.push({pubkey:n,isSigner:!1,isWritable:!1}),S.push({pubkey:i,isSigner:!1,isWritable:!1}),S.push({pubkey:a,isSigner:!1,isWritable:!0}),S.push({pubkey:s,isSigner:!1,isWritable:!0}),S.push({pubkey:o,isSigner:!1,isWritable:!1}),S.push({pubkey:c,isSigner:!1,isWritable:!1}),S.push({pubkey:u,isSigner:!0,isWritable:!0}),S.push({pubkey:f,isSigner:!1,isWritable:!0}),S.push({pubkey:d,isSigner:!1,isWritable:!1}),S.push({pubkey:l,isSigner:!1,isWritable:!1}),S.push({pubkey:p,isSigner:!1,isWritable:!1}),S.push({pubkey:g,isSigner:!1,isWritable:!0}),S.push({pubkey:w,isSigner:!1,isWritable:!1}),S.push({pubkey:h,isSigner:!1,isWritable:!1}),S.push({pubkey:m,isSigner:!1,isWritable:!1}),y&&S.push({pubkey:y,isSigner:!1,isWritable:!0}),new r({keys:S,programId:t,data:b})}}U.schema=new Map([[U,{kind:"struct",fields:[["tag","u8"],["name","string"],["space","u32"],["referrerIdxOpt",{kind:"option",type:"u16"}]]}]]);class z{constructor(e){this.tag=17,this.name=e.name,this.space=e.space}serialize(){return d(z.schema,this)}getInstruction(t,n,i,a,s,o,c,u,f,d,l,p,g,w,h,m,y){const b=e.from(this.serialize());let S=[];return S.push({pubkey:n,isSigner:!1,isWritable:!1}),S.push({pubkey:i,isSigner:!1,isWritable:!1}),S.push({pubkey:a,isSigner:!1,isWritable:!0}),S.push({pubkey:s,isSigner:!1,isWritable:!0}),S.push({pubkey:o,isSigner:!1,isWritable:!1}),S.push({pubkey:c,isSigner:!1,isWritable:!1}),S.push({pubkey:u,isSigner:!0,isWritable:!0}),S.push({pubkey:f,isSigner:!1,isWritable:!0}),S.push({pubkey:d,isSigner:!1,isWritable:!0}),S.push({pubkey:l,isSigner:!1,isWritable:!0}),S.push({pubkey:p,isSigner:!1,isWritable:!0}),S.push({pubkey:g,isSigner:!1,isWritable:!0}),S.push({pubkey:w,isSigner:!1,isWritable:!1}),S.push({pubkey:h,isSigner:!1,isWritable:!1}),S.push({pubkey:m,isSigner:!1,isWritable:!1}),S.push({pubkey:y,isSigner:!1,isWritable:!1}),new r({keys:S,programId:t,data:b})}}z.schema=new Map([[z,{kind:"struct",fields:[["tag","u8"],["name","string"],["space","u32"]]}]]);class H{constructor(){this.tag=16}serialize(){return d(H.schema,this)}getInstruction(t,n,i,a,s,o,c,u,f,d){const l=e.from(this.serialize());let p=[];return p.push({pubkey:n,isSigner:!1,isWritable:!1}),p.push({pubkey:i,isSigner:!1,isWritable:!1}),p.push({pubkey:a,isSigner:!1,isWritable:!0}),p.push({pubkey:s,isSigner:!1,isWritable:!0}),p.push({pubkey:o,isSigner:!1,isWritable:!0}),p.push({pubkey:c,isSigner:!1,isWritable:!0}),p.push({pubkey:u,isSigner:!1,isWritable:!1}),p.push({pubkey:f,isSigner:!0,isWritable:!1}),p.push({pubkey:d,isSigner:!1,isWritable:!0}),new r({keys:p,programId:t,data:l})}}H.schema=new Map([[H,{kind:"struct",fields:[["tag","u8"]]}]]);const M=new t("nftD3vbNkNqfj2Sd3HZwbpw4BxxKWr4AjGb9X38JeZk"),F=e.from("tokenized_name");var G;!function(e){e[e.Uninitialized=0]="Uninitialized",e[e.CentralState=1]="CentralState",e[e.ActiveRecord=2]="ActiveRecord",e[e.InactiveRecord=3]="InactiveRecord"}(G||(G={}));class O{constructor(e){this.tag=e.tag,this.nonce=e.nonce,this.nameAccount=new t(e.nameAccount),this.owner=new t(e.owner),this.nftMint=new t(e.nftMint)}static deserialize(e){return l(this.schema,O,e)}static async retrieve(e,t){const r=await e.getAccountInfo(t);if(!r||!r.data)throw new Error("NFT record not found");return this.deserialize(r.data)}static async findKey(r,n){return await t.findProgramAddress([e.from("nft_record"),r.toBuffer()],n)}}O.schema=new Map([[O,{kind:"struct",fields:[["tag","u8"],["nonce","u8"],["nameAccount",[32]],["owner",[32]],["nftMint",[32]]]}]]);const V=new t("namesLPneVptA9Z5rqUDD9tMTWEJwofgaYwp8cawRkX"),X="SPL Name Service",K=new t("58PwtjSDuFHuUkYjH9BYnnQKHfwo9reZhC2zMJv9JPkx"),q=new t("jCebN34bUfdeUYJT13J1yG16XWQpt5PDx6Mse9GUqhR"),Z=new t("ETp9eKXVv1dWwHSpsXRUuXHmw24PwRkttCGVgpZEY9zF"),J=new t("AUoZ3YAhV3b2rZeEH93UMZHXUZcTramBvb4d9YEVySkc"),Y=new t("33m47vH6Eav6jr5Ry86XjhRft2jRBLDnDgPSHoquXi2Z"),Q=new t("FvPH7PrVrLGKPfqaf3xJodFTjZriqrAXXLTVWEorTFBi"),$=new t("4YcexoW3r78zz16J2aqmukBLRwGq6rAvWzJpkYAXqebv"),_=96,ee=new t("DmSyHDSM9eSLyvoLsPvDr5fRRFZ7Bfr3h3ULvWpgQaq7"),te=new t("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),re=[new t("3ogYncmMM5CmytsGCqKHydmXmKUZ6sGWvizkzqwT7zb1"),new t("DM1jJCkZZEwY5tmWbgvKRxsDFzXCdbfrYCCH1CtwguEs"),new t("ADCp4QXFajHrhy4f43pD6GJFtQLkdBY2mjS9DfCk7tNW"),new t("2XTgjw8yi1E3Etgj4CUyRD7Zk49gynH2U9gA5N2MY4NP"),new t("5oDWj8vr3vbcq9JZTtwXqrkCMZggMsDzNietvbr1BNfe"),new t("8kJqxAbqbPLGLMgB6FhLcnw2SiUEavx2aEGM3WQGhtJF"),new t("HemvJzwxvVpWBjPETpaseAH395WAxb2G73MeUfjVkK1u")],ne=new Map([["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v","USDC"],["Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB","USDT"],["So11111111111111111111111111111111111111112","SOL"],["EchesyfXePKdLtoiZSL8pBe8Myagyy8ZRqsACNCFGnvp","FIDA"],["FeGn77dhg1KXRRFeSwwMiykZnZPw5JXW6naf2aQgZDQf","ETH"],["7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx","GMT"],["AFbX8oGjGpmVFywbVouvhQSRmiW2aR1mohfahi4Y2AdB","GST"],["mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So","MSOL"],["DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263","BONK"],["EPeUFDgHRxs9xxEPVaL6kfGQvCon7jmAWKVUHuux1Tpz","BAT"]]),ie=new t("AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J"),ae=new t("GcWEQ9K78FV7LEHteFVciYApERk5YvQuFDQPk1yYJVXi"),se=new t("BPeXUQDqGbzxeK1LJby6ugvCBuo7kRSEUkjD726mUVsz"),oe=new t("72aLKvXeV4aansAQtxKymeXDevT5ed6sCuz9iN62ugPT"),ce=new t("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),ue=t=>{const r=X+t,n=g(e.from(r,"utf8")).slice(2);return e.from(n,"hex")},fe=(r,n,i)=>{const a=[r];n?a.push(n.toBuffer()):a.push(e.alloc(32)),i?a.push(i.toBuffer()):a.push(e.alloc(32));const[s]=t.findProgramAddressSync(a,V);return s};async function de(e,t){const r=ue(t.toBase58()),n=fe(r,Y),{registry:i}=await Ie.retrieve(e,n);if(!i.data)throw new R(W.NoAccountData);const a=new f(i.data.slice(0,4),"le").toNumber();return i.data.slice(4,4+a).toString()}async function le(e,t){let r=[];for(let e of t){const t=ue(e.toBase58()),n=fe(t,Y);r.push(n)}return(await Ie.retrieveBatch(e,r)).map((e=>{if(void 0===e||void 0===e.data)return;let t=new f(e.data.slice(0,4),"le").toNumber();return e.data.slice(4,4+t).toString()}))}const pe=async(e,t)=>{const r=[{memcmp:{offset:0,bytes:t.toBase58()}},{memcmp:{offset:64,bytes:Y.toBase58()}}],n=await e.getProgramAccounts(V,{filters:r}),i=await de(e,t),a=n.map((e=>{var t;return null===(t=e.account.data.slice(97).toString("utf-8"))||void 0===t?void 0:t.split("\0").join("")})),s=a.map((e=>we(e+"."+i).pubkey)),o=await e.getMultipleAccountsInfo(s);return a.filter(((e,t)=>!!o[t]))},ge=(e,t=K)=>{let r=ue(e);return{pubkey:fe(r,void 0,t),hashed:r}},we=(t,r)=>{t.endsWith(".sol")&&(t=t.slice(0,-4));const n=t.split(".");if(2===n.length){const t=e.from([r||0]).toString().concat(n[0]),{pubkey:i}=ge(n[1]);return{...ge(t,i),isSub:!0,parent:i}}if(3===n.length&&r){const{pubkey:t}=ge(n[2]),{pubkey:r}=ge("\0".concat(n[1]),t),i=e.from([1]).toString();return{...ge(i.concat(n[0]),r),isSub:!0,parent:t,isSubRecord:!0}}if(n.length>=3)throw new R(W.InvalidInput);return{...ge(t,K),isSub:!1,parent:void 0}};async function he(e,t){const r=[{memcmp:{offset:32,bytes:t.toBase58()}},{memcmp:{offset:0,bytes:K.toBase58()}}];return(await e.getProgramAccounts(V,{filters:r})).map((e=>e.pubkey))}const me=async e=>{const t=[{memcmp:{offset:0,bytes:K.toBase58()}}];return await e.getProgramAccounts(V,{dataSlice:{offset:32,length:32},filters:t})},ye=(e,t)=>{const{pubkey:r,parent:n}=we(e),i=ue(r.toBase58());return fe(i,Y,t?n:void 0)},be=(e,t)=>{if(!e)throw new R(t)},Se=async(e,r)=>{try{const[n]=await t.findProgramAddress([F,r.toBuffer()],M);if("0"===(await s(e,n)).supply.toString())return;const i=[{memcmp:{offset:0,bytes:n.toBase58()}},{memcmp:{offset:64,bytes:"2"}},{dataSize:165}],o=await e.getProgramAccounts(a,{filters:i});if(1!=o.length)return;return new t(o[0].account.data.slice(32,64))}catch{return}},ve=async e=>{const r=await e.getProgramAccounts(M,{filters:[{memcmp:{offset:0,bytes:"3"}}]});return r.map((e=>new t(e.account.data.slice(66,98))))},Ae=e=>[{memcmp:{offset:32,bytes:e}},{memcmp:{offset:64,bytes:"2"}}],ke=async(e,t)=>{const r=await(async(e,t)=>{const r=[{memcmp:{offset:0,bytes:"3"}},{memcmp:{offset:66,bytes:t.toBase58()}}];return await e.getProgramAccounts(M,{filters:r})})(e,t.mint);if(1===r.length)return O.deserialize(r[0].account.data)},Be=async(e,t)=>{const r=await(async(e,t)=>{const r=[...Ae(t.toBase58()),{dataSize:165}],n=(await e.getProgramAccounts(a,{filters:r})).map((e=>o.decode(e.account.data))).map((t=>ke(e,t)));return(await Promise.all(n)).filter((e=>void 0!==e))})(e,t);return(await le(e,r.map((e=>e.nameAccount)))).map(((e,t)=>({key:r[t].nameAccount,mint:r[t].nftMint,reverse:e}))).filter((e=>!!e.reverse))};class Ie{constructor(e){this.parentName=new t(e.parentName),this.owner=new t(e.owner),this.class=new t(e.class)}static async retrieve(e,t){var r;const n=await e.getAccountInfo(t);if(!n)throw new R(W.AccountDoesNotExist);let i=p(this.schema,Ie,n.data);i.data=null===(r=n.data)||void 0===r?void 0:r.slice(this.HEADER_LEN);return{registry:i,nftOwner:await Se(e,t)}}static async _retrieveBatch(e,t){const r=await e.getMultipleAccountsInfo(t),n=e=>{if(!e)return;const t=p(this.schema,Ie,e);return t.data=null==e?void 0:e.slice(this.HEADER_LEN),t};return r.map((e=>n(null==e?void 0:e.data)))}static async retrieveBatch(e,t){let r=[];const n=[...t];for(;n.length>0;)r.push(...await this._retrieveBatch(e,n.splice(0,100)));return r}}async function Ee(e,t){if(!await e.getAccountInfo(t))throw new R(W.AccountDoesNotExist);return Ie.retrieve(e,t)}async function We(t){const r=X+t,n=g(e.from(r,"utf8")).slice(2);return e.from(n,"hex")}async function Re(r,n,i){const a=[r];n?a.push(n.toBuffer()):a.push(e.alloc(32)),i?a.push(i.toBuffer()):a.push(e.alloc(32));const[s]=await t.findProgramAddress(a,V);return s}async function De(e,t){const r=await We(t.toBase58()),n=await Re(r,Y),{registry:i}=await Ie.retrieve(e,n);if(!i.data)throw new R(W.NoAccountData);const a=new f(i.data.slice(0,4),"le").toNumber();return i.data.slice(4,4+a).toString()}async function Ne(e,t){let r=[];for(let e of t){const t=await We(e.toBase58()),n=await Re(t,Y);r.push(n)}return(await Ie.retrieveBatch(e,r)).map((e=>{if(void 0===e||void 0===e.data)return;let t=new f(e.data.slice(0,4),"le").toNumber();return e.data.slice(4,4+t).toString()}))}Ie.HEADER_LEN=96,Ie.schema=new Map([[Ie,{kind:"struct",fields:[["parentName",[32]],["owner",[32]],["class",[32]]]}]]);const Te=async(e,t=K)=>{let r=await We(e);return{pubkey:await Re(r,void 0,t),hashed:r}},xe=async(t,r=!1)=>{t.endsWith(".sol")&&(t=t.slice(0,-4));const n=t.split(".");if(2===n.length){const t=e.from([r?1:0]).toString().concat(n[0]),{pubkey:i}=await Te(n[1]);return{...await Te(t,i),isSub:!0,parent:i}}if(3===n.length&&r){const{pubkey:t}=await Te(n[2]),{pubkey:r}=await Te("\0".concat(n[1]),t),i=e.from([1]).toString();return{...await Te(i.concat(n[0]),r),isSub:!0,parent:t,isSubRecord:!0}}if(n.length>=3)throw new R(W.InvalidInput);return{...await Te(t,K),isSub:!1,parent:void 0}},Le=async(e,t)=>{const{pubkey:r,parent:n}=await xe(e),i=await We(r.toBase58());return await Re(i,Y,t?n:void 0)};var Pe;!function(e){e.IPFS="IPFS",e.ARWV="ARWV",e.SOL="SOL",e.ETH="ETH",e.BTC="BTC",e.LTC="LTC",e.DOGE="DOGE",e.Email="email",e.Url="url",e.Discord="discord",e.Github="github",e.Reddit="reddit",e.Twitter="twitter",e.Telegram="telegram",e.Pic="pic",e.SHDW="SHDW",e.POINT="POINT",e.BSC="BSC",e.Injective="INJ",e.Backpack="backpack",e.A="A",e.AAAA="AAAA",e.CNAME="CNAME",e.TXT="TXT",e.Background="background"}(Pe||(Pe={}));const je=new Map([[Pe.SOL,96],[Pe.ETH,20],[Pe.BSC,20],[Pe.Injective,20],[Pe.A,4],[Pe.AAAA,16],[Pe.Background,32]]);var Ce;!function(e){e[e.V1=1]="V1",e[e.V2=2]="V2"}(Ce||(Ce={}));const Ue=(e,t,r)=>b.sign.detached.verify(e,t,r.toBytes()),ze=async(r,n)=>{const{pubkey:i}=we(n),{registry:a,nftOwner:s}=await Ie.retrieve(r,i);if(s)return s;try{const i=He(n,Pe.SOL),s=await nt(r,n);if(!(null==s?void 0:s.data))throw new R(W.NoRecordData);const o=new TextEncoder,c=e.concat([s.data.slice(0,32),i.toBuffer()]),u=o.encode(c.toString("hex"));if(!Ue(u,s.data.slice(32),a.owner))throw new R(W.InvalidSignature);return new t(s.data.slice(0,32))}catch(e){if(e instanceof Error&&"FetchError"===e.name)throw e}return a.owner},He=(e,t)=>{const{pubkey:r}=we(t+"."+e,Ce.V1);return r};async function Me(e,t,r,n){const i=He(t,r);let{registry:a}=await Ie.retrieve(e,i);if(!a.data)throw new R(W.NoRecordData);if(n)return ut(a,r,i);const s=je.get(r);return a.data=a.data.slice(0,s),a}async function Fe(e,t,r,n){const i=r.map((e=>He(t,e))),a=await Ie.retrieveBatch(e,i);return n?a.map(((e,n)=>{if(e)return ut(e,r[n],He(t,r[n]))})):a}const Ge=async(e,t)=>await Me(e,t,Pe.IPFS,!0),Oe=async(e,t)=>await Me(e,t,Pe.ARWV,!0),Ve=async(e,t)=>await Me(e,t,Pe.ETH,!0),Xe=async(e,t)=>await Me(e,t,Pe.BTC,!0),Ke=async(e,t)=>await Me(e,t,Pe.LTC,!0),qe=async(e,t)=>await Me(e,t,Pe.DOGE,!0),Ze=async(e,t)=>await Me(e,t,Pe.Email,!0),Je=async(e,t)=>await Me(e,t,Pe.Url,!0),Ye=async(e,t)=>await Me(e,t,Pe.Discord,!0),Qe=async(e,t)=>await Me(e,t,Pe.Github,!0),$e=async(e,t)=>await Me(e,t,Pe.Reddit,!0),_e=async(e,t)=>await Me(e,t,Pe.Twitter,!0),et=async(e,t)=>await Me(e,t,Pe.Telegram,!0),tt=async(e,t)=>await Me(e,t,Pe.Pic,!0),rt=async(e,t)=>await Me(e,t,Pe.SHDW,!0),nt=async(e,t)=>await Me(e,t,Pe.SOL),it=async(e,t)=>await Me(e,t,Pe.POINT,!0),at=async(e,t)=>await Me(e,t,Pe.BSC,!0),st=async(e,t)=>await Me(e,t,Pe.Injective,!0),ot=async(e,t)=>await Me(e,t,Pe.Backpack,!0),ct=async(e,t)=>await Me(e,t,Pe.Background,!0),ut=(r,n,i)=>{const a=null==r?void 0:r.data;if(!a)return;if(0===a.compare(e.alloc(a.length)))return;const s=je.get(n),o=(e=>{const t=Array.from(e);return t.length-1-t.reverse().findIndex((e=>0!==e))+1})(a);if(!s)return a.slice(0,o).toString("utf-8");if(n===Pe.SOL){const t=new TextEncoder,n=e.concat([a.slice(0,32),i.toBuffer()]),s=t.encode(n.toString("hex"));if(Ue(s,a.slice(32,96),r.owner))return S.encode(a.slice(0,32))}if(s&&o!==s){const t=a.slice(0,o).toString("utf-8");if(n===Pe.Injective){const e=m(t);if("inj"===e.prefix&&20===e.data.length)return t}else if(n===Pe.BSC||n===Pe.ETH){const r=t.slice(0,2),n=t.slice(2);if("0x"===r&&20===e.from(n,"hex").length)return t}else if((n===Pe.A||n===Pe.AAAA)&&v.isValid(t))return t;throw new R(W.InvalidRecordData)}if(n===Pe.ETH||n===Pe.BSC)return"0x"+a.slice(0,s).toString("hex");if(n===Pe.Injective)return y("inj",a.slice(0,s),"bech32");if(n===Pe.A||n===Pe.AAAA)return v.fromByteArray([...a.slice(0,s)]).toString();if(n===Pe.Background)return new t(a.slice(0,s)).toString();throw new R(W.InvalidRecordData)},ft=(r,n)=>{if(!je.get(n))return n!==Pe.CNAME&&n!==Pe.TXT||(r=A(r)),e.from(r,"utf-8");if(n===Pe.SOL)throw new R(W.UnsupportedRecord,"Use `serializeSolRecord` for SOL record");if(n===Pe.ETH||n===Pe.BSC)return be("0x"===r.slice(0,2),W.InvalidEvmAddress),e.from(r.slice(2),"hex");if(n===Pe.Injective){const t=m(r);return be("inj"===t.prefix,W.InvalidInjectiveAddress),be(20===t.data.length,W.InvalidInjectiveAddress),e.from(t.data)}if(n===Pe.A){const t=v.parse(r).toByteArray();return be(4===t.length,W.InvalidARecord),e.from(t)}if(n===Pe.AAAA){const t=v.parse(r).toByteArray();return be(16===t.length,W.InvalidAAAARecord),e.from(t)}if(n===Pe.Background)return new t(r).toBuffer();throw new R(W.InvalidRecordInput)},dt=(t,r,n,i)=>{const a=e.concat([t.toBuffer(),r.toBuffer()]),s=(new TextEncoder).encode(a.toString("hex")),o=Ue(s,i,n);return be(o,W.InvalidSignature),e.concat([t.toBuffer(),i])};async function lt(e,t,r,i,a,s,o,c){const u=await We(t),f=await Re(u,o,c),d=s||await e.getMinimumBalanceForRentExemption(r);let l;if(c){const{registry:t}=await Ee(e,c);l=t.owner}return T(V,n.programId,f,a,i,u,new N(d),new D(r),o,c,l)}async function pt(e,t,r,n,i,a){const s=await We(t),o=await Re(s,i,a);let c;c=i||(await Ie.retrieve(e,o)).registry.owner;return x(V,o,new D(r),n,c)}async function gt(e,t,r,n,i,a){const s=await We(t),o=await Re(s,n,i);let c;c=n||(await Ie.retrieve(e,o)).registry.owner;return L(V,o,r,c,n,i,a)}async function wt(e,t,r,n,i){const a=await We(t),s=await Re(a,n,i);let o;o=n||(await Ie.retrieve(e,s)).registry.owner;return P(V,s,r,o)}const ht=async(e,r,s,o,f,d=te,l)=>{if(r.includes(".")||r.trim().toLowerCase()!==r)throw new R(W.InvalidDomain);const[p]=t.findProgramAddressSync([q.toBuffer()],q),g=ue(r),m=fe(g,void 0,K),y=ue(m.toBase58()),b=fe(y,p),[S]=t.findProgramAddressSync([m.toBuffer()],q),v=re.findIndex((e=>null==l?void 0:l.equals(e)));let A;const k=[];if(-1!==v&&l){A=c(d,l,!0);const t=await e.getAccountInfo(A);if(!(null==t?void 0:t.data)){const e=u(o,A,l,d);k.push(e)}}const B=new w(e,h("mainnet-beta")),I=await B.getData(),E=ne.get(d.toBase58());if(!E)throw new R(W.SymbolNotFound,`No symbol found for mint ${d.toBase58()}`);const D=I.productPrice.get("Crypto."+E+"/USD"),N=I.productFromSymbol.get("Crypto."+E+"/USD"),T=c(d,ae),x=new U({name:r,space:s,referrerIdxOpt:-1!=v?v:null}).getInstruction(q,V,K,m,b,n.programId,p,o,f,ie,D.productAccountKey,new t(N.price_account),T,a,i,S,A);return k.push(x),[[],k]},mt=async(e,r,a,s,o)=>{let[c]=await t.findProgramAddress([q.toBuffer()],q),u=await We(e.toBase58()),f=await Re(u,c,s);return[[],[new C({name:r}).getInstruction(q,V,K,f,n.programId,c,a,i,s,o)]]},yt=async(e,t,r,n=2e3)=>{const i=[],a=t.split(".")[0];if(!a)throw new R(W.InvalidSubdomain);const{parent:s,pubkey:o}=we(t),c=await e.getMinimumBalanceForRentExemption(n+Ie.HEADER_LEN),u=await lt(e,"\0".concat(a),n,r,r,c,void 0,s);i.push(u);const f=ye(t,!0),d=await e.getAccountInfo(f);if(!(null==d?void 0:d.data)){const[,e]=await mt(o,"\0".concat(a),r,s,r);i.push(...e)}return[[],i]},bt=async(e,t,r,i,a,s)=>{be(r!==Pe.SOL,W.UnsupportedRecord);const{pubkey:o,hashed:c,parent:u}=we(`${r}.${t}`,Ce.V1),f=ft(i,r).length,d=await e.getMinimumBalanceForRentExemption(f+Ie.HEADER_LEN);return T(V,n.programId,o,a,s,c,new N(d),new D(f),void 0,u,a)},St=async(e,t,r,i,a,s)=>{const o=i.serialize().length,{pubkey:c,hashed:u,parent:f}=we(`${r}.${t}`,Ce.V2),d=await e.getMinimumBalanceForRentExemption(o+Ie.HEADER_LEN);return T(V,n.programId,c,a,s,u,new N(d),new D(o),void 0,f,a)},vt=async(e,t,r,n,i,a)=>{be(r!==Pe.SOL,W.UnsupportedRecord);const{pubkey:s}=we(`${r}.${t}`,Ce.V1),o=await e.getAccountInfo(s);be(!!(null==o?void 0:o.data),W.AccountDoesNotExist);const c=ft(n,r);if((null==o?void 0:o.data.slice(96).length)!==c.length)return[P(V,s,a,i),await bt(e,t,r,n,i,a)];return[x(V,s,new D(0),c,i)]},At=async(t,r,n,i,a,s)=>{const{pubkey:o}=we(`${n}.${r}`,Ce.V2),c=await t.getAccountInfo(o),u=i.serialize();if(c&&(null==c?void 0:c.data.slice(96).length)!==u.length)return[P(V,o,s,a),await St(t,r,n,i,a,s),x(V,o,new D(0),e.from(u),a)];return[x(V,o,new D(0),e.from(u),a)]},kt=async(e,t,r,n)=>{const{pubkey:i}=we(`${t}.${e}`,Ce.V2);return P(V,i,n,r)},Bt=async(e,t,r,i,a,s)=>{const{pubkey:o,hashed:c,parent:u}=we(`${Pe.SOL}.${t}`,Ce.V1),f=dt(r,o,i,a).length,d=await e.getMinimumBalanceForRentExemption(f+Ie.HEADER_LEN);return[T(V,n.programId,o,i,s,c,new N(d),new D(f),void 0,u,i)]},It=async(e,t,r,n,i,a)=>{const{pubkey:s}=we(`${Pe.SOL}.${t}`,Ce.V1),o=await e.getAccountInfo(s);if(be(!!(null==o?void 0:o.data),W.AccountDoesNotExist),96!==(null==o?void 0:o.data.length))return[P(V,s,a,n),await Bt(e,t,r,n,i,a)];const c=dt(r,s,n,i);return[x(V,s,new D(0),c,n)]},Et=(e,r,i)=>{const{pubkey:a}=we(e),[s]=t.findProgramAddressSync([a.toBuffer()],q),[o]=t.findProgramAddressSync([a.toBuffer(),Uint8Array.from([1,1])],q);return(new H).getInstruction(q,V,n.programId,a,ye(e),o,s,Y,r,i)},Wt=(e,r,s,o,c,u,f,d,l)=>{const[p]=t.findProgramAddressSync([s.toBuffer()],q);return new z({space:r,name:e}).getInstruction(q,V,K,s,o,n.programId,Y,c,u,f,d,l,oe,a,i,p,ce)};async function Rt(e,t,r,i,a){const s=await We(t),o=await Re(s,void 0,$),c=await e.getMinimumBalanceForRentExemption(i+Ie.HEADER_LEN);let u=[T(V,n.programId,o,r,a,s,new N(c),new D(i),void 0,$,Q)];return u=u.concat(await zt(e,t,o,r,a)),u}async function Dt(e,t,r,n){const i=await We(e),a=await Re(i,void 0,$);return[x(V,a,new D(r),n,t)]}async function Nt(e,t,r,n,i){const a=await We(t),s=await Re(a,void 0,$);let o=[L(V,s,n,r,void 0)];const c=await We(r.toString());return await Re(c,Q,void 0),o.push(await wt(e,r.toString(),i,Q,$)),o=o.concat(await zt(e,t,s,n,i)),o}async function Tt(e,t){const r=await We(e),n=await Re(r,void 0,$),i=await We(t.toString()),a=await Re(i,Q,$);return[P(V,n,t,t),P(V,a,t,t)]}async function xt(e){const t=await We(e);return await Re(t,void 0,$)}async function Lt(e,t){const r=await We(t),n=await Re(r,void 0,$),{registry:i}=await Ie.retrieve(e,n);return i}async function Pt(e,r){const n=await We(r.toString()),i=await Re(n,Q,$);let a=await Ut.retrieve(e,i);return[a.twitterHandle,new t(a.twitterRegistryKey)]}async function jt(e,r){const n=[{memcmp:{offset:0,bytes:$.toBase58()}},{memcmp:{offset:32,bytes:r.toBase58()}},{memcmp:{offset:64,bytes:Q.toBase58()}}],i=await e.getProgramAccounts(V,{filters:n});for(const e of i)if(e.account.data.length>Ie.HEADER_LEN+32){let r=e.account.data.slice(Ie.HEADER_LEN),n=p(Ut.schema,Ut,r);return[n.twitterHandle,new t(n.twitterRegistryKey)]}throw new R(W.AccountDoesNotExist)}async function Ct(r,n){const i=[{memcmp:{offset:0,bytes:$.toBase58()}},{memcmp:{offset:32,bytes:n.toBase58()}},{memcmp:{offset:64,bytes:new t(e.alloc(32,0)).toBase58()}}],a=await r.getProgramAccounts(V,{filters:i});if(a.length>1)throw new R(W.MultipleRegistries);return a[0].account.data.slice(Ie.HEADER_LEN)}class Ut{constructor(e){this.twitterRegistryKey=e.twitterRegistryKey,this.twitterHandle=e.twitterHandle}static async retrieve(e,t){let r=await e.getAccountInfo(t,"processed");if(!r)throw new R(W.InvalidReverseTwitter);return p(this.schema,Ut,r.data.slice(Ie.HEADER_LEN))}}async function zt(t,r,i,a,s){const o=await We(a.toString()),c=await Re(o,Q,$);let u=d(Ut.schema,new Ut({twitterRegistryKey:i.toBytes(),twitterHandle:r}));return[T(V,n.programId,c,a,s,o,new N(await t.getMinimumBalanceForRentExemption(u.length+Ie.HEADER_LEN)),new D(u.length),Q,$,Q),x(V,c,new D(0),e.from(u),Q)]}Ut.schema=new Map([[Ut,{kind:"struct",fields:[["twitterRegistryKey",[32]],["twitterHandle","string"]]}]]);const Ht=new t("85iDfUvr3HJyLM2zcq5BXSiDvUWfw6cSE1FfNBo8Ap29");class Mt{constructor(e){this.tag=e.tag,this.nameAccount=new t(e.nameAccount)}static deserialize(e){return l(this.schema,Mt,e)}static async retrieve(e,t){const r=await e.getAccountInfo(t);if(!r||!r.data)throw new R(W.FavouriteDomainNotFound);return this.deserialize(r.data)}static async getKey(r,n){return await t.findProgramAddress([e.from("favourite_domain"),n.toBuffer()],r)}static getKeySync(r,n){return t.findProgramAddressSync([e.from("favourite_domain"),n.toBuffer()],r)}}Mt.schema=new Map([[Mt,{kind:"struct",fields:[["tag","u8"],["nameAccount",[32]]]}]]);const Ft=async(e,r)=>{const[n]=Mt.getKeySync(Ht,new t(r)),i=await Mt.retrieve(e,n),a=await de(e,i.nameAccount);return{domain:i.nameAccount,reverse:a}};var Gt;!function(e){e.DegenPoet1="DegenPoet#1"}(Gt||(Gt={}));const Ot=new t("ART5dr4bDic2sQVZoFheEmUxwQq5VGSx9he7JxHcXNQD"),Vt=(e,t)=>{const r=ue(t),n=ue(e),i=fe(n,void 0,se);return{domainKey:i,bgKey:fe(r,void 0,i)}},Xt=e=>{if(e===Gt.DegenPoet1)return Ot;throw new R(W.InvalidCustomBg)};var Kt,qt;!function(e){e[e.None=0]="None",e[e.Solana=1]="Solana",e[e.Ethereum=2]="Ethereum",e[e.Injective=3]="Injective"}(Kt||(Kt={})),function(e){e[e.None=0]="None",e[e.Solana=1]="Solana"}(qt||(qt={}));const Zt={signatureType:qt.None,signature:Buffer.alloc(0)},Jt={signatureType:Kt.None,signature:Buffer.alloc(0)},Yt=new Map([[Pe.Backpack,new t("ExXjtfdQe8JacoqP9Z535WzQKjF4CzW1TTRKRgpxvya3").toBuffer()]]),Qt=new Set([Pe.IPFS,Pe.ARWV,Pe.LTC,Pe.DOGE,Pe.Email,Pe.Url,Pe.Discord,Pe.Github,Pe.Reddit,Pe.Twitter,Pe.Telegram,Pe.Pic,Pe.SHDW,Pe.POINT,Pe.Backpack,Pe.TXT,Pe.CNAME,Pe.BTC]),$t=new Set([Pe.ETH,Pe.Injective,Pe.SOL]),_t=e=>{switch(e){case Kt.None:return 0;case Kt.Solana:return 64;case Kt.Ethereum:case Kt.Injective:return 65;case qt.None:return 0;case qt.Solana:return 64;default:throw new R(W.UnsupportedSignature,`Unsupported signature type: ${e}`)}},er=e=>{const t=Yt.get(e);if(!t)throw new R(W.RecordDoestNotSupportGuardianSig);return t},tr=(e,t,r)=>b.sign.detached.verify(e,t,r),rr=(e,t,r)=>{const n=B(e);return I(n,t)===E(r)},nr=(e,t,r)=>{throw new Error("TODO")},ir=(e,t,r,n)=>{switch(n){case Kt.Ethereum:case Kt.Injective:return rr(e.toString(),t.toString(),r.toString());case Kt.Solana:return tr(e,t,r);case Kt.None:throw new R(W.RecordIsNotSigned);default:throw new R(W.UnsupportedSignatureType)}},ar=(e,t,r,n)=>{switch(n){case qt.Solana:return tr(e,t,r);case qt.None:throw new R(W.RecordIsNotSigned);default:throw new R(W.UnsupportedSignatureType)}};class sr{constructor(e){this.userSignature=e.userSignature,this.guardianSignature=e.guardianSignature,this.contentLength=e.contentLength}serialize(){return d(sr.schema,this)}static deserialize(e){return l(this.schema,sr,e)}}sr.LEN=8,sr.schema=new Map([[sr,{kind:"struct",fields:[["userSignature","u16"],["guardianSignature","u16"],["contentLength","u32"]]}]]);class or{constructor(e){this.header=e.header,this.buffer=e.buffer}getLength(){return sr.LEN+this.buffer.length}static deserializeUnchecked(e){const t=p(sr.schema,sr,e);return new or({header:t,buffer:Buffer.from(e.slice(sr.LEN))})}serialize(){const e=this.header.serialize();return Buffer.concat([e,this.buffer])}deserializeContent(e){return cr(this.getContent(),e)}getContent(){const e=_t(this.header.guardianSignature)+_t(this.header.userSignature);return Buffer.from(this.buffer.slice(e,e+this.header.contentLength))}static new(e,t,r=Zt,n=Jt){const i=ur(e,t),a=Buffer.concat([r.signature,n.signature,i]),s=new sr({userSignature:r.signatureType,guardianSignature:n.signatureType,contentLength:i.length});return new or({header:s,buffer:a})}checkGuardianSignature(e,t){const r=_t(this.header.guardianSignature),n=_t(this.header.userSignature),i=Buffer.from(this.buffer.slice(n,n+r));return ir(e,i,t,this.header.guardianSignature)}checkUserSignature(e,t){const r=_t(this.header.userSignature),n=Buffer.from(this.buffer.slice(0,r));return ar(e,n,t,this.header.userSignature)}static async retrieve(e,t,r,n){const i=dr(r,t),{registry:a}=await Ie.retrieve(e,i);if(!a.data)throw new R(W.InvalidRecordData);const s=this.deserializeUnchecked(a.data),o=s.getContent(),c=Buffer.concat([i.toBuffer(),o]);if(!(null==n?void 0:n.skipGuardianSig)){const e=$t.has(t)?Buffer.from(s.getContent().slice(32)):er(t);s.checkGuardianSignature(c,e)}return(null==n?void 0:n.skipUserSig)||s.checkUserSignature(c,a.owner.toBuffer()),s}static async retrieveBatch(e,t,r){const n=t.map((e=>dr(r,e))),i=await Ie.retrieveBatch(e,n),a=[];for(let e of i)try{if(!(null==e?void 0:e.data)){a.push(void 0);continue}const t=or.deserializeUnchecked(null==e?void 0:e.data);a.push(t)}catch{a.push(void 0)}return a}}const cr=(e,r)=>{if(Qt.has(r)){const t=e.toString("utf-8");return r===Pe.CNAME||r===Pe.TXT?k(t):t}if(r===Pe.SOL)return new t(e).toBase58();if(r===Pe.ETH||r===Pe.BSC)return"0x"+e.toString("hex");if(r===Pe.Injective)return y("inj",e,"bech32");if(r===Pe.A||r===Pe.AAAA)return v.fromByteArray([...e]).toString();throw new R(W.InvalidARecord)},ur=(e,r)=>{if(Qt.has(r))return r!==Pe.CNAME&&r!==Pe.TXT||(e=A(e)),Buffer.from(e,"utf-8");if(r===Pe.SOL)return new t(e).toBuffer();if(r===Pe.ETH||r===Pe.BSC)return be("0x"===e.slice(0,2),W.InvalidEvmAddress),Buffer.from(e.slice(2),"hex");if(r===Pe.Injective){const t=m(e);return be("inj"===t.prefix,W.InvalidInjectiveAddress),be(20===t.data.length,W.InvalidInjectiveAddress),Buffer.from(t.data)}if(r===Pe.A){const t=v.parse(e).toByteArray();return be(4===t.length,W.InvalidARecord),Buffer.from(t)}if(r===Pe.AAAA){const t=v.parse(e).toByteArray();return be(16===t.length,W.InvalidAAAARecord),Buffer.from(t)}throw new R(W.InvalidARecord)},fr=(e,t,r)=>{const n=ur(e,r),i=dr(t,r),a=Buffer.concat([i.toBuffer(),n]).toString("hex");return Buffer.from(a)},dr=(e,t)=>{const{pubkey:r}=we(t+"."+e,Ce.V2);return r};export{J as BONFIDA_FIDA_BNB,ee as BONFIDA_USDC_BNB,se as CUSTOM_BG_TLD,Gt as CustomBg,W as ErrorType,Mt as FavouriteDomain,Kt as GuardianSig,Yt as Guardians,X as HASH_PREFIX,ce as METAPLEX_ID,Ht as NAME_OFFERS_ID,V as NAME_PROGRAM_ID,Ie as NameRegistryState,Jt as NullGuardianSig,Zt as NullUserSig,D as Numberu32,N as Numberu64,Z as PYTH_FIDA_PRICE_ACC,ie as PYTH_MAPPING_ACC,je as RECORD_V1_SIZE,re as REFERRERS,q as REGISTER_PROGRAM_ID,Y as REVERSE_LOOKUP_CLASS,K as ROOT_DOMAIN_ACCOUNT,Pe as Record,or as RecordV2,sr as RecordV2Header,Ce as RecordVersion,Ut as ReverseTwitterRegistryState,$t as SELF_SIGNED,R as SNSError,_ as SOL_RECORD_SIG_LEN,ne as TOKENS_SYM_MINT,$ as TWITTER_ROOT_PARENT_REGISTRY_KEY,Q as TWITTER_VERIFICATION_AUTHORITY,te as USDC_MINT,Qt as UTF8_ENCODED,qt as UserSig,ae as VAULT_OWNER,oe as WOLVES_COLLECTION_METADATA,Et as burnDomain,H as burnInstruction,Dt as changeTwitterRegistryData,Nt as changeVerifiedPubkey,be as check,Ue as checkSolRecord,T as createInstruction,U as createInstructionV3,lt as createNameRegistry,bt as createRecordInstruction,St as createRecordV2Instruction,C as createReverseInstruction,mt as createReverseName,zt as createReverseTwitterRegistry,Bt as createSolRecordInstruction,yt as createSubdomain,j as createV2Instruction,Rt as createVerifiedTwitterRegistry,z as createWithNftInstruction,P as deleteInstruction,wt as deleteNameRegistry,kt as deleteRecordV2,Tt as deleteTwitterRegistry,ut as deserializeRecord,cr as deserializeRecordV2Content,pe as findSubdomains,he as getAllDomains,me as getAllRegisteredDomains,Xt as getArtistPubkey,Oe as getArweaveRecord,ct as getBackgroundRecord,ot as getBackpackRecord,at as getBscRecord,Xe as getBtcRecord,Vt as getCustomBgKeys,Ye as getDiscordRecord,qe as getDogeRecord,xe as getDomainKey,we as getDomainKeySync,Ze as getEmailRecord,Ve as getEthRecord,Ft as getFavoriteDomain,Qe as getGithubRecord,er as getGuardianPublickey,Pt as getHandleAndRegistryKey,We as getHashedName,ue as getHashedNameSync,st as getInjectiveRecord,Ge as getIpfsRecord,Ke as getLtcRecord,fr as getMessageToSign,Re as getNameAccountKey,fe as getNameAccountKeySync,Ee as getNameOwner,tt as getPicRecord,it as getPointRecord,Me as getRecord,He as getRecordKeySync,dr as getRecordV2Key,Fe as getRecords,$e as getRedditRecord,Le as getReverseKey,ye as getReverseKeySync,rt as getShdwRecord,_t as getSignatureByteLength,nt as getSolRecord,et as getTelegramRecord,Be as getTokenizedDomains,jt as getTwitterHandleandRegistryKeyViaFilters,_e as getTwitterRecord,Lt as getTwitterRegistry,Ct as getTwitterRegistryData,xt as getTwitterRegistryKey,Je as getUrlRecord,De as performReverseLookup,Ne as performReverseLookupBatch,ht as registerDomainName,Wt as registerWithNft,ze as resolve,Se as retrieveNftOwner,ve as retrieveNfts,de as reverseLookup,le as reverseLookupBatch,ft as serializeRecord,ur as serializeRecordV2Content,dt as serializeSolRecord,L as transferInstruction,gt as transferNameOwnership,x as updateInstruction,pt as updateNameRegistryData,vt as updateRecordInstruction,At as updateRecordV2Instruction,It as updateSolRecordInstruction,rr as verifyEthereumSignature,ir as verifyGuardianSignature,nr as verifyInjectiveSignature,tr as verifySolanaSignature,ar as verifyUserSignature};
@@ -48,3 +48,22 @@ export declare class createInstructionV3 {
48
48
  serialize(): Uint8Array;
49
49
  getInstruction(programId: PublicKey, namingServiceProgram: PublicKey, rootDomain: PublicKey, name: PublicKey, reverseLookup: PublicKey, systemProgram: PublicKey, centralState: PublicKey, buyer: PublicKey, buyerTokenSource: PublicKey, pythMappingAcc: PublicKey, pythProductAcc: PublicKey, pythPriceAcc: PublicKey, vault: PublicKey, splTokenProgram: PublicKey, rentSysvar: PublicKey, state: PublicKey, referrerAccountOpt?: PublicKey): TransactionInstruction;
50
50
  }
51
+ export declare class createWithNftInstruction {
52
+ tag: number;
53
+ name: string;
54
+ space: number;
55
+ static schema: Schema;
56
+ constructor(obj: {
57
+ name: string;
58
+ space: number;
59
+ });
60
+ serialize(): Uint8Array;
61
+ getInstruction(programId: PublicKey, namingServiceProgram: PublicKey, rootDomain: PublicKey, name: PublicKey, reverseLookup: PublicKey, systemProgram: PublicKey, centralState: PublicKey, buyer: PublicKey, nftSource: PublicKey, nftMetadata: PublicKey, nftMint: PublicKey, masterEdition: PublicKey, collection: PublicKey, splTokenProgram: PublicKey, rentSysvar: PublicKey, state: PublicKey, mplTokenMetadata: PublicKey): TransactionInstruction;
62
+ }
63
+ export declare class burnInstruction {
64
+ tag: number;
65
+ static schema: Schema;
66
+ constructor();
67
+ serialize(): Uint8Array;
68
+ getInstruction(programId: PublicKey, nameServiceId: PublicKey, systemProgram: PublicKey, domain: PublicKey, reverse: PublicKey, resellingState: PublicKey, state: PublicKey, centralState: PublicKey, owner: PublicKey, target: PublicKey): TransactionInstruction;
69
+ }
package/dist/record.d.ts CHANGED
@@ -3,7 +3,7 @@ import { Connection, PublicKey } from "@solana/web3.js";
3
3
  import { NameRegistryState } from "./state";
4
4
  import { Buffer } from "buffer";
5
5
  /**
6
- * This function can be used to derive a record key (V1)
6
+ * This function can be used to derive a record key
7
7
  * @param domain The .sol domain name
8
8
  * @param record The record to derive the key for
9
9
  * @returns
@@ -14,146 +14,147 @@ export declare function getRecord(connection: Connection, domain: string, record
14
14
  export declare function getRecords(connection: Connection, domain: string, records: Record[], deserialize: true): Promise<string[]>;
15
15
  export declare function getRecords(connection: Connection, domain: string, records: Record[], deserialize?: false): Promise<NameRegistryState[]>;
16
16
  /**
17
- * This function can be used to retrieve the IPFS record (V1) of a domain name
17
+ * This function can be used to retrieve the IPFS record of a domain name
18
18
  * @param connection The Solana RPC connection object
19
19
  * @param domain The .sol domain name
20
20
  * @returns
21
21
  */
22
22
  export declare const getIpfsRecord: (connection: Connection, domain: string) => Promise<string | undefined>;
23
23
  /**
24
- * This function can be used to retrieve the Arweave record (V1) of a domain name
24
+ * This function can be used to retrieve the Arweave record of a domain name
25
25
  * @param connection The Solana RPC connection object
26
26
  * @param domain The .sol domain name
27
27
  * @returns
28
28
  */
29
29
  export declare const getArweaveRecord: (connection: Connection, domain: string) => Promise<string | undefined>;
30
30
  /**
31
- * This function can be used to retrieve the ETH record (V1) of a domain name
31
+ * This function can be used to retrieve the ETH record of a domain name
32
32
  * @param connection The Solana RPC connection object
33
33
  * @param domain The .sol domain name
34
34
  * @returns
35
35
  */
36
36
  export declare const getEthRecord: (connection: Connection, domain: string) => Promise<string | undefined>;
37
37
  /**
38
- * This function can be used to retrieve the BTC record (V1) of a domain name
38
+ * This function can be used to retrieve the BTC record of a domain name
39
39
  * @param connection The Solana RPC connection object
40
40
  * @param domain The .sol domain name
41
41
  * @returns
42
42
  */
43
43
  export declare const getBtcRecord: (connection: Connection, domain: string) => Promise<string | undefined>;
44
44
  /**
45
- * This function can be used to retrieve the LTC record (V1) of a domain name
45
+ * This function can be used to retrieve the LTC record of a domain name
46
46
  * @param connection The Solana RPC connection object
47
47
  * @param domain The .sol domain name
48
48
  * @returns
49
49
  */
50
50
  export declare const getLtcRecord: (connection: Connection, domain: string) => Promise<string | undefined>;
51
51
  /**
52
- * This function can be used to retrieve the DOGE record (V1) of a domain name
52
+ * This function can be used to retrieve the DOGE record of a domain name
53
53
  * @param connection The Solana RPC connection object
54
54
  * @param domain The .sol domain name
55
55
  * @returns
56
56
  */
57
57
  export declare const getDogeRecord: (connection: Connection, domain: string) => Promise<string | undefined>;
58
58
  /**
59
- * This function can be used to retrieve the email record (V1) of a domain name
59
+ * This function can be used to retrieve the email record of a domain name
60
60
  * @param connection The Solana RPC connection object
61
61
  * @param domain The .sol domain name
62
62
  * @returns
63
63
  */
64
64
  export declare const getEmailRecord: (connection: Connection, domain: string) => Promise<string | undefined>;
65
65
  /**
66
- * This function can be used to retrieve the URL record (V1) of a domain name
66
+ * This function can be used to retrieve the URL record of a domain name
67
67
  * @param connection The Solana RPC connection object
68
68
  * @param domain The .sol domain name
69
69
  * @returns
70
70
  */
71
71
  export declare const getUrlRecord: (connection: Connection, domain: string) => Promise<string | undefined>;
72
72
  /**
73
- * This function can be used to retrieve the Discord record (V1) of a domain name
73
+ * This function can be used to retrieve the Discord record of a domain name
74
74
  * @param connection The Solana RPC connection object
75
75
  * @param domain The .sol domain name
76
76
  * @returns
77
77
  */
78
78
  export declare const getDiscordRecord: (connection: Connection, domain: string) => Promise<string | undefined>;
79
79
  /**
80
- * This function can be used to retrieve the Github record (V1) of a domain name
80
+ * This function can be used to retrieve the Github record of a domain name
81
81
  * @param connection The Solana RPC connection object
82
82
  * @param domain The .sol domain name
83
83
  * @returns
84
84
  */
85
85
  export declare const getGithubRecord: (connection: Connection, domain: string) => Promise<string | undefined>;
86
86
  /**
87
- * This function can be used to retrieve the Reddit record (V1) of a domain name
87
+ * This function can be used to retrieve the Reddit record of a domain name
88
88
  * @param connection The Solana RPC connection object
89
89
  * @param domain The .sol domain name
90
90
  * @returns
91
91
  */
92
92
  export declare const getRedditRecord: (connection: Connection, domain: string) => Promise<string | undefined>;
93
93
  /**
94
- * This function can be used to retrieve the Twitter record (V1) of a domain name
94
+ * This function can be used to retrieve the Twitter record of a domain name
95
95
  * @param connection The Solana RPC connection object
96
96
  * @param domain The .sol domain name
97
97
  * @returns
98
98
  */
99
99
  export declare const getTwitterRecord: (connection: Connection, domain: string) => Promise<string | undefined>;
100
100
  /**
101
- * This function can be used to retrieve the Telegram record (V1) of a domain name
101
+ * This function can be used to retrieve the Telegram record of a domain name
102
102
  * @param connection The Solana RPC connection object
103
103
  * @param domain The .sol domain name
104
104
  * @returns
105
105
  */
106
106
  export declare const getTelegramRecord: (connection: Connection, domain: string) => Promise<string | undefined>;
107
107
  /**
108
- * This function can be used to retrieve the pic record (V1) of a domain name
108
+ * This function can be used to retrieve the pic record of a domain name
109
109
  * @param connection The Solana RPC connection object
110
110
  * @param domain The .sol domain name
111
111
  * @returns
112
112
  */
113
113
  export declare const getPicRecord: (connection: Connection, domain: string) => Promise<string | undefined>;
114
114
  /**
115
- * This function can be used to retrieve the SHDW record (V1) of a domain name
115
+ * This function can be used to retrieve the SHDW record of a domain name
116
116
  * @param connection The Solana RPC connection object
117
117
  * @param domain The .sol domain name
118
118
  * @returns
119
119
  */
120
120
  export declare const getShdwRecord: (connection: Connection, domain: string) => Promise<string | undefined>;
121
121
  /**
122
- * This function can be used to retrieve the SOL record (V1) of a domain name
122
+ * This function can be used to retrieve the SOL record of a domain name
123
123
  * @param connection The Solana RPC connection object
124
124
  * @param domain The .sol domain name
125
125
  * @returns
126
126
  */
127
127
  export declare const getSolRecord: (connection: Connection, domain: string) => Promise<NameRegistryState | undefined>;
128
128
  /**
129
- * This function can be used to retrieve the POINT record (V1) of a domain name
129
+ * This function can be used to retrieve the POINT record of a domain name
130
130
  * @param connection The Solana RPC connection object
131
131
  * @param domain The .sol domain name
132
132
  * @returns
133
133
  */
134
134
  export declare const getPointRecord: (connection: Connection, domain: string) => Promise<string | undefined>;
135
135
  /**
136
- * This function can be used to retrieve the BSC record (V1) of a domain name
136
+ * This function can be used to retrieve the BSC record of a domain name
137
137
  * @param connection The Solana RPC connection object
138
138
  * @param domain The .sol domain name
139
139
  * @returns
140
140
  */
141
141
  export declare const getBscRecord: (connection: Connection, domain: string) => Promise<string | undefined>;
142
142
  /**
143
- * This function can be used to retrieve the Injective record (V1) of a domain name
143
+ * This function can be used to retrieve the Injective record of a domain name
144
144
  * @param connection The Solana RPC connection object
145
145
  * @param domain The .sol domain name
146
146
  * @returns
147
147
  */
148
148
  export declare const getInjectiveRecord: (connection: Connection, domain: string) => Promise<string | undefined>;
149
149
  /**
150
- * This function can be used to retrieve the Backpack record (V1) of a domain name
150
+ * This function can be used to retrieve the Backpack record of a domain name
151
151
  * @param connection The Solana RPC connection object
152
152
  * @param domain The .sol domain name
153
153
  * @returns
154
154
  */
155
155
  export declare const getBackpackRecord: (connection: Connection, domain: string) => Promise<string | undefined>;
156
156
  /**
157
+
157
158
  * This function can be used to deserialize the content of a record. If the content is invalid it will throw an error
158
159
  * This function can be used to retrieve the Background record (V1) of a domain name
159
160
  * @param connection The Solana RPC connection object
@@ -178,7 +179,7 @@ export declare const deserializeRecord: (registry: NameRegistryState | undefined
178
179
  */
179
180
  export declare const serializeRecord: (str: string, record: Record) => Buffer;
180
181
  /**
181
- * This function can be used to build the content of a SOL record (V1)
182
+ * This function can be used to build the content of a SOL record
182
183
  * @param content The public key being stored in the SOL record
183
184
  * @param recordKey The record public key
184
185
  * @param signer The signer of the record i.e the domain owner
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonfida/spl-name-service",
3
- "version": "2.0.0-alpha.10",
3
+ "version": "2.0.0-alpha.13",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"
@@ -33,6 +33,7 @@
33
33
  "doc": "yarn typedoc src/index.ts"
34
34
  },
35
35
  "devDependencies": {
36
+ "@metaplex-foundation/js": "^0.19.5",
36
37
  "@rollup/plugin-commonjs": "^24.1.0",
37
38
  "@rollup/plugin-json": "^6.0.0",
38
39
  "@rollup/plugin-typescript": "^11.1.0",