{"version":3,"file":"allocateAndPostRecordInstruction.cjs","sources":["../../../src/instructions/allocateAndPostRecordInstruction.ts"],"sourcesContent":["import {\r\n  AccountMeta,\r\n  AccountRole,\r\n  Address,\r\n  Instruction,\r\n  ReadonlyUint8Array,\r\n} from \"@solana/kit\";\r\nimport { serialize } from \"borsh\";\r\n\r\n/**\r\n * Input for allocating and writing an SNS V2 record.\r\n *\r\n * @example\r\n * ```ts\r\n * const params: AllocateAndPostRecordInstructionParams = { record, content };\r\n * ```\r\n */\r\nexport interface AllocateAndPostRecordInstructionParams {\r\n  /** Encoded V2 record label. */\r\n  record: string;\r\n  /** Serialized record content. */\r\n  content: ReadonlyUint8Array;\r\n}\r\n\r\n/** Builder for allocating and writing an SNS V2 record account. */\r\nexport class AllocateAndPostRecordInstruction {\r\n  /** Instruction discriminator. */\r\n  tag: number;\r\n  /** Encoded V2 record label. */\r\n  record: string;\r\n  /** Serialized record content. */\r\n  content: ReadonlyUint8Array;\r\n\r\n  static schema = {\r\n    struct: {\r\n      tag: \"u8\",\r\n      record: \"string\",\r\n      content: { array: { type: \"u8\" } },\r\n    },\r\n  };\r\n\r\n  constructor(obj: AllocateAndPostRecordInstructionParams) {\r\n    this.tag = 1;\r\n    this.record = obj.record;\r\n    this.content = obj.content;\r\n  }\r\n\r\n  serialize(): Uint8Array {\r\n    return serialize(AllocateAndPostRecordInstruction.schema, this);\r\n  }\r\n\r\n  getInstruction(\r\n    programAddress: Address,\r\n    systemProgram: Address,\r\n    splNameServiceProgram: Address,\r\n    payer: Address,\r\n    record: Address,\r\n    domainAddress: Address,\r\n    domainOwner: Address,\r\n    centralState: Address\r\n  ): Instruction {\r\n    const data = this.serialize();\r\n\r\n    const accounts: AccountMeta[] = [\r\n      {\r\n        address: systemProgram,\r\n        role: AccountRole.READONLY,\r\n      },\r\n      {\r\n        address: splNameServiceProgram,\r\n        role: AccountRole.READONLY,\r\n      },\r\n      {\r\n        address: payer,\r\n        role: AccountRole.WRITABLE_SIGNER,\r\n      },\r\n      {\r\n        address: record,\r\n        role: AccountRole.WRITABLE,\r\n      },\r\n      {\r\n        address: domainAddress,\r\n        role: AccountRole.WRITABLE,\r\n      },\r\n      {\r\n        address: domainOwner,\r\n        role: AccountRole.WRITABLE_SIGNER,\r\n      },\r\n      {\r\n        address: centralState,\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":";;;;;;;AAwBA;MACa,gCAAgC,CAAA;;AAE3C,IAAA,GAAG;;AAEH,IAAA,MAAM;;AAEN,IAAA,OAAO;IAEP,OAAO,MAAM,GAAG;AACd,QAAA,MAAM,EAAE;AACN,YAAA,GAAG,EAAE,IAAI;AACT,YAAA,MAAM,EAAE,QAAQ;YAChB,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;AACnC,SAAA;KACF;AAED,IAAA,WAAA,CAAY,GAA2C,EAAA;AACrD,QAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,QAAA,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM;AACxB,QAAA,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO;;IAG5B,SAAS,GAAA;QACP,OAAOA,eAAS,CAAC,gCAAgC,CAAC,MAAM,EAAE,IAAI,CAAC;;AAGjE,IAAA,cAAc,CACZ,cAAuB,EACvB,aAAsB,EACtB,qBAA8B,EAC9B,KAAc,EACd,MAAe,EACf,aAAsB,EACtB,WAAoB,EACpB,YAAqB,EAAA;AAErB,QAAA,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE;AAE7B,QAAA,MAAM,QAAQ,GAAkB;AAC9B,YAAA;AACE,gBAAA,OAAO,EAAE,aAAa;gBACtB,IAAI,EAAEC,eAAW,CAAC,QAAQ;AAC3B,aAAA;AACD,YAAA;AACE,gBAAA,OAAO,EAAE,qBA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