{"version":3,"file":"registerPrimaryInstruction.cjs","sources":["../../../src/instructions/registerPrimaryInstruction.ts"],"sourcesContent":["import { AccountMeta, AccountRole, Address, Instruction } from \"@solana/kit\";\r\nimport { serialize } from \"borsh\";\r\n\r\n/** Builder for registering an address's SNS primary domain. */\r\nexport class RegisterPrimaryInstruction {\r\n  /** Instruction discriminator. */\r\n  tag: number;\r\n  static schema = {\r\n    struct: {\r\n      tag: \"u8\",\r\n    },\r\n  };\r\n\r\n  constructor() {\r\n    this.tag = 6;\r\n  }\r\n\r\n  serialize(): Uint8Array {\r\n    return serialize(RegisterPrimaryInstruction.schema, this);\r\n  }\r\n\r\n  getInstruction(\r\n    programAddress: Address,\r\n    nameAccount: Address,\r\n    primaryAccount: Address,\r\n    owner: Address,\r\n    systemProgram: Address,\r\n    optParent?: Address\r\n  ): Instruction {\r\n    const data = this.serialize();\r\n    const accounts: AccountMeta[] = [\r\n      {\r\n        address: nameAccount,\r\n        role: AccountRole.READONLY,\r\n      },\r\n      {\r\n        address: primaryAccount,\r\n        role: AccountRole.WRITABLE,\r\n      },\r\n      {\r\n        address: owner,\r\n        role: AccountRole.WRITABLE_SIGNER,\r\n      },\r\n      {\r\n        address: systemProgram,\r\n        role: AccountRole.READONLY,\r\n      },\r\n    ];\r\n\r\n    if (optParent) {\r\n      accounts.push({\r\n        address: optParent,\r\n        role: AccountRole.READONLY,\r\n      });\r\n    }\r\n\r\n    return {\r\n      programAddress,\r\n      accounts,\r\n      data,\r\n    };\r\n  }\r\n}\r\n"],"names":["serialize","AccountRole"],"mappings":";;;;;;;AAGA;MACa,0BAA0B,CAAA;;AAErC,IAAA,GAAG;IACH,OAAO,MAAM,GAAG;AACd,QAAA,MAAM,EAAE;AACN,YAAA,GAAG,EAAE,IAAI;AACV,SAAA;KACF;AAED,IAAA,WAAA,GAAA;AACE,QAAA,IAAI,CAAC,GAAG,GAAG,CAAC;;IAGd,SAAS,GAAA;QACP,OAAOA,eAAS,CAAC,0BAA0B,CAAC,MAAM,EAAE,IAAI,CAAC;;IAG3D,cAAc,CACZ,cAAuB,EACvB,WAAoB,EACpB,cAAuB,EACvB,KAAc,EACd,aAAsB,EACtB,SAAmB,EAAA;AAEnB,QAAA,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE;AAC7B,QAAA,MAAM,QAAQ,GAAkB;AAC9B,YAAA;AACE,gBAAA,OAAO,EAAE,WAAW;gBACpB,IAAI,EAAEC,eAAW,CAAC,QAAQ;AAC3B,aAAA;AACD,YAAA;AACE,gBAAA,OAAO,EAAE,cAAc;gBACvB,IAAI,EAAEA,eAAW,CAAC,QAAQ;AAC3B,aAAA;AACD,YAAA;AACE,gBAAA,OAAO,EAAE,KAAK;gBACd,IAAI,EAAEA,eAAW,CAAC,eAAe;AAClC,aAAA;AACD,YAAA;AACE,gBAAA,OAAO,EAAE,aAAa;gBACtB,IAAI,EAAEA,eAAW,CAAC,QAAQ;AAC3B,aAAA;SACF;QAED,IAAI,SAAS,EAAE;YACb,QAAQ,CAAC,IAAI,CAAC;AACZ,gBAAA,OAAO,EAAE,SAAS;gBAClB,IAAI,EAAEA,eAAW,CAAC,QAAQ;AAC3B,aAAA,CAAC;;QAGJ,OAAO;YACL,cAAc;YACd,QAAQ;YACR,IAAI;SACL;;;;;;"}