{"version":3,"file":"transferInstruction.cjs","sources":["../../../src/instructions/transferInstruction.ts"],"sourcesContent":["import {\r\n  AccountRole,\r\n  Address,\r\n  IAccountMeta,\r\n  IInstruction,\r\n  ReadonlyUint8Array,\r\n} from \"@solana/kit\";\r\nimport { serialize } from \"borsh\";\r\n\r\nimport { addressCodec } from \"../codecs\";\r\nimport { DEFAULT_ADDRESS } from \"../constants/addresses\";\r\n\r\nexport class TransferInstruction {\r\n  tag: number;\r\n  encodedNewOwnerAddress: ReadonlyUint8Array;\r\n\r\n  static schema = {\r\n    struct: {\r\n      tag: \"u8\",\r\n      encodedNewOwnerAddress: { array: { type: \"u8\", len: 32 } },\r\n    },\r\n  };\r\n\r\n  constructor(obj: { newOwner: Address }) {\r\n    this.tag = 2;\r\n    this.encodedNewOwnerAddress = addressCodec.encode(obj.newOwner);\r\n  }\r\n\r\n  serialize(): Uint8Array {\r\n    return serialize(TransferInstruction.schema, this);\r\n  }\r\n\r\n  getInstruction(\r\n    programAddress: Address,\r\n    domainAddress: Address,\r\n    currentOwner: Address,\r\n    classAddress?: Address,\r\n    parentAddress?: Address,\r\n    parentOwner?: Address\r\n  ): IInstruction {\r\n    const data = this.serialize();\r\n\r\n    const accounts: IAccountMeta[] = [\r\n      {\r\n        address: domainAddress,\r\n        role: AccountRole.WRITABLE,\r\n      },\r\n      {\r\n        address: parentOwner ? parentOwner : currentOwner,\r\n        role: AccountRole.READONLY_SIGNER,\r\n      },\r\n    ];\r\n\r\n    if (classAddress) {\r\n      accounts.push({\r\n        address: classAddress,\r\n        role: AccountRole.READONLY_SIGNER,\r\n      });\r\n    }\r\n\r\n    if (parentOwner && parentAddress) {\r\n      if (!classAddress) {\r\n        accounts.push({\r\n          address: DEFAULT_ADDRESS,\r\n          role: AccountRole.READONLY,\r\n        });\r\n      }\r\n\r\n      accounts.push({\r\n        address: parentAddress,\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":["TransferInstruction","tag","encodedNewOwnerAddress","static","struct","array","type","len","constructor","obj","this","addressCodec","encode","newOwner","serialize","schema","getInstruction","programAddress","domainAddress","currentOwner","classAddress","parentAddress","parentOwner","data","accounts","address","role","AccountRole","WRITABLE","READONLY_SIGNER","push","DEFAULT_ADDRESS","READONLY"],"mappings":"wKAYaA,EACXC,IACAC,uBAEAC,cAAgB,CACdC,OAAQ,CACNH,IAAK,KACLC,uBAAwB,CAAEG,MAAO,CAAEC,KAAM,KAAMC,IAAK,OAIxD,WAAAC,CAAYC,GACVC,KAAKT,IAAM,EACXS,KAAKR,uBAAyBS,EAAAA,aAAaC,OAAOH,EAAII,UAGxD,SAAAC,GACE,OAAOA,YAAUd,EAAoBe,OAAQL,MAG/C,cAAAM,CACEC,EACAC,EACAC,EACAC,EACAC,EACAC,GAEA,MAAMC,EAAOb,KAAKI,YAEZU,EAA2B,CAC/B,CACEC,QAASP,EACTQ,KAAMC,EAAWA,YAACC,UAEpB,CACEH,QAASH,GAA4BH,EACrCO,KAAMC,EAAWA,YAACE,kBAyBtB,OArBIT,GACFI,EAASM,KAAK,CACZL,QAASL,EACTM,KAAMC,EAAWA,YAACE,kBAIlBP,GAAeD,IACZD,GACHI,EAASM,KAAK,CACZL,QAASM,EAAeA,gBACxBL,KAAMC,EAAWA,YAACK,WAItBR,EAASM,KAAK,CACZL,QAASJ,EACTK,KAAMC,EAAWA,YAACK,YAIf,CACLf,iBACAO,WACAD"}