@solana-program/token-wrap 0.0.0 → 2.0.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/generated/pdas/backpointer.ts","../../src/generated/pdas/wrappedMint.ts","../../src/generated/pdas/wrappedMintAuthority.ts","../../src/generated/accounts/backpointer.ts","../../src/generated/programs/tokenWrap.ts","../../src/generated/errors/tokenWrap.ts","../../src/generated/shared/index.ts","../../src/generated/instructions/createMint.ts","../../src/generated/instructions/unwrap.ts","../../src/generated/instructions/wrap.ts","../../src/create-mint.ts","../../src/utilities.ts","../../src/wrap.ts","../../src/unwrap.ts"],"names":["getProgramDerivedAddress","getUtf8Encoder","getAddressEncoder","getStructEncoder","getStructDecoder","getAddressDecoder","combineCodec","decodeAccount","assertAccountExists","fetchEncodedAccount","assertAccountsExist","fetchEncodedAccounts","TokenWrapAccount","TokenWrapInstruction","containsBytes","getU8Encoder","isProgramError","AccountRole","upgradeRoleToSigner","kitIsTransactionSigner","transformEncoder","getBooleanEncoder","getU8Decoder","getBooleanDecoder","getU64Encoder","getU64Decoder","getMintSize","getTransferSolInstruction","findAssociatedTokenPda","fetchMaybeToken","getCreateAssociatedTokenInstruction","getTokenDecoder","assertTransactionIsFullySigned","pipe","createTransactionMessage","setTransactionMessageFeePayerSigner","setTransactionMessageLifetimeUsingBlockhash","appendTransactionMessageInstructions"],"mappings":";;;;;;;;AAoBA,eAAsB,kBACpB,CAAA,KAAA,EACA,MAAmD,GAAA,EACnB,EAAA;AAChC,EAAM,MAAA;AAAA,IACJ,cAAiB,GAAA;AAAA,GACf,GAAA,MAAA;AACJ,EAAA,OAAO,MAAMA,4BAAyB,CAAA;AAAA,IACpC,cAAA;AAAA,IACA,KAAO,EAAA;AAAA,MACLC,kBAAA,EAAiB,CAAA,MAAA,CAAO,aAAa,CAAA;AAAA,MACrCC,qBAAkB,EAAA,CAAE,MAAO,CAAA,KAAA,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,GAAI,MAAM,kBAAmB,CAAA;AAAA,IAC3B,GAAA;AAAA,IACA,KAAA;AAAA,IACA,mBAAA;AAAA,IACA,uBAAA;AAAA,IACA,kBAAA;AAAA,IACA,sBAAA;AAAA,IACA,wBAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAM,MAAA,EAAA,GAAK,MAAM,sBAAuB,CAAA;AAAA,IACtC,uBAAA;AAAA,IACA,oBAAA;AAAA,IACA,aAAA;AAAA,IACA,mBAAA;AAAA,IACA,qBAAA;AAAA,IACA,mBAAA;AAAA,IACA,WAAA;AAAA,IACA,iBAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAO,OAAA;AAAA,IACL,uBAAA;AAAA,IACA,MAAA,EAAQ,OAAO,MAAM,CAAA;AAAA,IACrB,GAAA,EAAK,CAAC,EAAE;AAAA,GACV;AACF;AAYA,eAAsB,0BACpB,IACiF,EAAA;AACjF,EAAM,MAAA,QAAA,GAAW,MAAM,sBAAA,CAAuB,IAAI,CAAA;AAElD,EAAOK,OAAAA,QAAAA;AAAA,IACLC,4BAAyB,CAAA,EAAE,OAAS,EAAA,CAAA,EAAG,CAAA;AAAA,IACvC,CAAMC,EAAAA,KAAAA,uCAAAA,CAAoC,IAAK,CAAA,KAAA,EAAO,EAAE,CAAA;AAAA,IACxD,CAAMC,EAAAA,KAAAA,+CAAAA,CAA4C,IAAK,CAAA,SAAA,EAAW,EAAE,CAAA;AAAA,IACpE,CAAMC,EAAAA,KAAAA,wCAAAA,CAAqC,CAAC,QAAQ,GAAG,EAAE;AAAA,GAC3D;AACF","file":"index.js","sourcesContent":["/**\n * This code was AUTOGENERATED using the codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n getAddressEncoder,\n getProgramDerivedAddress,\n getUtf8Encoder,\n type Address,\n type ProgramDerivedAddress,\n} from '@solana/kit';\n\nexport type BackpointerSeeds = {\n wrappedMint: Address;\n};\n\nexport async function findBackpointerPda(\n seeds: BackpointerSeeds,\n config: { programAddress?: Address | undefined } = {}\n): Promise<ProgramDerivedAddress> {\n const {\n programAddress = 'TwRapQCDhWkZRrDaHfZGuHxkZ91gHDRkyuzNqeU5MgR' as Address<'TwRapQCDhWkZRrDaHfZGuHxkZ91gHDRkyuzNqeU5MgR'>,\n } = config;\n return await getProgramDerivedAddress({\n programAddress,\n seeds: [\n getUtf8Encoder().encode('backpointer'),\n getAddressEncoder().encode(seeds.wrappedMint),\n ],\n });\n}\n","/**\n * This code was AUTOGENERATED using the codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n getAddressEncoder,\n getProgramDerivedAddress,\n getUtf8Encoder,\n type Address,\n type ProgramDerivedAddress,\n} from '@solana/kit';\n\nexport type WrappedMintSeeds = {\n unwrappedMint: Address;\n\n wrappedTokenProgram: Address;\n};\n\nexport async function findWrappedMintPda(\n seeds: WrappedMintSeeds,\n config: { programAddress?: Address | undefined } = {}\n): Promise<ProgramDerivedAddress> {\n const {\n programAddress = 'TwRapQCDhWkZRrDaHfZGuHxkZ91gHDRkyuzNqeU5MgR' as Address<'TwRapQCDhWkZRrDaHfZGuHxkZ91gHDRkyuzNqeU5MgR'>,\n } = config;\n return await getProgramDerivedAddress({\n programAddress,\n seeds: [\n getUtf8Encoder().encode('mint'),\n getAddressEncoder().encode(seeds.unwrappedMint),\n getAddressEncoder().encode(seeds.wrappedTokenProgram),\n ],\n });\n}\n","/**\n * This code was AUTOGENERATED using the codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n getAddressEncoder,\n getProgramDerivedAddress,\n getUtf8Encoder,\n type Address,\n type ProgramDerivedAddress,\n} from '@solana/kit';\n\nexport type WrappedMintAuthoritySeeds = {\n wrappedMint: Address;\n};\n\nexport async function findWrappedMintAuthorityPda(\n seeds: WrappedMintAuthoritySeeds,\n config: { programAddress?: Address | undefined } = {}\n): Promise<ProgramDerivedAddress> {\n const {\n programAddress = 'TwRapQCDhWkZRrDaHfZGuHxkZ91gHDRkyuzNqeU5MgR' as Address<'TwRapQCDhWkZRrDaHfZGuHxkZ91gHDRkyuzNqeU5MgR'>,\n } = config;\n return await getProgramDerivedAddress({\n programAddress,\n seeds: [\n getUtf8Encoder().encode('authority'),\n getAddressEncoder().encode(seeds.wrappedMint),\n ],\n });\n}\n","/**\n * This code was AUTOGENERATED using the codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n assertAccountExists,\n assertAccountsExist,\n combineCodec,\n decodeAccount,\n fetchEncodedAccount,\n fetchEncodedAccounts,\n getAddressDecoder,\n getAddressEncoder,\n getStructDecoder,\n getStructEncoder,\n type Account,\n type Address,\n type Codec,\n type Decoder,\n type EncodedAccount,\n type Encoder,\n type FetchAccountConfig,\n type FetchAccountsConfig,\n type MaybeAccount,\n type MaybeEncodedAccount,\n} from '@solana/kit';\nimport { BackpointerSeeds, findBackpointerPda } from '../pdas';\n\nexport type Backpointer = { unwrappedMint: Address };\n\nexport type BackpointerArgs = Backpointer;\n\nexport function getBackpointerEncoder(): Encoder<BackpointerArgs> {\n return getStructEncoder([['unwrappedMint', getAddressEncoder()]]);\n}\n\nexport function getBackpointerDecoder(): Decoder<Backpointer> {\n return getStructDecoder([['unwrappedMint', getAddressDecoder()]]);\n}\n\nexport function getBackpointerCodec(): Codec<BackpointerArgs, Backpointer> {\n return combineCodec(getBackpointerEncoder(), getBackpointerDecoder());\n}\n\nexport function decodeBackpointer<TAddress extends string = string>(\n encodedAccount: EncodedAccount<TAddress>\n): Account<Backpointer, TAddress>;\nexport function decodeBackpointer<TAddress extends string = string>(\n encodedAccount: MaybeEncodedAccount<TAddress>\n): MaybeAccount<Backpointer, TAddress>;\nexport function decodeBackpointer<TAddress extends string = string>(\n encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>\n): Account<Backpointer, TAddress> | MaybeAccount<Backpointer, TAddress> {\n return decodeAccount(\n encodedAccount as MaybeEncodedAccount<TAddress>,\n getBackpointerDecoder()\n );\n}\n\nexport async function fetchBackpointer<TAddress extends string = string>(\n rpc: Parameters<typeof fetchEncodedAccount>[0],\n address: Address<TAddress>,\n config?: FetchAccountConfig\n): Promise<Account<Backpointer, TAddress>> {\n const maybeAccount = await fetchMaybeBackpointer(rpc, address, config);\n assertAccountExists(maybeAccount);\n return maybeAccount;\n}\n\nexport async function fetchMaybeBackpointer<TAddress extends string = string>(\n rpc: Parameters<typeof fetchEncodedAccount>[0],\n address: Address<TAddress>,\n config?: FetchAccountConfig\n): Promise<MaybeAccount<Backpointer, TAddress>> {\n const maybeAccount = await fetchEncodedAccount(rpc, address, config);\n return decodeBackpointer(maybeAccount);\n}\n\nexport async function fetchAllBackpointer(\n rpc: Parameters<typeof fetchEncodedAccounts>[0],\n addresses: Array<Address>,\n config?: FetchAccountsConfig\n): Promise<Account<Backpointer>[]> {\n const maybeAccounts = await fetchAllMaybeBackpointer(rpc, addresses, config);\n assertAccountsExist(maybeAccounts);\n return maybeAccounts;\n}\n\nexport async function fetchAllMaybeBackpointer(\n rpc: Parameters<typeof fetchEncodedAccounts>[0],\n addresses: Array<Address>,\n config?: FetchAccountsConfig\n): Promise<MaybeAccount<Backpointer>[]> {\n const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);\n return maybeAccounts.map((maybeAccount) => decodeBackpointer(maybeAccount));\n}\n\nexport function getBackpointerSize(): number {\n return 32;\n}\n\nexport async function fetchBackpointerFromSeeds(\n rpc: Parameters<typeof fetchEncodedAccount>[0],\n seeds: BackpointerSeeds,\n config: FetchAccountConfig & { programAddress?: Address } = {}\n): Promise<Account<Backpointer>> {\n const maybeAccount = await fetchMaybeBackpointerFromSeeds(rpc, seeds, config);\n assertAccountExists(maybeAccount);\n return maybeAccount;\n}\n\nexport async function fetchMaybeBackpointerFromSeeds(\n rpc: Parameters<typeof fetchEncodedAccount>[0],\n seeds: BackpointerSeeds,\n config: FetchAccountConfig & { programAddress?: Address } = {}\n): Promise<MaybeAccount<Backpointer>> {\n const { programAddress, ...fetchConfig } = config;\n const [address] = await findBackpointerPda(seeds, { programAddress });\n return await fetchMaybeBackpointer(rpc, address, fetchConfig);\n}\n","/**\n * This code was AUTOGENERATED using the codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n containsBytes,\n getU8Encoder,\n type Address,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport {\n type ParsedCreateMintInstruction,\n type ParsedUnwrapInstruction,\n type ParsedWrapInstruction,\n} from '../instructions';\n\nexport const TOKEN_WRAP_PROGRAM_ADDRESS =\n 'TwRapQCDhWkZRrDaHfZGuHxkZ91gHDRkyuzNqeU5MgR' as Address<'TwRapQCDhWkZRrDaHfZGuHxkZ91gHDRkyuzNqeU5MgR'>;\n\nexport enum TokenWrapAccount {\n Backpointer,\n}\n\nexport enum TokenWrapInstruction {\n CreateMint,\n Wrap,\n Unwrap,\n}\n\nexport function identifyTokenWrapInstruction(\n instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array\n): TokenWrapInstruction {\n const data = 'data' in instruction ? instruction.data : instruction;\n if (containsBytes(data, getU8Encoder().encode(0), 0)) {\n return TokenWrapInstruction.CreateMint;\n }\n if (containsBytes(data, getU8Encoder().encode(1), 0)) {\n return TokenWrapInstruction.Wrap;\n }\n if (containsBytes(data, getU8Encoder().encode(2), 0)) {\n return TokenWrapInstruction.Unwrap;\n }\n throw new Error(\n 'The provided instruction could not be identified as a tokenWrap instruction.'\n );\n}\n\nexport type ParsedTokenWrapInstruction<\n TProgram extends string = 'TwRapQCDhWkZRrDaHfZGuHxkZ91gHDRkyuzNqeU5MgR',\n> =\n | ({\n instructionType: TokenWrapInstruction.CreateMint;\n } & ParsedCreateMintInstruction<TProgram>)\n | ({\n instructionType: TokenWrapInstruction.Wrap;\n } & ParsedWrapInstruction<TProgram>)\n | ({\n instructionType: TokenWrapInstruction.Unwrap;\n } & ParsedUnwrapInstruction<TProgram>);\n","/**\n * This code was AUTOGENERATED using the codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n isProgramError,\n type Address,\n type SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM,\n type SolanaError,\n} from '@solana/kit';\nimport { TOKEN_WRAP_PROGRAM_ADDRESS } from '../programs';\n\nexport const TOKEN_WRAP_ERROR__WRAPPED_MINT_MISMATCH = 0x0; // 0\n\nexport const TOKEN_WRAP_ERROR__BACKPOINTER_MISMATCH = 0x1; // 1\n\nexport const TOKEN_WRAP_ERROR__ZERO_WRAP_AMOUNT = 0x2; // 2\n\nexport const TOKEN_WRAP_ERROR__MINT_AUTHORITY_MISMATCH = 0x3; // 3\n\nexport const TOKEN_WRAP_ERROR__ESCROW_OWNER_MISMATCH = 0x4; // 4\n\nexport const TOKEN_WRAP_ERROR__INVALID_WRAPPED_MINT_OWNER = 0x5; // 5\n\nexport const TOKEN_WRAP_ERROR__INVALID_BACKPOINTER_OWNER = 0x6; // 6\n\nexport const TOKEN_WRAP_ERROR__ESCROW_MISMATCH = 0x7; // 7\n\nexport type TokenWrapError =\n | typeof TOKEN_WRAP_ERROR__BACKPOINTER_MISMATCH\n | typeof TOKEN_WRAP_ERROR__ESCROW_MISMATCH\n | typeof TOKEN_WRAP_ERROR__ESCROW_OWNER_MISMATCH\n | typeof TOKEN_WRAP_ERROR__INVALID_BACKPOINTER_OWNER\n | typeof TOKEN_WRAP_ERROR__INVALID_WRAPPED_MINT_OWNER\n | typeof TOKEN_WRAP_ERROR__MINT_AUTHORITY_MISMATCH\n | typeof TOKEN_WRAP_ERROR__WRAPPED_MINT_MISMATCH\n | typeof TOKEN_WRAP_ERROR__ZERO_WRAP_AMOUNT;\n\nlet tokenWrapErrorMessages: Record<TokenWrapError, string> | undefined;\nif (process.env.NODE_ENV !== 'production') {\n tokenWrapErrorMessages = {\n [TOKEN_WRAP_ERROR__BACKPOINTER_MISMATCH]: `Wrapped backpointer account address does not match expected PDA`,\n [TOKEN_WRAP_ERROR__ESCROW_MISMATCH]: `Escrow account address does not match expected ATA`,\n [TOKEN_WRAP_ERROR__ESCROW_OWNER_MISMATCH]: `Unwrapped escrow token owner is not set to expected PDA`,\n [TOKEN_WRAP_ERROR__INVALID_BACKPOINTER_OWNER]: `Wrapped backpointer account owner is not the expected token wrap program`,\n [TOKEN_WRAP_ERROR__INVALID_WRAPPED_MINT_OWNER]: `Wrapped mint account owner is not the expected token program`,\n [TOKEN_WRAP_ERROR__MINT_AUTHORITY_MISMATCH]: `Wrapped mint authority does not match expected PDA`,\n [TOKEN_WRAP_ERROR__WRAPPED_MINT_MISMATCH]: `Wrapped mint account address does not match expected PDA`,\n [TOKEN_WRAP_ERROR__ZERO_WRAP_AMOUNT]: `Wrap amount should be positive`,\n };\n}\n\nexport function getTokenWrapErrorMessage(code: TokenWrapError): string {\n if (process.env.NODE_ENV !== 'production') {\n return (tokenWrapErrorMessages as Record<TokenWrapError, string>)[code];\n }\n\n return 'Error message not available in production bundles.';\n}\n\nexport function isTokenWrapError<TProgramErrorCode extends TokenWrapError>(\n error: unknown,\n transactionMessage: {\n instructions: Record<number, { programAddress: Address }>;\n },\n code?: TProgramErrorCode\n): error is SolanaError<typeof SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM> &\n Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> {\n return isProgramError<TProgramErrorCode>(\n error,\n transactionMessage,\n TOKEN_WRAP_PROGRAM_ADDRESS,\n code\n );\n}\n","/**\n * This code was AUTOGENERATED using the codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n AccountRole,\n isProgramDerivedAddress,\n isTransactionSigner as kitIsTransactionSigner,\n type Address,\n type IAccountMeta,\n type IAccountSignerMeta,\n type ProgramDerivedAddress,\n type TransactionSigner,\n upgradeRoleToSigner,\n} from '@solana/kit';\n\n/**\n * Asserts that the given value is not null or undefined.\n * @internal\n */\nexport function expectSome<T>(value: T | null | undefined): T {\n if (value == null) {\n throw new Error('Expected a value but received null or undefined.');\n }\n return value;\n}\n\n/**\n * Asserts that the given value is a PublicKey.\n * @internal\n */\nexport function expectAddress<T extends string = string>(\n value:\n | Address<T>\n | ProgramDerivedAddress<T>\n | TransactionSigner<T>\n | null\n | undefined\n): Address<T> {\n if (!value) {\n throw new Error('Expected a Address.');\n }\n if (typeof value === 'object' && 'address' in value) {\n return value.address;\n }\n if (Array.isArray(value)) {\n return value[0];\n }\n return value as Address<T>;\n}\n\n/**\n * Asserts that the given value is a PDA.\n * @internal\n */\nexport function expectProgramDerivedAddress<T extends string = string>(\n value:\n | Address<T>\n | ProgramDerivedAddress<T>\n | TransactionSigner<T>\n | null\n | undefined\n): ProgramDerivedAddress<T> {\n if (!value || !Array.isArray(value) || !isProgramDerivedAddress(value)) {\n throw new Error('Expected a ProgramDerivedAddress.');\n }\n return value;\n}\n\n/**\n * Asserts that the given value is a TransactionSigner.\n * @internal\n */\nexport function expectTransactionSigner<T extends string = string>(\n value:\n | Address<T>\n | ProgramDerivedAddress<T>\n | TransactionSigner<T>\n | null\n | undefined\n): TransactionSigner<T> {\n if (!value || !isTransactionSigner(value)) {\n throw new Error('Expected a TransactionSigner.');\n }\n return value;\n}\n\n/**\n * Defines an instruction account to resolve.\n * @internal\n */\nexport type ResolvedAccount<\n T extends string = string,\n U extends\n | Address<T>\n | ProgramDerivedAddress<T>\n | TransactionSigner<T>\n | null =\n | Address<T>\n | ProgramDerivedAddress<T>\n | TransactionSigner<T>\n | null,\n> = {\n isWritable: boolean;\n value: U;\n};\n\n/**\n * Defines an instruction that stores additional bytes on-chain.\n * @internal\n */\nexport type IInstructionWithByteDelta = {\n byteDelta: number;\n};\n\n/**\n * Get account metas and signers from resolved accounts.\n * @internal\n */\nexport function getAccountMetaFactory(\n programAddress: Address,\n optionalAccountStrategy: 'omitted' | 'programId'\n) {\n return (\n account: ResolvedAccount\n ): IAccountMeta | IAccountSignerMeta | undefined => {\n if (!account.value) {\n if (optionalAccountStrategy === 'omitted') return;\n return Object.freeze({\n address: programAddress,\n role: AccountRole.READONLY,\n });\n }\n\n const writableRole = account.isWritable\n ? AccountRole.WRITABLE\n : AccountRole.READONLY;\n return Object.freeze({\n address: expectAddress(account.value),\n role: isTransactionSigner(account.value)\n ? upgradeRoleToSigner(writableRole)\n : writableRole,\n ...(isTransactionSigner(account.value) ? { signer: account.value } : {}),\n });\n };\n}\n\nexport function isTransactionSigner<TAddress extends string = string>(\n value:\n | Address<TAddress>\n | ProgramDerivedAddress<TAddress>\n | TransactionSigner<TAddress>\n): value is TransactionSigner<TAddress> {\n return (\n !!value &&\n typeof value === 'object' &&\n 'address' in value &&\n kitIsTransactionSigner(value)\n );\n}\n","/**\n * This code was AUTOGENERATED using the codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n combineCodec,\n getBooleanDecoder,\n getBooleanEncoder,\n getStructDecoder,\n getStructEncoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type Address,\n type Codec,\n type Decoder,\n type Encoder,\n type IAccountMeta,\n type IInstruction,\n type IInstructionWithAccounts,\n type IInstructionWithData,\n type ReadonlyAccount,\n type WritableAccount,\n} from '@solana/kit';\nimport { TOKEN_WRAP_PROGRAM_ADDRESS } from '../programs';\nimport { getAccountMetaFactory, type ResolvedAccount } from '../shared';\n\nexport const CREATE_MINT_DISCRIMINATOR = 0;\n\nexport function getCreateMintDiscriminatorBytes() {\n return getU8Encoder().encode(CREATE_MINT_DISCRIMINATOR);\n}\n\nexport type CreateMintInstruction<\n TProgram extends string = typeof TOKEN_WRAP_PROGRAM_ADDRESS,\n TAccountWrappedMint extends string | IAccountMeta<string> = string,\n TAccountBackpointer extends string | IAccountMeta<string> = string,\n TAccountUnwrappedMint extends string | IAccountMeta<string> = string,\n TAccountSystemProgram extends\n | string\n | IAccountMeta<string> = '11111111111111111111111111111111',\n TAccountWrappedTokenProgram extends string | IAccountMeta<string> = string,\n TRemainingAccounts extends readonly IAccountMeta<string>[] = [],\n> = IInstruction<TProgram> &\n IInstructionWithData<Uint8Array> &\n IInstructionWithAccounts<\n [\n TAccountWrappedMint extends string\n ? WritableAccount<TAccountWrappedMint>\n : TAccountWrappedMint,\n TAccountBackpointer extends string\n ? WritableAccount<TAccountBackpointer>\n : TAccountBackpointer,\n TAccountUnwrappedMint extends string\n ? ReadonlyAccount<TAccountUnwrappedMint>\n : TAccountUnwrappedMint,\n TAccountSystemProgram extends string\n ? ReadonlyAccount<TAccountSystemProgram>\n : TAccountSystemProgram,\n TAccountWrappedTokenProgram extends string\n ? ReadonlyAccount<TAccountWrappedTokenProgram>\n : TAccountWrappedTokenProgram,\n ...TRemainingAccounts,\n ]\n >;\n\nexport type CreateMintInstructionData = {\n discriminator: number;\n /** Whether the creation should fail if the wrapped mint already exists. */\n idempotent: boolean;\n};\n\nexport type CreateMintInstructionDataArgs = {\n /** Whether the creation should fail if the wrapped mint already exists. */\n idempotent?: boolean;\n};\n\nexport function getCreateMintInstructionDataEncoder(): Encoder<CreateMintInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['idempotent', getBooleanEncoder()],\n ]),\n (value) => ({\n ...value,\n discriminator: CREATE_MINT_DISCRIMINATOR,\n idempotent: value.idempotent ?? false,\n })\n );\n}\n\nexport function getCreateMintInstructionDataDecoder(): Decoder<CreateMintInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['idempotent', getBooleanDecoder()],\n ]);\n}\n\nexport function getCreateMintInstructionDataCodec(): Codec<\n CreateMintInstructionDataArgs,\n CreateMintInstructionData\n> {\n return combineCodec(\n getCreateMintInstructionDataEncoder(),\n getCreateMintInstructionDataDecoder()\n );\n}\n\nexport type CreateMintInput<\n TAccountWrappedMint extends string = string,\n TAccountBackpointer extends string = string,\n TAccountUnwrappedMint extends string = string,\n TAccountSystemProgram extends string = string,\n TAccountWrappedTokenProgram extends string = string,\n> = {\n /**\n * Unallocated wrapped mint account to create (PDA), address must be:\n * `get_wrapped_mint_address(unwrapped_mint_address, wrapped_token_program_id)`\n */\n wrappedMint: Address<TAccountWrappedMint>;\n /**\n * Unallocated wrapped backpointer account to create (PDA)\n * `get_wrapped_mint_backpointer_address(wrapped_mint_address)`\n */\n backpointer: Address<TAccountBackpointer>;\n /** The existing mint */\n unwrappedMint: Address<TAccountUnwrappedMint>;\n /** The system program */\n systemProgram?: Address<TAccountSystemProgram>;\n /** The token program used to create the wrapped mint */\n wrappedTokenProgram: Address<TAccountWrappedTokenProgram>;\n idempotent?: CreateMintInstructionDataArgs['idempotent'];\n};\n\nexport function getCreateMintInstruction<\n TAccountWrappedMint extends string,\n TAccountBackpointer extends string,\n TAccountUnwrappedMint extends string,\n TAccountSystemProgram extends string,\n TAccountWrappedTokenProgram extends string,\n TProgramAddress extends Address = typeof TOKEN_WRAP_PROGRAM_ADDRESS,\n>(\n input: CreateMintInput<\n TAccountWrappedMint,\n TAccountBackpointer,\n TAccountUnwrappedMint,\n TAccountSystemProgram,\n TAccountWrappedTokenProgram\n >,\n config?: { programAddress?: TProgramAddress }\n): CreateMintInstruction<\n TProgramAddress,\n TAccountWrappedMint,\n TAccountBackpointer,\n TAccountUnwrappedMint,\n TAccountSystemProgram,\n TAccountWrappedTokenProgram\n> {\n // Program address.\n const programAddress = config?.programAddress ?? TOKEN_WRAP_PROGRAM_ADDRESS;\n\n // Original accounts.\n const originalAccounts = {\n wrappedMint: { value: input.wrappedMint ?? null, isWritable: true },\n backpointer: { value: input.backpointer ?? null, isWritable: true },\n unwrappedMint: { value: input.unwrappedMint ?? null, isWritable: false },\n systemProgram: { value: input.systemProgram ?? null, isWritable: false },\n wrappedTokenProgram: {\n value: input.wrappedTokenProgram ?? null,\n isWritable: false,\n },\n };\n const accounts = originalAccounts as Record<\n keyof typeof originalAccounts,\n ResolvedAccount\n >;\n\n // Original args.\n const args = { ...input };\n\n // Resolve default values.\n if (!accounts.systemProgram.value) {\n accounts.systemProgram.value =\n '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;\n }\n\n const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');\n const instruction = {\n accounts: [\n getAccountMeta(accounts.wrappedMint),\n getAccountMeta(accounts.backpointer),\n getAccountMeta(accounts.unwrappedMint),\n getAccountMeta(accounts.systemProgram),\n getAccountMeta(accounts.wrappedTokenProgram),\n ],\n programAddress,\n data: getCreateMintInstructionDataEncoder().encode(\n args as CreateMintInstructionDataArgs\n ),\n } as CreateMintInstruction<\n TProgramAddress,\n TAccountWrappedMint,\n TAccountBackpointer,\n TAccountUnwrappedMint,\n TAccountSystemProgram,\n TAccountWrappedTokenProgram\n >;\n\n return instruction;\n}\n\nexport type ParsedCreateMintInstruction<\n TProgram extends string = typeof TOKEN_WRAP_PROGRAM_ADDRESS,\n TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[],\n> = {\n programAddress: Address<TProgram>;\n accounts: {\n /**\n * Unallocated wrapped mint account to create (PDA), address must be:\n * `get_wrapped_mint_address(unwrapped_mint_address, wrapped_token_program_id)`\n */\n\n wrappedMint: TAccountMetas[0];\n /**\n * Unallocated wrapped backpointer account to create (PDA)\n * `get_wrapped_mint_backpointer_address(wrapped_mint_address)`\n */\n\n backpointer: TAccountMetas[1];\n /** The existing mint */\n unwrappedMint: TAccountMetas[2];\n /** The system program */\n systemProgram?: TAccountMetas[3] | undefined;\n /** The token program used to create the wrapped mint */\n wrappedTokenProgram: TAccountMetas[4];\n };\n data: CreateMintInstructionData;\n};\n\nexport function parseCreateMintInstruction<\n TProgram extends string,\n TAccountMetas extends readonly IAccountMeta[],\n>(\n instruction: IInstruction<TProgram> &\n IInstructionWithAccounts<TAccountMetas> &\n IInstructionWithData<Uint8Array>\n): ParsedCreateMintInstruction<TProgram, TAccountMetas> {\n if (instruction.accounts.length < 5) {\n // TODO: Coded error.\n throw new Error('Not enough accounts');\n }\n let accountIndex = 0;\n const getNextAccount = () => {\n const accountMeta = instruction.accounts![accountIndex]!;\n accountIndex += 1;\n return accountMeta;\n };\n const getNextOptionalAccount = () => {\n const accountMeta = getNextAccount();\n return accountMeta.address === TOKEN_WRAP_PROGRAM_ADDRESS\n ? undefined\n : accountMeta;\n };\n return {\n programAddress: instruction.programAddress,\n accounts: {\n wrappedMint: getNextAccount(),\n backpointer: getNextAccount(),\n unwrappedMint: getNextAccount(),\n systemProgram: getNextOptionalAccount(),\n wrappedTokenProgram: getNextAccount(),\n },\n data: getCreateMintInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * This code was AUTOGENERATED using the codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n AccountRole,\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU64Decoder,\n getU64Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type Address,\n type Codec,\n type Decoder,\n type Encoder,\n type IAccountMeta,\n type IAccountSignerMeta,\n type IInstruction,\n type IInstructionWithAccounts,\n type IInstructionWithData,\n type ReadonlyAccount,\n type ReadonlySignerAccount,\n type TransactionSigner,\n type WritableAccount,\n} from '@solana/kit';\nimport { TOKEN_WRAP_PROGRAM_ADDRESS } from '../programs';\nimport { getAccountMetaFactory, type ResolvedAccount } from '../shared';\n\nexport const UNWRAP_DISCRIMINATOR = 2;\n\nexport function getUnwrapDiscriminatorBytes() {\n return getU8Encoder().encode(UNWRAP_DISCRIMINATOR);\n}\n\nexport type UnwrapInstruction<\n TProgram extends string = typeof TOKEN_WRAP_PROGRAM_ADDRESS,\n TAccountUnwrappedEscrow extends string | IAccountMeta<string> = string,\n TAccountRecipientUnwrappedToken extends\n | string\n | IAccountMeta<string> = string,\n TAccountWrappedMintAuthority extends string | IAccountMeta<string> = string,\n TAccountUnwrappedMint extends string | IAccountMeta<string> = string,\n TAccountWrappedTokenProgram extends string | IAccountMeta<string> = string,\n TAccountUnwrappedTokenProgram extends string | IAccountMeta<string> = string,\n TAccountWrappedTokenAccount extends string | IAccountMeta<string> = string,\n TAccountWrappedMint extends string | IAccountMeta<string> = string,\n TAccountTransferAuthority extends string | IAccountMeta<string> = string,\n TRemainingAccounts extends readonly IAccountMeta<string>[] = [],\n> = IInstruction<TProgram> &\n IInstructionWithData<Uint8Array> &\n IInstructionWithAccounts<\n [\n TAccountUnwrappedEscrow extends string\n ? WritableAccount<TAccountUnwrappedEscrow>\n : TAccountUnwrappedEscrow,\n TAccountRecipientUnwrappedToken extends string\n ? WritableAccount<TAccountRecipientUnwrappedToken>\n : TAccountRecipientUnwrappedToken,\n TAccountWrappedMintAuthority extends string\n ? ReadonlyAccount<TAccountWrappedMintAuthority>\n : TAccountWrappedMintAuthority,\n TAccountUnwrappedMint extends string\n ? ReadonlyAccount<TAccountUnwrappedMint>\n : TAccountUnwrappedMint,\n TAccountWrappedTokenProgram extends string\n ? ReadonlyAccount<TAccountWrappedTokenProgram>\n : TAccountWrappedTokenProgram,\n TAccountUnwrappedTokenProgram extends string\n ? ReadonlyAccount<TAccountUnwrappedTokenProgram>\n : TAccountUnwrappedTokenProgram,\n TAccountWrappedTokenAccount extends string\n ? WritableAccount<TAccountWrappedTokenAccount>\n : TAccountWrappedTokenAccount,\n TAccountWrappedMint extends string\n ? WritableAccount<TAccountWrappedMint>\n : TAccountWrappedMint,\n TAccountTransferAuthority extends string\n ? ReadonlyAccount<TAccountTransferAuthority>\n : TAccountTransferAuthority,\n ...TRemainingAccounts,\n ]\n >;\n\nexport type UnwrapInstructionData = {\n discriminator: number;\n /** The amount of tokens to unwrap. */\n amount: bigint;\n};\n\nexport type UnwrapInstructionDataArgs = {\n /** The amount of tokens to unwrap. */\n amount: number | bigint;\n};\n\nexport function getUnwrapInstructionDataEncoder(): Encoder<UnwrapInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['amount', getU64Encoder()],\n ]),\n (value) => ({ ...value, discriminator: UNWRAP_DISCRIMINATOR })\n );\n}\n\nexport function getUnwrapInstructionDataDecoder(): Decoder<UnwrapInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['amount', getU64Decoder()],\n ]);\n}\n\nexport function getUnwrapInstructionDataCodec(): Codec<\n UnwrapInstructionDataArgs,\n UnwrapInstructionData\n> {\n return combineCodec(\n getUnwrapInstructionDataEncoder(),\n getUnwrapInstructionDataDecoder()\n );\n}\n\nexport type UnwrapInput<\n TAccountUnwrappedEscrow extends string = string,\n TAccountRecipientUnwrappedToken extends string = string,\n TAccountWrappedMintAuthority extends string = string,\n TAccountUnwrappedMint extends string = string,\n TAccountWrappedTokenProgram extends string = string,\n TAccountUnwrappedTokenProgram extends string = string,\n TAccountWrappedTokenAccount extends string = string,\n TAccountWrappedMint extends string = string,\n TAccountTransferAuthority extends string = string,\n> = {\n /**\n * The escrow account holding the unwrapped tokens.\n * Address must be ATA: get_escrow_address(unwrapped_mint, unwrapped_token_program, wrapped_token_program)\n */\n unwrappedEscrow: Address<TAccountUnwrappedEscrow>;\n /** The account to receive the unwrapped tokens. */\n recipientUnwrappedToken: Address<TAccountRecipientUnwrappedToken>;\n /**\n * The PDA authority of the wrapped mint,\n * address must be: `get_wrapped_mint_authority(wrapped_mint)`\n */\n wrappedMintAuthority: Address<TAccountWrappedMintAuthority>;\n /** The mint of the unwrapped tokens */\n unwrappedMint: Address<TAccountUnwrappedMint>;\n /** The token program of the wrapped tokens */\n wrappedTokenProgram: Address<TAccountWrappedTokenProgram>;\n /** The token program of the unwrapped tokens */\n unwrappedTokenProgram: Address<TAccountUnwrappedTokenProgram>;\n /** The source token account for the wrapped tokens */\n wrappedTokenAccount: Address<TAccountWrappedTokenAccount>;\n /**\n * The wrapped mint account, address must be:\n * `get_wrapped_mint_address(unwrapped_mint_address, wrapped_token_program_id)`\n */\n wrappedMint: Address<TAccountWrappedMint>;\n /** The authority to burn the wrapped tokens. */\n transferAuthority:\n | Address<TAccountTransferAuthority>\n | TransactionSigner<TAccountTransferAuthority>;\n amount: UnwrapInstructionDataArgs['amount'];\n multiSigners?: Array<TransactionSigner>;\n};\n\nexport function getUnwrapInstruction<\n TAccountUnwrappedEscrow extends string,\n TAccountRecipientUnwrappedToken extends string,\n TAccountWrappedMintAuthority extends string,\n TAccountUnwrappedMint extends string,\n TAccountWrappedTokenProgram extends string,\n TAccountUnwrappedTokenProgram extends string,\n TAccountWrappedTokenAccount extends string,\n TAccountWrappedMint extends string,\n TAccountTransferAuthority extends string,\n TProgramAddress extends Address = typeof TOKEN_WRAP_PROGRAM_ADDRESS,\n>(\n input: UnwrapInput<\n TAccountUnwrappedEscrow,\n TAccountRecipientUnwrappedToken,\n TAccountWrappedMintAuthority,\n TAccountUnwrappedMint,\n TAccountWrappedTokenProgram,\n TAccountUnwrappedTokenProgram,\n TAccountWrappedTokenAccount,\n TAccountWrappedMint,\n TAccountTransferAuthority\n >,\n config?: { programAddress?: TProgramAddress }\n): UnwrapInstruction<\n TProgramAddress,\n TAccountUnwrappedEscrow,\n TAccountRecipientUnwrappedToken,\n TAccountWrappedMintAuthority,\n TAccountUnwrappedMint,\n TAccountWrappedTokenProgram,\n TAccountUnwrappedTokenProgram,\n TAccountWrappedTokenAccount,\n TAccountWrappedMint,\n (typeof input)['transferAuthority'] extends TransactionSigner<TAccountTransferAuthority>\n ? ReadonlySignerAccount<TAccountTransferAuthority> &\n IAccountSignerMeta<TAccountTransferAuthority>\n : TAccountTransferAuthority\n> {\n // Program address.\n const programAddress = config?.programAddress ?? TOKEN_WRAP_PROGRAM_ADDRESS;\n\n // Original accounts.\n const originalAccounts = {\n unwrappedEscrow: { value: input.unwrappedEscrow ?? null, isWritable: true },\n recipientUnwrappedToken: {\n value: input.recipientUnwrappedToken ?? null,\n isWritable: true,\n },\n wrappedMintAuthority: {\n value: input.wrappedMintAuthority ?? null,\n isWritable: false,\n },\n unwrappedMint: { value: input.unwrappedMint ?? null, isWritable: false },\n wrappedTokenProgram: {\n value: input.wrappedTokenProgram ?? null,\n isWritable: false,\n },\n unwrappedTokenProgram: {\n value: input.unwrappedTokenProgram ?? null,\n isWritable: false,\n },\n wrappedTokenAccount: {\n value: input.wrappedTokenAccount ?? null,\n isWritable: true,\n },\n wrappedMint: { value: input.wrappedMint ?? null, isWritable: true },\n transferAuthority: {\n value: input.transferAuthority ?? null,\n isWritable: false,\n },\n };\n const accounts = originalAccounts as Record<\n keyof typeof originalAccounts,\n ResolvedAccount\n >;\n\n // Original args.\n const args = { ...input };\n\n // Remaining accounts.\n const remainingAccounts: IAccountMeta[] = (args.multiSigners ?? []).map(\n (signer) => ({\n address: signer.address,\n role: AccountRole.READONLY_SIGNER,\n signer,\n })\n );\n\n const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');\n const instruction = {\n accounts: [\n getAccountMeta(accounts.unwrappedEscrow),\n getAccountMeta(accounts.recipientUnwrappedToken),\n getAccountMeta(accounts.wrappedMintAuthority),\n getAccountMeta(accounts.unwrappedMint),\n getAccountMeta(accounts.wrappedTokenProgram),\n getAccountMeta(accounts.unwrappedTokenProgram),\n getAccountMeta(accounts.wrappedTokenAccount),\n getAccountMeta(accounts.wrappedMint),\n getAccountMeta(accounts.transferAuthority),\n ...remainingAccounts,\n ],\n programAddress,\n data: getUnwrapInstructionDataEncoder().encode(\n args as UnwrapInstructionDataArgs\n ),\n } as UnwrapInstruction<\n TProgramAddress,\n TAccountUnwrappedEscrow,\n TAccountRecipientUnwrappedToken,\n TAccountWrappedMintAuthority,\n TAccountUnwrappedMint,\n TAccountWrappedTokenProgram,\n TAccountUnwrappedTokenProgram,\n TAccountWrappedTokenAccount,\n TAccountWrappedMint,\n (typeof input)['transferAuthority'] extends TransactionSigner<TAccountTransferAuthority>\n ? ReadonlySignerAccount<TAccountTransferAuthority> &\n IAccountSignerMeta<TAccountTransferAuthority>\n : TAccountTransferAuthority\n >;\n\n return instruction;\n}\n\nexport type ParsedUnwrapInstruction<\n TProgram extends string = typeof TOKEN_WRAP_PROGRAM_ADDRESS,\n TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[],\n> = {\n programAddress: Address<TProgram>;\n accounts: {\n /**\n * The escrow account holding the unwrapped tokens.\n * Address must be ATA: get_escrow_address(unwrapped_mint, unwrapped_token_program, wrapped_token_program)\n */\n\n unwrappedEscrow: TAccountMetas[0];\n /** The account to receive the unwrapped tokens. */\n recipientUnwrappedToken: TAccountMetas[1];\n /**\n * The PDA authority of the wrapped mint,\n * address must be: `get_wrapped_mint_authority(wrapped_mint)`\n */\n\n wrappedMintAuthority: TAccountMetas[2];\n /** The mint of the unwrapped tokens */\n unwrappedMint: TAccountMetas[3];\n /** The token program of the wrapped tokens */\n wrappedTokenProgram: TAccountMetas[4];\n /** The token program of the unwrapped tokens */\n unwrappedTokenProgram: TAccountMetas[5];\n /** The source token account for the wrapped tokens */\n wrappedTokenAccount: TAccountMetas[6];\n /**\n * The wrapped mint account, address must be:\n * `get_wrapped_mint_address(unwrapped_mint_address, wrapped_token_program_id)`\n */\n\n wrappedMint: TAccountMetas[7];\n /** The authority to burn the wrapped tokens. */\n transferAuthority: TAccountMetas[8];\n };\n data: UnwrapInstructionData;\n};\n\nexport function parseUnwrapInstruction<\n TProgram extends string,\n TAccountMetas extends readonly IAccountMeta[],\n>(\n instruction: IInstruction<TProgram> &\n IInstructionWithAccounts<TAccountMetas> &\n IInstructionWithData<Uint8Array>\n): ParsedUnwrapInstruction<TProgram, TAccountMetas> {\n if (instruction.accounts.length < 9) {\n // TODO: Coded error.\n throw new Error('Not enough accounts');\n }\n let accountIndex = 0;\n const getNextAccount = () => {\n const accountMeta = instruction.accounts![accountIndex]!;\n accountIndex += 1;\n return accountMeta;\n };\n return {\n programAddress: instruction.programAddress,\n accounts: {\n unwrappedEscrow: getNextAccount(),\n recipientUnwrappedToken: getNextAccount(),\n wrappedMintAuthority: getNextAccount(),\n unwrappedMint: getNextAccount(),\n wrappedTokenProgram: getNextAccount(),\n unwrappedTokenProgram: getNextAccount(),\n wrappedTokenAccount: getNextAccount(),\n wrappedMint: getNextAccount(),\n transferAuthority: getNextAccount(),\n },\n data: getUnwrapInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * This code was AUTOGENERATED using the codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n AccountRole,\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU64Decoder,\n getU64Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type Address,\n type Codec,\n type Decoder,\n type Encoder,\n type IAccountMeta,\n type IAccountSignerMeta,\n type IInstruction,\n type IInstructionWithAccounts,\n type IInstructionWithData,\n type ReadonlyAccount,\n type ReadonlySignerAccount,\n type TransactionSigner,\n type WritableAccount,\n} from '@solana/kit';\nimport { TOKEN_WRAP_PROGRAM_ADDRESS } from '../programs';\nimport { getAccountMetaFactory, type ResolvedAccount } from '../shared';\n\nexport const WRAP_DISCRIMINATOR = 1;\n\nexport function getWrapDiscriminatorBytes() {\n return getU8Encoder().encode(WRAP_DISCRIMINATOR);\n}\n\nexport type WrapInstruction<\n TProgram extends string = typeof TOKEN_WRAP_PROGRAM_ADDRESS,\n TAccountRecipientWrappedTokenAccount extends\n | string\n | IAccountMeta<string> = string,\n TAccountWrappedMint extends string | IAccountMeta<string> = string,\n TAccountWrappedMintAuthority extends string | IAccountMeta<string> = string,\n TAccountUnwrappedTokenProgram extends string | IAccountMeta<string> = string,\n TAccountWrappedTokenProgram extends string | IAccountMeta<string> = string,\n TAccountUnwrappedTokenAccount extends string | IAccountMeta<string> = string,\n TAccountUnwrappedMint extends string | IAccountMeta<string> = string,\n TAccountUnwrappedEscrow extends string | IAccountMeta<string> = string,\n TAccountTransferAuthority extends string | IAccountMeta<string> = string,\n TRemainingAccounts extends readonly IAccountMeta<string>[] = [],\n> = IInstruction<TProgram> &\n IInstructionWithData<Uint8Array> &\n IInstructionWithAccounts<\n [\n TAccountRecipientWrappedTokenAccount extends string\n ? WritableAccount<TAccountRecipientWrappedTokenAccount>\n : TAccountRecipientWrappedTokenAccount,\n TAccountWrappedMint extends string\n ? WritableAccount<TAccountWrappedMint>\n : TAccountWrappedMint,\n TAccountWrappedMintAuthority extends string\n ? ReadonlyAccount<TAccountWrappedMintAuthority>\n : TAccountWrappedMintAuthority,\n TAccountUnwrappedTokenProgram extends string\n ? ReadonlyAccount<TAccountUnwrappedTokenProgram>\n : TAccountUnwrappedTokenProgram,\n TAccountWrappedTokenProgram extends string\n ? ReadonlyAccount<TAccountWrappedTokenProgram>\n : TAccountWrappedTokenProgram,\n TAccountUnwrappedTokenAccount extends string\n ? WritableAccount<TAccountUnwrappedTokenAccount>\n : TAccountUnwrappedTokenAccount,\n TAccountUnwrappedMint extends string\n ? ReadonlyAccount<TAccountUnwrappedMint>\n : TAccountUnwrappedMint,\n TAccountUnwrappedEscrow extends string\n ? WritableAccount<TAccountUnwrappedEscrow>\n : TAccountUnwrappedEscrow,\n TAccountTransferAuthority extends string\n ? ReadonlyAccount<TAccountTransferAuthority>\n : TAccountTransferAuthority,\n ...TRemainingAccounts,\n ]\n >;\n\nexport type WrapInstructionData = {\n discriminator: number;\n /** The amount of tokens to wrap. */\n amount: bigint;\n};\n\nexport type WrapInstructionDataArgs = {\n /** The amount of tokens to wrap. */\n amount: number | bigint;\n};\n\nexport function getWrapInstructionDataEncoder(): Encoder<WrapInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['amount', getU64Encoder()],\n ]),\n (value) => ({ ...value, discriminator: WRAP_DISCRIMINATOR })\n );\n}\n\nexport function getWrapInstructionDataDecoder(): Decoder<WrapInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['amount', getU64Decoder()],\n ]);\n}\n\nexport function getWrapInstructionDataCodec(): Codec<\n WrapInstructionDataArgs,\n WrapInstructionData\n> {\n return combineCodec(\n getWrapInstructionDataEncoder(),\n getWrapInstructionDataDecoder()\n );\n}\n\nexport type WrapInput<\n TAccountRecipientWrappedTokenAccount extends string = string,\n TAccountWrappedMint extends string = string,\n TAccountWrappedMintAuthority extends string = string,\n TAccountUnwrappedTokenProgram extends string = string,\n TAccountWrappedTokenProgram extends string = string,\n TAccountUnwrappedTokenAccount extends string = string,\n TAccountUnwrappedMint extends string = string,\n TAccountUnwrappedEscrow extends string = string,\n TAccountTransferAuthority extends string = string,\n> = {\n /** The token account to receive the wrapped tokens. */\n recipientWrappedTokenAccount: Address<TAccountRecipientWrappedTokenAccount>;\n /**\n * Wrapped mint, must be initialized, address must be:\n * `get_wrapped_mint_address(unwrapped_mint_address, wrapped_token_program_id)`\n */\n wrappedMint: Address<TAccountWrappedMint>;\n /**\n * The PDA authority of the wrapped mint, address must be\n * `get_wrapped_mint_authority(wrapped_mint)`\n */\n wrappedMintAuthority: Address<TAccountWrappedMintAuthority>;\n /** The token program of the unwrapped tokens. */\n unwrappedTokenProgram: Address<TAccountUnwrappedTokenProgram>;\n /** The token program of the wrapped tokens. */\n wrappedTokenProgram: Address<TAccountWrappedTokenProgram>;\n /** The source token account for the unwrapped tokens. */\n unwrappedTokenAccount: Address<TAccountUnwrappedTokenAccount>;\n /** The mint of the unwrapped tokens. */\n unwrappedMint: Address<TAccountUnwrappedMint>;\n /**\n * The escrow account that holds the unwrapped tokens.\n * Address must be ATA: get_escrow_address(unwrapped_mint, unwrapped_token_program, wrapped_token_program)\n */\n unwrappedEscrow: Address<TAccountUnwrappedEscrow>;\n /** The authority to transfer the unwrapped tokens. */\n transferAuthority:\n | Address<TAccountTransferAuthority>\n | TransactionSigner<TAccountTransferAuthority>;\n amount: WrapInstructionDataArgs['amount'];\n multiSigners?: Array<TransactionSigner>;\n};\n\nexport function getWrapInstruction<\n TAccountRecipientWrappedTokenAccount extends string,\n TAccountWrappedMint extends string,\n TAccountWrappedMintAuthority extends string,\n TAccountUnwrappedTokenProgram extends string,\n TAccountWrappedTokenProgram extends string,\n TAccountUnwrappedTokenAccount extends string,\n TAccountUnwrappedMint extends string,\n TAccountUnwrappedEscrow extends string,\n TAccountTransferAuthority extends string,\n TProgramAddress extends Address = typeof TOKEN_WRAP_PROGRAM_ADDRESS,\n>(\n input: WrapInput<\n TAccountRecipientWrappedTokenAccount,\n TAccountWrappedMint,\n TAccountWrappedMintAuthority,\n TAccountUnwrappedTokenProgram,\n TAccountWrappedTokenProgram,\n TAccountUnwrappedTokenAccount,\n TAccountUnwrappedMint,\n TAccountUnwrappedEscrow,\n TAccountTransferAuthority\n >,\n config?: { programAddress?: TProgramAddress }\n): WrapInstruction<\n TProgramAddress,\n TAccountRecipientWrappedTokenAccount,\n TAccountWrappedMint,\n TAccountWrappedMintAuthority,\n TAccountUnwrappedTokenProgram,\n TAccountWrappedTokenProgram,\n TAccountUnwrappedTokenAccount,\n TAccountUnwrappedMint,\n TAccountUnwrappedEscrow,\n (typeof input)['transferAuthority'] extends TransactionSigner<TAccountTransferAuthority>\n ? ReadonlySignerAccount<TAccountTransferAuthority> &\n IAccountSignerMeta<TAccountTransferAuthority>\n : TAccountTransferAuthority\n> {\n // Program address.\n const programAddress = config?.programAddress ?? TOKEN_WRAP_PROGRAM_ADDRESS;\n\n // Original accounts.\n const originalAccounts = {\n recipientWrappedTokenAccount: {\n value: input.recipientWrappedTokenAccount ?? null,\n isWritable: true,\n },\n wrappedMint: { value: input.wrappedMint ?? null, isWritable: true },\n wrappedMintAuthority: {\n value: input.wrappedMintAuthority ?? null,\n isWritable: false,\n },\n unwrappedTokenProgram: {\n value: input.unwrappedTokenProgram ?? null,\n isWritable: false,\n },\n wrappedTokenProgram: {\n value: input.wrappedTokenProgram ?? null,\n isWritable: false,\n },\n unwrappedTokenAccount: {\n value: input.unwrappedTokenAccount ?? null,\n isWritable: true,\n },\n unwrappedMint: { value: input.unwrappedMint ?? null, isWritable: false },\n unwrappedEscrow: { value: input.unwrappedEscrow ?? null, isWritable: true },\n transferAuthority: {\n value: input.transferAuthority ?? null,\n isWritable: false,\n },\n };\n const accounts = originalAccounts as Record<\n keyof typeof originalAccounts,\n ResolvedAccount\n >;\n\n // Original args.\n const args = { ...input };\n\n // Remaining accounts.\n const remainingAccounts: IAccountMeta[] = (args.multiSigners ?? []).map(\n (signer) => ({\n address: signer.address,\n role: AccountRole.READONLY_SIGNER,\n signer,\n })\n );\n\n const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');\n const instruction = {\n accounts: [\n getAccountMeta(accounts.recipientWrappedTokenAccount),\n getAccountMeta(accounts.wrappedMint),\n getAccountMeta(accounts.wrappedMintAuthority),\n getAccountMeta(accounts.unwrappedTokenProgram),\n getAccountMeta(accounts.wrappedTokenProgram),\n getAccountMeta(accounts.unwrappedTokenAccount),\n getAccountMeta(accounts.unwrappedMint),\n getAccountMeta(accounts.unwrappedEscrow),\n getAccountMeta(accounts.transferAuthority),\n ...remainingAccounts,\n ],\n programAddress,\n data: getWrapInstructionDataEncoder().encode(\n args as WrapInstructionDataArgs\n ),\n } as WrapInstruction<\n TProgramAddress,\n TAccountRecipientWrappedTokenAccount,\n TAccountWrappedMint,\n TAccountWrappedMintAuthority,\n TAccountUnwrappedTokenProgram,\n TAccountWrappedTokenProgram,\n TAccountUnwrappedTokenAccount,\n TAccountUnwrappedMint,\n TAccountUnwrappedEscrow,\n (typeof input)['transferAuthority'] extends TransactionSigner<TAccountTransferAuthority>\n ? ReadonlySignerAccount<TAccountTransferAuthority> &\n IAccountSignerMeta<TAccountTransferAuthority>\n : TAccountTransferAuthority\n >;\n\n return instruction;\n}\n\nexport type ParsedWrapInstruction<\n TProgram extends string = typeof TOKEN_WRAP_PROGRAM_ADDRESS,\n TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[],\n> = {\n programAddress: Address<TProgram>;\n accounts: {\n /** The token account to receive the wrapped tokens. */\n recipientWrappedTokenAccount: TAccountMetas[0];\n /**\n * Wrapped mint, must be initialized, address must be:\n * `get_wrapped_mint_address(unwrapped_mint_address, wrapped_token_program_id)`\n */\n\n wrappedMint: TAccountMetas[1];\n /**\n * The PDA authority of the wrapped mint, address must be\n * `get_wrapped_mint_authority(wrapped_mint)`\n */\n\n wrappedMintAuthority: TAccountMetas[2];\n /** The token program of the unwrapped tokens. */\n unwrappedTokenProgram: TAccountMetas[3];\n /** The token program of the wrapped tokens. */\n wrappedTokenProgram: TAccountMetas[4];\n /** The source token account for the unwrapped tokens. */\n unwrappedTokenAccount: TAccountMetas[5];\n /** The mint of the unwrapped tokens. */\n unwrappedMint: TAccountMetas[6];\n /**\n * The escrow account that holds the unwrapped tokens.\n * Address must be ATA: get_escrow_address(unwrapped_mint, unwrapped_token_program, wrapped_token_program)\n */\n\n unwrappedEscrow: TAccountMetas[7];\n /** The authority to transfer the unwrapped tokens. */\n transferAuthority: TAccountMetas[8];\n };\n data: WrapInstructionData;\n};\n\nexport function parseWrapInstruction<\n TProgram extends string,\n TAccountMetas extends readonly IAccountMeta[],\n>(\n instruction: IInstruction<TProgram> &\n IInstructionWithAccounts<TAccountMetas> &\n IInstructionWithData<Uint8Array>\n): ParsedWrapInstruction<TProgram, TAccountMetas> {\n if (instruction.accounts.length < 9) {\n // TODO: Coded error.\n throw new Error('Not enough accounts');\n }\n let accountIndex = 0;\n const getNextAccount = () => {\n const accountMeta = instruction.accounts![accountIndex]!;\n accountIndex += 1;\n return accountMeta;\n };\n return {\n programAddress: instruction.programAddress,\n accounts: {\n recipientWrappedTokenAccount: getNextAccount(),\n wrappedMint: getNextAccount(),\n wrappedMintAuthority: getNextAccount(),\n unwrappedTokenProgram: getNextAccount(),\n wrappedTokenProgram: getNextAccount(),\n unwrappedTokenAccount: getNextAccount(),\n unwrappedMint: getNextAccount(),\n unwrappedEscrow: getNextAccount(),\n transferAuthority: getNextAccount(),\n },\n data: getWrapInstructionDataDecoder().decode(instruction.data),\n };\n}\n","import {\n Address,\n fetchEncodedAccount,\n GetAccountInfoApi,\n GetMinimumBalanceForRentExemptionApi,\n IInstruction,\n KeyPairSigner,\n Rpc,\n} from '@solana/kit';\nimport { getMintSize } from '@solana-program/token-2022';\nimport { getTransferSolInstruction } from '@solana-program/system';\nimport {\n findBackpointerPda,\n findWrappedMintPda,\n getBackpointerSize,\n getCreateMintInstruction,\n} from './generated';\n\nexport interface CreateMintArgs {\n rpc: Rpc<GetAccountInfoApi & GetMinimumBalanceForRentExemptionApi>;\n unwrappedMint: Address;\n wrappedTokenProgram: Address;\n payer: KeyPairSigner;\n idempotent: boolean;\n}\n\nexport interface CreateMintResult {\n wrappedMint: Address;\n backpointer: Address;\n fundedWrappedMintLamports: bigint;\n fundedBackpointerLamports: bigint;\n ixs: IInstruction[];\n}\n\nexport async function createMint({\n rpc,\n unwrappedMint,\n wrappedTokenProgram,\n payer,\n idempotent = false,\n}: CreateMintArgs): Promise<CreateMintResult> {\n const [wrappedMint] = await findWrappedMintPda({\n unwrappedMint,\n wrappedTokenProgram: wrappedTokenProgram,\n });\n const [backpointer] = await findBackpointerPda({ wrappedMint });\n\n const instructions: IInstruction[] = [];\n\n // Fund wrapped mint account if needed\n let fundedWrappedMintLamports = 0n;\n\n const mintSize = BigInt(getMintSize());\n const [wrappedMintAccount, wrappedMintRent] = await Promise.all([\n fetchEncodedAccount(rpc, wrappedMint),\n rpc.getMinimumBalanceForRentExemption(mintSize).send(),\n ]);\n\n const wrappedMintLamports = wrappedMintAccount.exists ? wrappedMintAccount.lamports : 0n;\n if (wrappedMintLamports < wrappedMintRent) {\n fundedWrappedMintLamports = wrappedMintRent - wrappedMintLamports;\n instructions.push(\n getTransferSolInstruction({\n source: payer,\n destination: wrappedMint,\n amount: fundedWrappedMintLamports,\n }),\n );\n }\n\n // Fund backpointer account if needed\n let fundedBackpointerLamports = 0n;\n\n const backpointerSize = BigInt(getBackpointerSize());\n const [backpointerAccount, backpointerRent] = await Promise.all([\n fetchEncodedAccount(rpc, backpointer),\n rpc.getMinimumBalanceForRentExemption(backpointerSize).send(),\n ]);\n\n const backpointerLamports = backpointerAccount.exists ? backpointerAccount.lamports : 0n;\n if (backpointerLamports < backpointerRent) {\n fundedBackpointerLamports = backpointerRent - backpointerLamports;\n instructions.push(\n getTransferSolInstruction({\n source: payer,\n destination: backpointer,\n amount: fundedBackpointerLamports,\n }),\n );\n }\n\n // Add create_mint instruction\n instructions.push(\n getCreateMintInstruction({\n wrappedMint,\n backpointer,\n unwrappedMint,\n wrappedTokenProgram,\n idempotent,\n }),\n );\n\n return {\n wrappedMint,\n backpointer,\n ixs: instructions,\n fundedWrappedMintLamports,\n fundedBackpointerLamports,\n };\n}\n","import { findWrappedMintAuthorityPda, findWrappedMintPda } from './generated';\nimport {\n Address,\n assertTransactionIsFullySigned,\n containsBytes,\n fetchEncodedAccount,\n FullySignedTransaction,\n generateKeyPairSigner,\n GetAccountInfoApi,\n GetMinimumBalanceForRentExemptionApi,\n IInstruction,\n KeyPairSigner,\n Rpc,\n SignatureBytes,\n Transaction,\n TransactionWithBlockhashLifetime,\n} from '@solana/kit';\nimport { getCreateAccountInstruction } from '@solana-program/system';\nimport {\n getInitializeAccountInstruction as initializeToken,\n TOKEN_PROGRAM_ADDRESS,\n} from '@solana-program/token';\nimport {\n fetchMaybeToken,\n findAssociatedTokenPda,\n getCreateAssociatedTokenInstruction,\n getInitializeAccountInstruction as initializeToken2022,\n getTokenDecoder,\n Token,\n TOKEN_2022_PROGRAM_ADDRESS,\n} from '@solana-program/token-2022';\nimport { Blockhash } from '@solana/rpc-types';\nimport { Account } from '@solana/accounts';\n\nfunction getInitializeTokenFn(tokenProgram: Address) {\n if (tokenProgram === TOKEN_PROGRAM_ADDRESS) return initializeToken;\n if (tokenProgram === TOKEN_2022_PROGRAM_ADDRESS) return initializeToken2022;\n throw new Error(`${tokenProgram} is not a valid token program.`);\n}\n\nexport async function createTokenAccount({\n rpc,\n payer,\n mint,\n owner,\n tokenProgram,\n}: {\n rpc: Rpc<GetMinimumBalanceForRentExemptionApi>;\n payer: KeyPairSigner;\n mint: Address;\n owner: Address;\n tokenProgram: Address;\n}): Promise<{ ixs: IInstruction[]; keyPair: KeyPairSigner }> {\n const [keyPair, lamports] = await Promise.all([\n generateKeyPairSigner(),\n rpc.getMinimumBalanceForRentExemption(165n).send(),\n ]);\n\n const createAccountIx = getCreateAccountInstruction({\n payer,\n newAccount: keyPair,\n lamports,\n space: 165,\n programAddress: tokenProgram,\n });\n\n const initializeAccountIx = getInitializeTokenFn(tokenProgram)({\n account: keyPair.address,\n mint,\n owner,\n });\n\n return {\n ixs: [createAccountIx, initializeAccountIx],\n keyPair,\n };\n}\n\nexport interface CreateEscrowAccountArgs {\n rpc: Rpc<GetAccountInfoApi & GetMinimumBalanceForRentExemptionApi>;\n payer: KeyPairSigner;\n unwrappedMint: Address;\n wrappedTokenProgram: Address;\n}\n\nexport type CreateEscrowAccountResult =\n | { kind: 'already_exists'; account: Account<Token> }\n | {\n kind: 'instructions_to_create';\n address: Address;\n ixs: IInstruction[];\n };\n\nexport async function createEscrowAccount({\n rpc,\n payer,\n unwrappedMint,\n wrappedTokenProgram,\n}: CreateEscrowAccountArgs): Promise<CreateEscrowAccountResult> {\n const [wrappedMint] = await findWrappedMintPda({ unwrappedMint, wrappedTokenProgram });\n const [wrappedMintAuthority] = await findWrappedMintAuthorityPda({ wrappedMint });\n const unwrappedTokenProgram = await getOwnerFromAccount(rpc, unwrappedMint);\n\n const [escrowAta] = await findAssociatedTokenPda({\n owner: wrappedMintAuthority,\n mint: unwrappedMint,\n tokenProgram: unwrappedTokenProgram,\n });\n\n const escrowResult = await fetchMaybeToken(rpc, escrowAta);\n if (escrowResult.exists) {\n return { kind: 'already_exists', account: escrowResult };\n }\n\n const ix = getCreateAssociatedTokenInstruction({\n payer,\n owner: wrappedMintAuthority,\n mint: unwrappedMint,\n ata: escrowAta,\n tokenProgram: unwrappedTokenProgram,\n });\n\n return { address: escrowAta, ixs: [ix], kind: 'instructions_to_create' };\n}\n\nexport async function getOwnerFromAccount(\n rpc: Rpc<GetAccountInfoApi>,\n accountAddress: Address,\n): Promise<Address> {\n const accountInfo = await rpc.getAccountInfo(accountAddress, { encoding: 'base64' }).send();\n if (!accountInfo.value) {\n throw new Error(`Account ${accountAddress} not found.`);\n }\n return accountInfo.value.owner;\n}\n\nexport async function getMintFromTokenAccount(\n rpc: Rpc<GetAccountInfoApi>,\n tokenAccountAddress: Address,\n): Promise<Address> {\n const account = await fetchEncodedAccount(rpc, tokenAccountAddress);\n if (!account.exists) {\n throw new Error(`Unwrapped token account ${tokenAccountAddress} not found.`);\n }\n return getTokenDecoder().decode(account.data).mint;\n}\n\nfunction messageBytesEqual(results: (Transaction & TransactionWithBlockhashLifetime)[]): boolean {\n // If array has only one element, return true\n if (results.length === 1) {\n return true;\n }\n\n // Use the first result as reference\n const reference = results[0];\n if (!reference) throw new Error('No transactions in input');\n\n // Compare each result with the reference\n return results.every(\n c =>\n reference.messageBytes.length === c.messageBytes.length &&\n containsBytes(reference.messageBytes, c.messageBytes, 0),\n );\n}\n\nfunction combineSignatures(\n signedTxs: (Transaction & TransactionWithBlockhashLifetime)[],\n): Record<string, SignatureBytes> {\n // Step 1: Determine the canonical signer order from the first signed transaction.\n // Insertion order is the way to re-create this. Without it, verification will fail.\n const firstSignedTx = signedTxs[0];\n if (!firstSignedTx) {\n throw new Error('No signed transactions provided');\n }\n\n const allSignatures: Record<string, SignatureBytes | null> = {};\n\n // Step 1: Insert a null signature for each signer, maintaining the order of the signatures from the first signed transaction\n for (const pubkey of Object.keys(firstSignedTx.signatures)) {\n allSignatures[pubkey] = null;\n }\n\n // Step 2: Gather all signatures from all transactions\n for (const signedTx of signedTxs) {\n for (const [address, signature] of Object.entries(signedTx.signatures)) {\n if (signature) {\n // only store non-null signers\n allSignatures[address] = signature;\n }\n }\n }\n\n // Step 3: Assert all signatures are set\n const missingSigners: string[] = [];\n for (const [pubkey, signature] of Object.entries(allSignatures)) {\n if (signature === null) {\n missingSigners.push(pubkey);\n }\n }\n if (missingSigners.length > 0) {\n throw new Error(`Missing signatures for: ${missingSigners.join(', ')}`);\n }\n\n return allSignatures as Record<string, SignatureBytes>;\n}\n\nexport interface MultiSigCombineArgs {\n signedTxs: (Transaction & TransactionWithBlockhashLifetime)[];\n blockhash: {\n blockhash: Blockhash;\n lastValidBlockHeight: bigint;\n };\n}\n\n// Combines, validates, and broadcasts outputs of multisig offline partially signed txs\nexport function combinedMultisigTx({\n signedTxs,\n blockhash,\n}: MultiSigCombineArgs): FullySignedTransaction & TransactionWithBlockhashLifetime {\n const messagesEqual = messageBytesEqual(signedTxs);\n if (!messagesEqual) throw new Error('Messages are not all the same');\n if (!signedTxs[0]) throw new Error('No signed transactions provided');\n\n const tx = {\n messageBytes: signedTxs[0].messageBytes,\n signatures: combineSignatures(signedTxs),\n lifetimeConstraint: blockhash,\n };\n\n assertTransactionIsFullySigned(tx);\n\n return tx;\n}\n","import {\n Address,\n appendTransactionMessageInstructions,\n CompilableTransactionMessage,\n createTransactionMessage,\n GetAccountInfoApi,\n IInstruction,\n pipe,\n Rpc,\n setTransactionMessageFeePayerSigner,\n setTransactionMessageLifetimeUsingBlockhash,\n TransactionMessageWithBlockhashLifetime,\n TransactionSigner,\n} from '@solana/kit';\nimport {\n findWrappedMintAuthorityPda,\n findWrappedMintPda,\n getWrapInstruction,\n WrapInput,\n} from './generated';\nimport { getMintFromTokenAccount, getOwnerFromAccount } from './utilities';\nimport { findAssociatedTokenPda } from '@solana-program/token-2022';\nimport { Blockhash } from '@solana/rpc-types';\n\ninterface IxBuilderArgs {\n unwrappedTokenAccount: Address;\n wrappedTokenProgram: Address;\n amount: bigint | number;\n wrappedMint: Address;\n wrappedMintAuthority: Address;\n transferAuthority: Address | TransactionSigner;\n unwrappedMint: Address;\n recipientWrappedTokenAccount: Address;\n unwrappedTokenProgram: Address;\n multiSigners?: TransactionSigner[];\n}\n\nexport interface MultiSignerWrapIxBuilderArgs extends IxBuilderArgs {\n payer: TransactionSigner;\n blockhash: {\n blockhash: Blockhash;\n lastValidBlockHeight: bigint;\n };\n multiSigners: TransactionSigner[];\n}\n\n// Used to collect signatures\nexport async function multisigOfflineSignWrap(\n args: MultiSignerWrapIxBuilderArgs,\n): Promise<CompilableTransactionMessage & TransactionMessageWithBlockhashLifetime> {\n const wrapIx = await buildWrapIx(args);\n\n return pipe(\n createTransactionMessage({ version: 0 }),\n tx => setTransactionMessageFeePayerSigner(args.payer, tx),\n tx => setTransactionMessageLifetimeUsingBlockhash(args.blockhash, tx),\n tx => appendTransactionMessageInstructions([wrapIx], tx),\n );\n}\n\nexport interface SingleSignerWrapArgs {\n rpc: Rpc<GetAccountInfoApi>;\n payer: TransactionSigner; // Fee payer and default transfer authority\n unwrappedTokenAccount: Address;\n wrappedTokenProgram: Address;\n amount: bigint | number;\n transferAuthority?: Address | TransactionSigner; // Defaults to payer if not provided\n unwrappedMint?: Address; // Will fetch from unwrappedTokenAccount if not provided\n recipientWrappedTokenAccount?: Address; // Defaults to payer's ATA if not provided\n unwrappedTokenProgram?: Address; // Will fetch from unwrappedTokenAccount owner if not provided\n}\n\nexport interface SingleSignerWrapResult {\n ixs: IInstruction[];\n recipientWrappedTokenAccount: Address;\n escrowAccount: Address;\n amount: bigint;\n}\n\nexport async function singleSignerWrap({\n rpc,\n payer,\n unwrappedTokenAccount,\n wrappedTokenProgram,\n amount,\n transferAuthority: inputTransferAuthority,\n unwrappedMint: inputUnwrappedMint,\n recipientWrappedTokenAccount: inputRecipientTokenAccount,\n unwrappedTokenProgram: inputUnwrappedTokenProgram,\n}: SingleSignerWrapArgs): Promise<SingleSignerWrapResult> {\n const {\n unwrappedMint,\n unwrappedTokenProgram,\n wrappedMint,\n wrappedMintAuthority,\n recipientWrappedTokenAccount,\n transferAuthority,\n unwrappedEscrow,\n } = await resolveAddrs({\n rpc,\n payer,\n inputTransferAuthority,\n inputUnwrappedMint,\n unwrappedTokenAccount,\n inputUnwrappedTokenProgram,\n wrappedTokenProgram,\n inputRecipientTokenAccount,\n });\n\n const ix = await buildWrapIx({\n unwrappedTokenAccount,\n wrappedTokenProgram,\n amount,\n transferAuthority,\n unwrappedMint,\n wrappedMint,\n wrappedMintAuthority,\n recipientWrappedTokenAccount,\n unwrappedTokenProgram,\n });\n\n return {\n ixs: [ix],\n recipientWrappedTokenAccount,\n escrowAccount: unwrappedEscrow,\n amount: BigInt(amount),\n };\n}\n\n// Meant to handle all of the potential default values\nasync function resolveAddrs({\n rpc,\n payer,\n unwrappedTokenAccount,\n wrappedTokenProgram,\n inputTransferAuthority,\n inputUnwrappedMint,\n inputRecipientTokenAccount,\n inputUnwrappedTokenProgram,\n}: {\n rpc: Rpc<GetAccountInfoApi>;\n payer: TransactionSigner;\n unwrappedTokenAccount: Address;\n wrappedTokenProgram: Address;\n inputTransferAuthority?: Address | TransactionSigner;\n inputUnwrappedMint?: Address;\n inputRecipientTokenAccount?: Address;\n inputUnwrappedTokenProgram?: Address;\n}) {\n const unwrappedMint =\n inputUnwrappedMint ?? (await getMintFromTokenAccount(rpc, unwrappedTokenAccount));\n const unwrappedTokenProgram =\n inputUnwrappedTokenProgram ?? (await getOwnerFromAccount(rpc, unwrappedTokenAccount));\n const [wrappedMint] = await findWrappedMintPda({ unwrappedMint, wrappedTokenProgram });\n const [wrappedMintAuthority] = await findWrappedMintAuthorityPda({ wrappedMint });\n const recipientWrappedTokenAccount =\n inputRecipientTokenAccount ??\n (\n await findAssociatedTokenPda({\n owner: payer.address,\n mint: wrappedMint,\n tokenProgram: wrappedTokenProgram,\n })\n )[0];\n const [unwrappedEscrow] = await findAssociatedTokenPda({\n owner: wrappedMintAuthority,\n mint: unwrappedMint,\n tokenProgram: unwrappedTokenProgram,\n });\n\n const transferAuthority = inputTransferAuthority ?? payer;\n\n return {\n unwrappedEscrow,\n transferAuthority,\n unwrappedMint,\n unwrappedTokenProgram,\n wrappedMint,\n wrappedMintAuthority,\n recipientWrappedTokenAccount,\n };\n}\n\nasync function buildWrapIx({\n unwrappedTokenAccount,\n wrappedTokenProgram,\n amount,\n transferAuthority,\n unwrappedMint,\n recipientWrappedTokenAccount,\n unwrappedTokenProgram,\n wrappedMint,\n wrappedMintAuthority,\n multiSigners = [],\n}: IxBuilderArgs): Promise<IInstruction> {\n const [unwrappedEscrow] = await findAssociatedTokenPda({\n owner: wrappedMintAuthority,\n mint: unwrappedMint,\n tokenProgram: unwrappedTokenProgram,\n });\n\n const wrapInstructionInput: WrapInput = {\n recipientWrappedTokenAccount,\n wrappedMint,\n wrappedMintAuthority,\n unwrappedTokenProgram,\n wrappedTokenProgram,\n unwrappedTokenAccount,\n unwrappedMint,\n unwrappedEscrow,\n transferAuthority,\n amount: BigInt(amount),\n multiSigners,\n };\n\n return getWrapInstruction(wrapInstructionInput);\n}\n","import {\n Address,\n appendTransactionMessageInstructions,\n CompilableTransactionMessage,\n createTransactionMessage,\n fetchEncodedAccount,\n GetAccountInfoApi,\n IInstruction,\n pipe,\n Rpc,\n setTransactionMessageFeePayerSigner,\n setTransactionMessageLifetimeUsingBlockhash,\n TransactionMessageWithBlockhashLifetime,\n TransactionSigner,\n} from '@solana/kit';\nimport { findAssociatedTokenPda, getTokenDecoder } from '@solana-program/token-2022';\nimport { findWrappedMintAuthorityPda, getUnwrapInstruction, UnwrapInput } from './generated';\nimport { getMintFromTokenAccount, getOwnerFromAccount } from './utilities';\nimport { Blockhash } from '@solana/rpc-types';\n\nexport interface SingleSignerUnwrapArgs {\n rpc: Rpc<GetAccountInfoApi>;\n payer: TransactionSigner; // Fee payer and default transfer authority\n wrappedTokenAccount: Address;\n amount: bigint | number;\n recipientUnwrappedToken: Address;\n // Optional arguments below (will be derived/defaulted if not provided)\n transferAuthority?: Address | TransactionSigner; // Defaults to payer\n unwrappedMint?: Address; // Will derive from unwrappedEscrow if not provided\n wrappedTokenProgram?: Address; // Will derive from wrappedTokenAccount if not provided\n unwrappedTokenProgram?: Address; // Will derive from unwrappedEscrow if not provided\n}\n\nasync function resolveUnwrapAddrs({\n rpc,\n payer,\n wrappedTokenAccount,\n recipientUnwrappedToken,\n inputUnwrappedMint,\n inputTransferAuthority,\n inputWrappedTokenProgram,\n inputUnwrappedTokenProgram,\n}: {\n rpc: Rpc<GetAccountInfoApi>;\n payer: TransactionSigner;\n wrappedTokenAccount: Address;\n recipientUnwrappedToken: Address;\n inputUnwrappedMint?: Address;\n inputTransferAuthority?: Address | TransactionSigner;\n inputWrappedTokenProgram?: Address;\n inputUnwrappedTokenProgram?: Address;\n}) {\n const wrappedTokenProgram =\n inputWrappedTokenProgram ?? (await getOwnerFromAccount(rpc, wrappedTokenAccount));\n const unwrappedTokenProgram =\n inputUnwrappedTokenProgram ?? (await getOwnerFromAccount(rpc, recipientUnwrappedToken));\n const unwrappedMint =\n inputUnwrappedMint ?? (await getMintFromTokenAccount(rpc, recipientUnwrappedToken));\n\n // Get wrapped mint from the token account being burned\n const wrappedAccountInfo = await fetchEncodedAccount(rpc, wrappedTokenAccount);\n if (!wrappedAccountInfo.exists) {\n throw new Error(`Wrapped token account ${wrappedTokenAccount} not found.`);\n }\n const wrappedMint = getTokenDecoder().decode(wrappedAccountInfo.data).mint;\n\n const [wrappedMintAuthority] = await findWrappedMintAuthorityPda({ wrappedMint });\n\n // Default transfer authority to payer if not provided\n const transferAuthority = inputTransferAuthority ?? payer;\n\n return {\n unwrappedMint,\n wrappedMint,\n wrappedMintAuthority,\n transferAuthority,\n wrappedTokenProgram,\n unwrappedTokenProgram,\n };\n}\n\ninterface UnwrapTxBuilderArgs {\n wrappedTokenAccount: Address;\n amount: bigint | number;\n wrappedMint: Address;\n wrappedMintAuthority: Address;\n unwrappedMint: Address;\n recipientUnwrappedToken: Address;\n unwrappedTokenProgram: Address;\n wrappedTokenProgram: Address;\n transferAuthority: Address | TransactionSigner;\n multiSigners?: TransactionSigner[];\n}\n\nasync function buildUnwrapTransaction({\n recipientUnwrappedToken,\n wrappedMintAuthority,\n unwrappedMint,\n wrappedTokenProgram,\n unwrappedTokenProgram,\n wrappedTokenAccount,\n wrappedMint,\n transferAuthority,\n amount,\n multiSigners = [],\n}: UnwrapTxBuilderArgs): Promise<IInstruction> {\n const [unwrappedEscrow] = await findAssociatedTokenPda({\n owner: wrappedMintAuthority,\n mint: unwrappedMint,\n tokenProgram: unwrappedTokenProgram,\n });\n\n const unwrapInstructionInput: UnwrapInput = {\n unwrappedEscrow,\n recipientUnwrappedToken,\n wrappedMintAuthority,\n unwrappedMint,\n wrappedTokenProgram,\n unwrappedTokenProgram,\n wrappedTokenAccount,\n wrappedMint,\n transferAuthority,\n amount: BigInt(amount),\n multiSigners,\n };\n\n return getUnwrapInstruction(unwrapInstructionInput);\n}\n\nexport interface SingleSignerUnwrapResult {\n ixs: IInstruction[];\n recipientUnwrappedToken: Address;\n amount: bigint;\n}\n\n/**\n * Creates, signs (single signer or default authority), and sends an unwrap transaction.\n * Derives necessary PDAs and default accounts if not provided.\n */\nexport async function singleSignerUnwrap({\n rpc,\n payer,\n wrappedTokenAccount,\n amount,\n recipientUnwrappedToken,\n transferAuthority: inputTransferAuthority,\n unwrappedMint: inputUnwrappedMint,\n wrappedTokenProgram: inputWrappedTokenProgram,\n unwrappedTokenProgram: inputUnwrappedTokenProgram,\n}: SingleSignerUnwrapArgs): Promise<SingleSignerUnwrapResult> {\n const {\n wrappedMint,\n wrappedMintAuthority,\n transferAuthority,\n unwrappedTokenProgram,\n unwrappedMint,\n wrappedTokenProgram,\n } = await resolveUnwrapAddrs({\n rpc,\n payer,\n wrappedTokenAccount,\n recipientUnwrappedToken,\n inputUnwrappedMint,\n inputTransferAuthority,\n inputWrappedTokenProgram,\n inputUnwrappedTokenProgram,\n });\n\n const ix = await buildUnwrapTransaction({\n recipientUnwrappedToken,\n wrappedMintAuthority,\n unwrappedMint,\n wrappedTokenProgram,\n unwrappedTokenProgram,\n wrappedTokenAccount,\n wrappedMint,\n transferAuthority,\n amount,\n });\n\n return {\n recipientUnwrappedToken,\n amount: BigInt(amount),\n ixs: [ix],\n };\n}\n\nexport interface MultiSignerUnWrapTxBuilderArgs extends UnwrapTxBuilderArgs {\n payer: TransactionSigner;\n blockhash: {\n blockhash: Blockhash;\n lastValidBlockHeight: bigint;\n };\n multiSigners: TransactionSigner[];\n}\n\n// Used to collect signatures\nexport async function multisigOfflineSignUnwrap(\n args: MultiSignerUnWrapTxBuilderArgs,\n): Promise<CompilableTransactionMessage & TransactionMessageWithBlockhashLifetime> {\n const unwrapIx = await buildUnwrapTransaction(args);\n\n return pipe(\n createTransactionMessage({ version: 0 }),\n tx => setTransactionMessageFeePayerSigner(args.payer, tx),\n tx => setTransactionMessageLifetimeUsingBlockhash(args.blockhash, tx),\n tx => appendTransactionMessageInstructions([unwrapIx], tx),\n );\n}\n"]}