{"version":3,"file":"reallocInstruction.mjs","sources":["../../../src/instructions/reallocInstruction.ts"],"sourcesContent":["import { AccountMeta, AccountRole, Address, Instruction } from \"@solana/kit\";\r\nimport { serialize } from \"borsh\";\r\n\r\n/**\r\n * Input for reallocating an SNS name-registry account.\r\n *\r\n * @example\r\n * ```ts\r\n * const params: ReallocInstructionParams = { space: 1_000 };\r\n * ```\r\n */\r\nexport interface ReallocInstructionParams {\r\n  /** New account data size in bytes. */\r\n  space: number;\r\n}\r\n\r\n/** Builder for reallocating an SNS name-registry account. */\r\nexport class ReallocInstruction {\r\n  /** Instruction discriminator. */\r\n  tag: number;\r\n  /** New account data size in bytes. */\r\n  space: number;\r\n\r\n  static schema = {\r\n    struct: {\r\n      tag: \"u8\",\r\n      space: \"u32\",\r\n    },\r\n  };\r\n\r\n  constructor(obj: ReallocInstructionParams) {\r\n    this.tag = 4;\r\n    this.space = obj.space;\r\n  }\r\n\r\n  serialize(): Uint8Array {\r\n    return serialize(ReallocInstruction.schema, this);\r\n  }\r\n\r\n  getInstruction(\r\n    programAddress: Address,\r\n    systemProgramId: Address,\r\n    payerKey: Address,\r\n    nameAccountKey: Address,\r\n    nameOwnerKey: Address\r\n  ): Instruction {\r\n    const data = this.serialize();\r\n\r\n    const accounts: AccountMeta[] = [\r\n      {\r\n        address: systemProgramId,\r\n        role: AccountRole.READONLY,\r\n      },\r\n      {\r\n        address: payerKey,\r\n        role: AccountRole.WRITABLE_SIGNER,\r\n      },\r\n      {\r\n        address: nameAccountKey,\r\n        role: AccountRole.WRITABLE,\r\n      },\r\n      {\r\n        address: nameOwnerKey,\r\n        role: AccountRole.READONLY_SIGNER,\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":[],"mappings":";;;AAgBA;MACa,kBAAkB,CAAA;;AAE7B,IAAA,GAAG;;AAEH,IAAA,KAAK;IAEL,OAAO,MAAM,GAAG;AACd,QAAA,MAAM,EAAE;AACN,YAAA,GAAG,EAAE,IAAI;AACT,YAAA,KAAK,EAAE,KAAK;AACb,SAAA;KACF;AAED,IAAA,WAAA,CAAY,GAA6B,EAAA;AACvC,QAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,QAAA,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK;;IAGxB,SAAS,GAAA;QACP,OAAO,SAAS,CAAC,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC;;IAGnD,cAAc,CACZ,cAAuB,EACvB,eAAwB,EACxB,QAAiB,EACjB,cAAuB,EACvB,YAAqB,EAAA;AAErB,QAAA,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE;AAE7B,QAAA,MAAM,QAAQ,GAAkB;AAC9B,YAAA;AACE,gBAAA,OAAO,EAAE,eAAe;gBACxB,IAAI,EAAE,WAAW,CAAC,QAAQ;AAC3B,aAAA;AACD,YAAA;AACE,gBAAA,OAAO,EAAE,QAAQ;gBACjB,IAAI,EAAE,WAAW,CAAC,eAAe;AAClC,aAAA;AACD,YAAA;AACE,gBAAA,OAAO,EAAE,cAAc;gBACvB,IAAI,EAAE,WAAW,CAAC,QAAQ;AAC3B,aAAA;AACD,YAAA;AACE,gBAAA,OAAO,EAAE,YAAY;gBACrB,IAAI,EAAE,WAAW,CAAC,eAAe;AAClC,aAAA;SACF;QAED,OAAO;YACL,cAAc;YACd,QAAQ;YACR,IAAI;SACL;;;;;;"}