@lightprotocol/compressed-token 0.22.0 → 0.22.1-alpha.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../../src/constants.ts","../../../../../src/utils/get-token-pool-infos.ts","../../../../../src/utils/select-input-accounts.ts","../../../../../src/utils/pack-compressed-token-accounts.ts","../../../../../src/utils/validation.ts","../../../../../src/layout.ts","../../../../../src/program.ts","../../../../../src/idl.ts","../../../../../src/actions/create-token-pool.ts","../../../../../src/actions/approve.ts","../../../../../src/actions/approve-and-mint-to.ts","../../../../../src/actions/compress.ts","../../../../../src/actions/compress-spl-token-account.ts","../../../../../src/actions/create-mint.ts","../../../../../src/actions/create-token-program-lookup-table.ts","../../../../../src/actions/decompress.ts","../../../../../src/actions/decompress-delegated.ts","../../../../../src/types.ts","../../../../../src/actions/merge-token-accounts.ts","../../../../../src/actions/mint-to.ts","../../../../../src/actions/revoke.ts","../../../../../src/actions/transfer.ts","../../../../../src/actions/transfer-delegated.ts"],"sourcesContent":["import { Buffer } from 'buffer';\nexport const POOL_SEED = Buffer.from('pool');\n\nexport const CPI_AUTHORITY_SEED = Buffer.from('cpi_authority');\n\nexport const SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE = 1461600;\n\nexport const CREATE_TOKEN_POOL_DISCRIMINATOR = Buffer.from([\n 23, 169, 27, 122, 147, 169, 209, 152,\n]);\nexport const MINT_TO_DISCRIMINATOR = Buffer.from([\n 241, 34, 48, 186, 37, 179, 123, 192,\n]);\nexport const BATCH_COMPRESS_DISCRIMINATOR = Buffer.from([\n 65, 206, 101, 37, 147, 42, 221, 144,\n]);\nexport const TRANSFER_DISCRIMINATOR = Buffer.from([\n 163, 52, 200, 231, 140, 3, 69, 186,\n]);\nexport const COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR = Buffer.from([\n 112, 230, 105, 101, 145, 202, 157, 97,\n]);\n\nexport const APPROVE_DISCRIMINATOR = Buffer.from([\n 69, 74, 217, 36, 115, 117, 97, 76,\n]);\nexport const REVOKE_DISCRIMINATOR = Buffer.from([\n 170, 23, 31, 34, 133, 173, 93, 242,\n]);\nexport const ADD_TOKEN_POOL_DISCRIMINATOR = Buffer.from([\n 114, 143, 210, 73, 96, 115, 1, 228,\n]);\n","import { Commitment, PublicKey } from '@solana/web3.js';\nimport { unpackAccount } from '@solana/spl-token';\nimport { CompressedTokenProgram } from '../program';\nimport { bn, Rpc } from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\n\n/**\n * Check if the token pool info is initialized and has a balance.\n * @param mint The mint of the token pool\n * @param tokenPoolInfo The token pool info\n * @returns True if the token pool info is initialized and has a balance\n */\nexport function checkTokenPoolInfo(\n tokenPoolInfo: TokenPoolInfo,\n mint: PublicKey,\n): boolean {\n if (!tokenPoolInfo.mint.equals(mint)) {\n throw new Error(`TokenPool mint does not match the provided mint.`);\n }\n\n if (!tokenPoolInfo.isInitialized) {\n throw new Error(\n `TokenPool is not initialized. Please create a compressed token pool for mint: ${mint.toBase58()} via createTokenPool().`,\n );\n }\n return true;\n}\n\n/**\n * Get the token pool infos for a given mint.\n * @param rpc The RPC client\n * @param mint The mint of the token pool\n * @param commitment The commitment to use\n *\n * @returns The token pool infos\n */\nexport async function getTokenPoolInfos(\n rpc: Rpc,\n mint: PublicKey,\n commitment?: Commitment,\n): Promise<TokenPoolInfo[]> {\n const addressesAndBumps = Array.from({ length: 5 }, (_, i) =>\n CompressedTokenProgram.deriveTokenPoolPdaWithIndex(mint, i),\n );\n\n const accountInfos = await rpc.getMultipleAccountsInfo(\n addressesAndBumps.map(addressAndBump => addressAndBump[0]),\n commitment,\n );\n\n if (accountInfos[0] === null) {\n throw new Error(\n `TokenPool not found. Please create a compressed token pool for mint: ${mint.toBase58()} via createTokenPool().`,\n );\n }\n\n const parsedInfos = addressesAndBumps.map((addressAndBump, i) =>\n accountInfos[i]\n ? unpackAccount(\n addressAndBump[0],\n accountInfos[i],\n accountInfos[i].owner,\n )\n : null,\n );\n\n const tokenProgram = accountInfos[0].owner;\n return parsedInfos.map((parsedInfo, i) => {\n if (!parsedInfo) {\n return {\n mint,\n tokenPoolPda: addressesAndBumps[i][0],\n tokenProgram,\n activity: undefined,\n balance: bn(0),\n isInitialized: false,\n poolIndex: i,\n bump: addressesAndBumps[i][1],\n };\n }\n\n return {\n mint,\n tokenPoolPda: parsedInfo.address,\n tokenProgram,\n activity: undefined,\n balance: bn(parsedInfo.amount.toString()),\n isInitialized: true,\n poolIndex: i,\n bump: addressesAndBumps[i][1],\n };\n });\n}\n\nexport type TokenPoolActivity = {\n signature: string;\n amount: BN;\n action: Action;\n};\n\n/**\n * Token pool pda info.\n */\nexport type TokenPoolInfo = {\n /**\n * The mint of the token pool\n */\n mint: PublicKey;\n /**\n * The token pool address\n */\n tokenPoolPda: PublicKey;\n /**\n * The token program of the token pool\n */\n tokenProgram: PublicKey;\n /**\n * count of txs and volume in the past 60 seconds.\n */\n activity?: {\n txs: number;\n amountAdded: BN;\n amountRemoved: BN;\n };\n /**\n * Whether the token pool is initialized\n */\n isInitialized: boolean;\n /**\n * The balance of the token pool\n */\n balance: BN;\n /**\n * The index of the token pool\n */\n poolIndex: number;\n /**\n * The bump used to derive the token pool pda\n */\n bump: number;\n};\n\n/**\n * @internal\n */\nexport enum Action {\n Compress = 1,\n Decompress = 2,\n Transfer = 3,\n}\n\n/**\n * @internal\n */\nconst shuffleArray = <T>(array: T[]): T[] => {\n for (let i = array.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [array[i], array[j]] = [array[j], array[i]];\n }\n return array;\n};\n\n/**\n * For `compress` and `mintTo` instructions only.\n * Select a random token pool info from the token pool infos.\n *\n * For `decompress`, use {@link selectTokenPoolInfosForDecompression} instead.\n *\n * @param infos The token pool infos\n *\n * @returns A random token pool info\n */\nexport function selectTokenPoolInfo(infos: TokenPoolInfo[]): TokenPoolInfo {\n const shuffledInfos = shuffleArray(infos);\n\n // filter only infos that are initialized\n const filteredInfos = shuffledInfos.filter(info => info.isInitialized);\n\n if (filteredInfos.length === 0) {\n throw new Error(\n 'Please pass at least one initialized token pool info.',\n );\n }\n\n // Return a single random token pool info\n return filteredInfos[0];\n}\n\n/**\n * Select one or multiple token pool infos from the token pool infos.\n *\n * Use this function for `decompress`.\n *\n * For `compress`, `mintTo` use {@link selectTokenPoolInfo} instead.\n *\n * @param infos The token pool infos\n * @param decompressAmount The amount of tokens to withdraw\n *\n * @returns Array with one or more token pool infos.\n */\nexport function selectTokenPoolInfosForDecompression(\n infos: TokenPoolInfo[],\n decompressAmount: number | BN,\n): TokenPoolInfo[] {\n if (infos.length === 0) {\n throw new Error('Please pass at least one token pool info.');\n }\n\n infos = shuffleArray(infos);\n // Find the first info where balance is 10x the requested amount\n const sufficientBalanceInfo = infos.find(info =>\n info.balance.gte(bn(decompressAmount).mul(bn(10))),\n );\n\n // filter only infos that are initialized\n infos = infos\n .filter(info => info.isInitialized)\n .sort((a, b) => a.poolIndex - b.poolIndex);\n\n const allBalancesZero = infos.every(info => info.balance.isZero());\n if (allBalancesZero) {\n throw new Error(\n 'All provided token pool balances are zero. Please pass recent token pool infos.',\n );\n }\n\n // If none found, return all infos\n return sufficientBalanceInfo ? [sufficientBalanceInfo] : infos;\n}\n","import { bn, ParsedTokenAccount } from '@lightprotocol/stateless.js';\n\nimport BN from 'bn.js';\n\nexport const ERROR_NO_ACCOUNTS_FOUND =\n 'Could not find accounts to select for transfer.';\n\n/**\n * Selects token accounts for approval, first trying to find an exact match, then falling back to minimum selection.\n *\n * @param {ParsedTokenAccount[]} accounts - Token accounts to choose from.\n * @param {BN} approveAmount - Amount to approve.\n * @param {number} [maxInputs=4] - Max accounts to select when falling back to minimum selection.\n * @returns {[\n * selectedAccounts: ParsedTokenAccount[],\n * total: BN,\n * totalLamports: BN | null,\n * maxPossibleAmount: BN\n * ]} - Returns:\n * - selectedAccounts: Accounts chosen for approval.\n * - total: Total amount from selected accounts.\n * - totalLamports: Total lamports from selected accounts.\n * - maxPossibleAmount: Max approvable amount given maxInputs.\n */\nexport function selectTokenAccountsForApprove(\n accounts: ParsedTokenAccount[],\n approveAmount: BN,\n maxInputs: number = 4,\n): [\n selectedAccounts: ParsedTokenAccount[],\n total: BN,\n totalLamports: BN | null,\n maxPossibleAmount: BN,\n] {\n // First try to find an exact match\n const exactMatch = accounts.find(account =>\n account.parsed.amount.eq(approveAmount),\n );\n if (exactMatch) {\n return [\n [exactMatch],\n exactMatch.parsed.amount,\n exactMatch.compressedAccount.lamports,\n exactMatch.parsed.amount,\n ];\n }\n\n // If no exact match, fall back to minimum selection\n return selectMinCompressedTokenAccountsForTransfer(\n accounts,\n approveAmount,\n maxInputs,\n );\n}\n\n/**\n * Selects the minimum number of compressed token accounts required for a\n * decompress instruction, up to a specified maximum.\n *\n * @param {ParsedTokenAccount[]} accounts Token accounts to choose from.\n * @param {BN} amount Amount to decompress.\n * @param {number} [maxInputs=4] Max accounts to select. Default\n * is 4.\n *\n * @returns Returns selected accounts and their totals.\n */\nexport function selectMinCompressedTokenAccountsForDecompression(\n accounts: ParsedTokenAccount[],\n amount: BN,\n maxInputs: number = 4,\n): {\n selectedAccounts: ParsedTokenAccount[];\n total: BN;\n totalLamports: BN | null;\n maxPossibleAmount: BN;\n} {\n const [selectedAccounts, total, totalLamports, maxPossibleAmount] =\n selectMinCompressedTokenAccountsForTransfer(\n accounts,\n amount,\n maxInputs,\n );\n return { selectedAccounts, total, totalLamports, maxPossibleAmount };\n}\n\n/**\n * Selects the minimum number of compressed token accounts required for a\n * transfer or decompression instruction, up to a specified maximum.\n *\n * @param {ParsedTokenAccount[]} accounts Token accounts to choose from.\n * @param {BN} transferAmount Amount to transfer or decompress.\n * @param {number} [maxInputs=4] Max accounts to select. Default\n * is 4.\n *\n * @returns Returns selected accounts and their totals. [\n * selectedAccounts: ParsedTokenAccount[],\n * total: BN,\n * totalLamports: BN | null,\n * maxPossibleAmount: BN\n * ]\n */\nexport function selectMinCompressedTokenAccountsForTransfer(\n accounts: ParsedTokenAccount[],\n transferAmount: BN,\n maxInputs: number = 4,\n): [\n selectedAccounts: ParsedTokenAccount[],\n total: BN,\n totalLamports: BN | null,\n maxPossibleAmount: BN,\n] {\n const [\n selectedAccounts,\n accumulatedAmount,\n accumulatedLamports,\n maxPossibleAmount,\n ] = selectMinCompressedTokenAccountsForTransferOrPartial(\n accounts,\n transferAmount,\n maxInputs,\n );\n\n if (accumulatedAmount.lt(bn(transferAmount))) {\n const totalBalance = accounts.reduce(\n (acc, account) => acc.add(account.parsed.amount),\n bn(0),\n );\n if (selectedAccounts.length >= maxInputs) {\n throw new Error(\n `Account limit exceeded: max ${maxPossibleAmount.toString()} (${maxInputs} accounts) per transaction. Total balance: ${totalBalance.toString()} (${accounts.length} accounts). Consider multiple transfers to spend full balance.`,\n );\n } else {\n throw new Error(\n `Insufficient balance for transfer. Required: ${transferAmount.toString()}, available: ${totalBalance.toString()}.`,\n );\n }\n }\n\n if (selectedAccounts.length === 0) {\n throw new Error(ERROR_NO_ACCOUNTS_FOUND);\n }\n\n return [\n selectedAccounts,\n accumulatedAmount,\n accumulatedLamports,\n maxPossibleAmount,\n ];\n}\n\n/**\n * Executes {@link selectMinCompressedTokenAccountsForTransfer} strategy,\n * returns partial amounts if insufficient accounts are found instead of\n * throwing an error.\n */\nexport function selectMinCompressedTokenAccountsForTransferOrPartial(\n accounts: ParsedTokenAccount[],\n transferAmount: BN,\n maxInputs: number = 4,\n): [\n selectedAccounts: ParsedTokenAccount[],\n total: BN,\n totalLamports: BN | null,\n maxPossibleAmount: BN,\n] {\n if (accounts.length === 0) {\n throw new Error(ERROR_NO_ACCOUNTS_FOUND);\n }\n\n let accumulatedAmount = bn(0);\n let accumulatedLamports = bn(0);\n let maxPossibleAmount = bn(0);\n\n const selectedAccounts: ParsedTokenAccount[] = [];\n\n accounts.sort((a, b) => b.parsed.amount.cmp(a.parsed.amount));\n\n for (const account of accounts) {\n if (selectedAccounts.length >= maxInputs) break;\n if (accumulatedAmount.gte(bn(transferAmount))) break;\n\n if (\n !account.parsed.amount.isZero() ||\n !account.compressedAccount.lamports.isZero()\n ) {\n accumulatedAmount = accumulatedAmount.add(account.parsed.amount);\n accumulatedLamports = accumulatedLamports.add(\n account.compressedAccount.lamports,\n );\n selectedAccounts.push(account);\n }\n }\n\n // Max, considering maxInputs\n maxPossibleAmount = accounts\n .slice(0, maxInputs)\n .reduce((total, account) => total.add(account.parsed.amount), bn(0));\n\n if (accumulatedAmount.lt(bn(transferAmount))) {\n console.log(\n `Insufficient balance for transfer. Requested: ${transferAmount.toString()}, Returns max available: ${maxPossibleAmount.toString()}.`,\n );\n }\n\n if (selectedAccounts.length === 0) {\n throw new Error(ERROR_NO_ACCOUNTS_FOUND);\n }\n\n return [\n selectedAccounts,\n accumulatedAmount,\n accumulatedLamports,\n maxPossibleAmount,\n ];\n}\n\n/**\n * Selects compressed token accounts for a transfer, ensuring one extra account\n * if possible, up to maxInputs.\n *\n * 1. Sorts accounts by amount (desc)\n * 2. Selects accounts until transfer amount is met or maxInputs is reached,\n * attempting to add one extra account if possible.\n *\n * @param {ParsedTokenAccount[]} accounts - The list of token accounts to select from.\n * @param {BN} transferAmount - The token amount to be transferred.\n * @param {number} [maxInputs=4] - The maximum number of accounts to select. Default: 4.\n * @returns {[\n * selectedAccounts: ParsedTokenAccount[],\n * total: BN,\n * totalLamports: BN | null,\n * maxPossibleAmount: BN\n * ]} - An array containing:\n * - selectedAccounts: The accounts selected for the transfer.\n * - total: The total amount accumulated from the selected accounts.\n * - totalLamports: The total lamports accumulated from the selected accounts.\n * - maxPossibleAmount: The maximum possible amount that can be transferred considering maxInputs.\n *\n * @example\n * const accounts = [\n * { parsed: { amount: new BN(100) }, compressedAccount: { lamports: new BN(10) } },\n * { parsed: { amount: new BN(50) }, compressedAccount: { lamports: new BN(5) } },\n * { parsed: { amount: new BN(25) }, compressedAccount: { lamports: new BN(2) } },\n * ];\n * const transferAmount = new BN(75);\n * const maxInputs = 2;\n *\n * const [selectedAccounts, total, totalLamports, maxPossibleAmount] =\n * selectSmartCompressedTokenAccountsForTransfer(accounts, transferAmount, maxInputs);\n *\n * console.log(selectedAccounts.length); // 2\n * console.log(total.toString()); // '150'\n * console.log(totalLamports!.toString()); // '15'\n * console.log(maxPossibleAmount.toString()); // '150'\n */\nexport function selectSmartCompressedTokenAccountsForTransfer(\n accounts: ParsedTokenAccount[],\n transferAmount: BN,\n maxInputs: number = 4,\n): [\n selectedAccounts: ParsedTokenAccount[],\n total: BN,\n totalLamports: BN | null,\n maxPossibleAmount: BN,\n] {\n const [\n selectedAccounts,\n accumulatedAmount,\n accumulatedLamports,\n maxPossibleAmount,\n ] = selectSmartCompressedTokenAccountsForTransferOrPartial(\n accounts,\n transferAmount,\n maxInputs,\n );\n\n if (accumulatedAmount.lt(bn(transferAmount))) {\n const totalBalance = accounts.reduce(\n (acc, account) => acc.add(account.parsed.amount),\n bn(0),\n );\n if (selectedAccounts.length >= maxInputs) {\n throw new Error(\n `Account limit exceeded: max ${maxPossibleAmount.toString()} (${maxInputs} accounts) per transaction. Total balance: ${totalBalance.toString()} (${accounts.length} accounts). Consider multiple transfers to spend full balance.`,\n );\n } else {\n throw new Error(\n `Insufficient balance. Required: ${transferAmount.toString()}, available: ${totalBalance.toString()}.`,\n );\n }\n }\n\n if (selectedAccounts.length === 0) {\n throw new Error(ERROR_NO_ACCOUNTS_FOUND);\n }\n\n return [\n selectedAccounts,\n accumulatedAmount,\n accumulatedLamports,\n maxPossibleAmount,\n ];\n}\n\n/**\n * Executes {@link selectMinCompressedTokenAccountsForTransfer} strategy,\n * returns partial amounts if insufficient accounts are found instead of\n * throwing an error.\n */\nexport function selectSmartCompressedTokenAccountsForTransferOrPartial(\n accounts: ParsedTokenAccount[],\n transferAmount: BN,\n maxInputs: number = 4,\n): [\n selectedAccounts: ParsedTokenAccount[],\n total: BN,\n totalLamports: BN | null,\n maxPossibleAmount: BN,\n] {\n if (accounts.length === 0) {\n throw new Error(ERROR_NO_ACCOUNTS_FOUND);\n }\n\n let accumulatedAmount = bn(0);\n let accumulatedLamports = bn(0);\n\n const selectedAccounts: ParsedTokenAccount[] = [];\n\n // we can ignore zero value accounts.\n const nonZeroAccounts = accounts.filter(\n account =>\n !account.parsed.amount.isZero() ||\n !account.compressedAccount.lamports.isZero(),\n );\n\n nonZeroAccounts.sort((a, b) => b.parsed.amount.cmp(a.parsed.amount));\n\n for (const account of nonZeroAccounts) {\n if (selectedAccounts.length >= maxInputs) break;\n accumulatedAmount = accumulatedAmount.add(account.parsed.amount);\n accumulatedLamports = accumulatedLamports.add(\n account.compressedAccount.lamports,\n );\n selectedAccounts.push(account);\n\n if (accumulatedAmount.gte(bn(transferAmount))) {\n // Select smallest additional account if maxInputs not reached\n const remainingAccounts = nonZeroAccounts.slice(\n selectedAccounts.length,\n );\n if (remainingAccounts.length > 0) {\n const smallestAccount = remainingAccounts.reduce((min, acc) =>\n acc.parsed.amount.lt(min.parsed.amount) ? acc : min,\n );\n if (selectedAccounts.length < maxInputs) {\n selectedAccounts.push(smallestAccount);\n accumulatedAmount = accumulatedAmount.add(\n smallestAccount.parsed.amount,\n );\n accumulatedLamports = accumulatedLamports.add(\n smallestAccount.compressedAccount.lamports,\n );\n }\n }\n break;\n }\n }\n\n const maxPossibleAmount = nonZeroAccounts\n .slice(0, maxInputs)\n .reduce((max, account) => max.add(account.parsed.amount), bn(0));\n\n if (selectedAccounts.length === 0) {\n throw new Error(ERROR_NO_ACCOUNTS_FOUND);\n }\n\n return [\n selectedAccounts,\n accumulatedAmount,\n accumulatedLamports,\n maxPossibleAmount,\n ];\n}\n","import {\n ParsedTokenAccount,\n InputTokenDataWithContext,\n getIndexOrAdd,\n bn,\n padOutputStateMerkleTrees,\n TreeType,\n featureFlags,\n TreeInfo,\n} from '@lightprotocol/stateless.js';\nimport { PublicKey, AccountMeta } from '@solana/web3.js';\nimport {\n PackedTokenTransferOutputData,\n TokenTransferOutputData,\n} from '../types';\n\nexport type PackCompressedTokenAccountsParams = {\n /** Input state to be consumed */\n inputCompressedTokenAccounts: ParsedTokenAccount[];\n /**\n * State trees that the output should be inserted into. Defaults to the 0th\n * state tree of the input state. Gets padded to the length of\n * outputCompressedAccounts.\n */\n outputStateTreeInfo?: TreeInfo;\n /** Optional remaining accounts to append to */\n remainingAccounts?: PublicKey[];\n /**\n * Root indices that are used on-chain to fetch the correct root\n * from the state Merkle tree account for validity proof verification.\n */\n rootIndices: number[];\n tokenTransferOutputs: TokenTransferOutputData[];\n};\n\n/**\n * Packs Compressed Token Accounts.\n */\nexport function packCompressedTokenAccounts(\n params: PackCompressedTokenAccountsParams,\n): {\n inputTokenDataWithContext: InputTokenDataWithContext[];\n remainingAccountMetas: AccountMeta[];\n packedOutputTokenData: PackedTokenTransferOutputData[];\n} {\n const {\n inputCompressedTokenAccounts,\n outputStateTreeInfo,\n remainingAccounts = [],\n rootIndices,\n tokenTransferOutputs,\n } = params;\n\n const _remainingAccounts = remainingAccounts.slice();\n let delegateIndex: number | null = null;\n\n if (\n inputCompressedTokenAccounts.length > 0 &&\n inputCompressedTokenAccounts[0].parsed.delegate\n ) {\n delegateIndex = getIndexOrAdd(\n _remainingAccounts,\n inputCompressedTokenAccounts[0].parsed.delegate,\n );\n }\n\n const packedInputTokenData: InputTokenDataWithContext[] = [];\n /// pack inputs\n inputCompressedTokenAccounts.forEach(\n (account: ParsedTokenAccount, index) => {\n const merkleTreePubkeyIndex = getIndexOrAdd(\n _remainingAccounts,\n account.compressedAccount.treeInfo.tree,\n );\n\n const queuePubkeyIndex = getIndexOrAdd(\n _remainingAccounts,\n account.compressedAccount.treeInfo.queue,\n );\n\n packedInputTokenData.push({\n amount: account.parsed.amount,\n delegateIndex,\n merkleContext: {\n merkleTreePubkeyIndex,\n queuePubkeyIndex,\n leafIndex: account.compressedAccount.leafIndex,\n proveByIndex: account.compressedAccount.proveByIndex,\n },\n rootIndex: rootIndices[index],\n lamports: account.compressedAccount.lamports.eq(bn(0))\n ? null\n : account.compressedAccount.lamports,\n tlv: null,\n });\n },\n );\n\n if (inputCompressedTokenAccounts.length > 0 && outputStateTreeInfo) {\n throw new Error(\n 'Cannot specify both input accounts and outputStateTreeInfo',\n );\n }\n\n let treeInfo: TreeInfo;\n if (inputCompressedTokenAccounts.length > 0) {\n treeInfo = inputCompressedTokenAccounts[0].compressedAccount.treeInfo;\n } else if (outputStateTreeInfo) {\n treeInfo = outputStateTreeInfo;\n } else {\n throw new Error(\n 'Neither input accounts nor outputStateTreeInfo are available',\n );\n }\n\n // Use next tree if available, otherwise fall back to current tree.\n // `nextTreeInfo` always takes precedence.\n const activeTreeInfo = treeInfo.nextTreeInfo || treeInfo;\n let activeTreeOrQueue = activeTreeInfo.tree;\n\n if (activeTreeInfo.treeType === TreeType.StateV2) {\n if (featureFlags.isV2()) {\n activeTreeOrQueue = activeTreeInfo.queue;\n } else throw new Error('V2 trees are not supported yet');\n }\n\n // Pack output state trees\n const paddedOutputStateMerkleTrees = padOutputStateMerkleTrees(\n activeTreeOrQueue,\n tokenTransferOutputs.length,\n );\n const packedOutputTokenData: PackedTokenTransferOutputData[] = [];\n paddedOutputStateMerkleTrees.forEach((account, index) => {\n const merkleTreeIndex = getIndexOrAdd(_remainingAccounts, account);\n packedOutputTokenData.push({\n owner: tokenTransferOutputs[index].owner,\n amount: tokenTransferOutputs[index].amount,\n lamports: tokenTransferOutputs[index].lamports?.eq(bn(0))\n ? null\n : tokenTransferOutputs[index].lamports,\n merkleTreeIndex,\n tlv: null,\n });\n });\n // to meta\n const remainingAccountMetas = _remainingAccounts.map(\n (account): AccountMeta => ({\n pubkey: account,\n isWritable: true,\n isSigner: false,\n }),\n );\n\n return {\n inputTokenDataWithContext: packedInputTokenData,\n remainingAccountMetas,\n packedOutputTokenData,\n };\n}\n","import { ParsedTokenAccount } from '@lightprotocol/stateless.js';\nimport { PublicKey } from '@solana/web3.js';\n\n/**\n * Check if all input accounts belong to the same mint.\n *\n * @param compressedTokenAccounts The compressed token accounts\n * @param mint The mint of the token pool\n * @returns True if all input accounts belong to the same mint\n */\nexport function checkMint(\n compressedTokenAccounts: ParsedTokenAccount[],\n mint: PublicKey,\n): boolean {\n if (\n !compressedTokenAccounts.every(account =>\n account.parsed.mint.equals(mint),\n )\n ) {\n throw new Error(`All input accounts must belong to the same mint`);\n }\n\n return true;\n}\n","import {\n struct,\n option,\n vec,\n bool,\n u64,\n u8,\n publicKey,\n array,\n u32,\n u16,\n vecU8,\n} from '@coral-xyz/borsh';\nimport { AccountMeta, PublicKey } from '@solana/web3.js';\nimport { CompressedTokenProgram } from './program';\nimport {\n BatchCompressInstructionData,\n CompressedTokenInstructionDataApprove,\n CompressedTokenInstructionDataRevoke,\n CompressedTokenInstructionDataTransfer,\n CompressSplTokenAccountInstructionData,\n MintToInstructionData,\n} from './types';\nimport {\n APPROVE_DISCRIMINATOR,\n BATCH_COMPRESS_DISCRIMINATOR,\n COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR,\n MINT_TO_DISCRIMINATOR,\n REVOKE_DISCRIMINATOR,\n TRANSFER_DISCRIMINATOR,\n} from './constants';\nimport { Buffer } from 'buffer';\nimport { ValidityProof } from '@lightprotocol/stateless.js';\n\nconst CompressedProofLayout = struct([\n array(u8(), 32, 'a'),\n array(u8(), 64, 'b'),\n array(u8(), 32, 'c'),\n]);\n\nconst PackedTokenTransferOutputDataLayout = struct([\n publicKey('owner'),\n u64('amount'),\n option(u64(), 'lamports'),\n u8('merkleTreeIndex'),\n option(vecU8(), 'tlv'),\n]);\n\nconst InputTokenDataWithContextLayout = struct([\n u64('amount'),\n option(u8(), 'delegateIndex'),\n struct(\n [\n u8('merkleTreePubkeyIndex'),\n u8('queuePubkeyIndex'),\n u32('leafIndex'),\n bool('proveByIndex'),\n ],\n 'merkleContext',\n ),\n u16('rootIndex'),\n option(u64(), 'lamports'),\n option(vecU8(), 'tlv'),\n]);\n\nexport const DelegatedTransferLayout = struct([\n publicKey('owner'),\n option(u8(), 'delegateChangeAccountIndex'),\n]);\n\nexport const CpiContextLayout = struct([\n bool('setContext'),\n bool('firstSetContext'),\n u8('cpiContextAccountIndex'),\n]);\n\nexport const CompressedTokenInstructionDataTransferLayout = struct([\n option(CompressedProofLayout, 'proof'),\n publicKey('mint'),\n option(DelegatedTransferLayout, 'delegatedTransfer'),\n vec(InputTokenDataWithContextLayout, 'inputTokenDataWithContext'),\n vec(PackedTokenTransferOutputDataLayout, 'outputCompressedAccounts'),\n bool('isCompress'),\n option(u64(), 'compressOrDecompressAmount'),\n option(CpiContextLayout, 'cpiContext'),\n option(u8(), 'lamportsChangeAccountMerkleTreeIndex'),\n]);\n\nexport const mintToLayout = struct([\n vec(publicKey(), 'recipients'),\n vec(u64(), 'amounts'),\n option(u64(), 'lamports'),\n]);\n\nexport const batchCompressLayout = struct([\n vec(publicKey(), 'pubkeys'),\n option(vec(u64(), 'amounts'), 'amounts'),\n option(u64(), 'lamports'),\n option(u64(), 'amount'),\n u8('index'),\n u8('bump'),\n]);\n\nexport const compressSplTokenAccountInstructionDataLayout = struct([\n publicKey('owner'),\n option(u64(), 'remainingAmount'),\n option(CpiContextLayout, 'cpiContext'),\n]);\n\nexport function encodeMintToInstructionData(\n data: MintToInstructionData,\n): Buffer {\n const buffer = Buffer.alloc(1000);\n const len = mintToLayout.encode(\n {\n recipients: data.recipients,\n amounts: data.amounts,\n lamports: data.lamports,\n },\n buffer,\n );\n\n return Buffer.concat([\n new Uint8Array(MINT_TO_DISCRIMINATOR),\n new Uint8Array(buffer.subarray(0, len)),\n ]);\n}\n\nexport function decodeMintToInstructionData(\n buffer: Buffer,\n): MintToInstructionData {\n return mintToLayout.decode(\n buffer.subarray(MINT_TO_DISCRIMINATOR.length),\n ) as MintToInstructionData;\n}\n\nexport function encodeBatchCompressInstructionData(\n data: BatchCompressInstructionData,\n): Buffer {\n const buffer = Buffer.alloc(1000);\n const len = batchCompressLayout.encode(data, buffer);\n\n const lengthBuffer = Buffer.alloc(4);\n lengthBuffer.writeUInt32LE(len, 0);\n\n const dataBuffer = buffer.subarray(0, len);\n return Buffer.concat([\n new Uint8Array(BATCH_COMPRESS_DISCRIMINATOR),\n new Uint8Array(lengthBuffer),\n new Uint8Array(dataBuffer),\n ]);\n}\n\nexport function decodeBatchCompressInstructionData(\n buffer: Buffer,\n): BatchCompressInstructionData {\n return batchCompressLayout.decode(\n buffer.subarray(BATCH_COMPRESS_DISCRIMINATOR.length + 4),\n ) as BatchCompressInstructionData;\n}\n\nexport function encodeCompressSplTokenAccountInstructionData(\n data: CompressSplTokenAccountInstructionData,\n): Buffer {\n const buffer = Buffer.alloc(1000);\n const len = compressSplTokenAccountInstructionDataLayout.encode(\n {\n owner: data.owner,\n remainingAmount: data.remainingAmount,\n cpiContext: data.cpiContext,\n },\n buffer,\n );\n\n return Buffer.concat([\n new Uint8Array(COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR),\n new Uint8Array(buffer.subarray(0, len)),\n ]);\n}\n\nexport function decodeCompressSplTokenAccountInstructionData(\n buffer: Buffer,\n): CompressSplTokenAccountInstructionData {\n const data = compressSplTokenAccountInstructionDataLayout.decode(\n buffer.subarray(COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR.length),\n ) as CompressSplTokenAccountInstructionData;\n return {\n owner: data.owner,\n remainingAmount: data.remainingAmount,\n cpiContext: data.cpiContext,\n };\n}\nexport function encodeTransferInstructionData(\n data: CompressedTokenInstructionDataTransfer,\n): Buffer {\n const buffer = Buffer.alloc(1000);\n\n const len = CompressedTokenInstructionDataTransferLayout.encode(\n data,\n buffer,\n );\n\n const lengthBuffer = Buffer.alloc(4);\n lengthBuffer.writeUInt32LE(len, 0);\n\n const dataBuffer = buffer.subarray(0, len);\n\n return Buffer.concat([\n new Uint8Array(TRANSFER_DISCRIMINATOR),\n new Uint8Array(lengthBuffer),\n new Uint8Array(dataBuffer),\n ]);\n}\n\nexport function decodeTransferInstructionData(\n buffer: Buffer,\n): CompressedTokenInstructionDataTransfer {\n return CompressedTokenInstructionDataTransferLayout.decode(\n buffer.slice(TRANSFER_DISCRIMINATOR.length + 4),\n ) as CompressedTokenInstructionDataTransfer;\n}\n\ninterface BaseAccountsLayoutParams {\n feePayer: PublicKey;\n authority: PublicKey;\n cpiAuthorityPda: PublicKey;\n lightSystemProgram: PublicKey;\n registeredProgramPda: PublicKey;\n noopProgram: PublicKey;\n accountCompressionAuthority: PublicKey;\n accountCompressionProgram: PublicKey;\n selfProgram: PublicKey;\n systemProgram: PublicKey;\n}\nexport type createTokenPoolAccountsLayoutParams = {\n feePayer: PublicKey;\n tokenPoolPda: PublicKey;\n systemProgram: PublicKey;\n mint: PublicKey;\n tokenProgram: PublicKey;\n cpiAuthorityPda: PublicKey;\n};\n\nexport type addTokenPoolAccountsLayoutParams =\n createTokenPoolAccountsLayoutParams & {\n existingTokenPoolPda: PublicKey;\n };\n\nexport type mintToAccountsLayoutParams = BaseAccountsLayoutParams & {\n mint: PublicKey;\n tokenPoolPda: PublicKey;\n tokenProgram: PublicKey;\n merkleTree: PublicKey;\n solPoolPda: PublicKey | null;\n};\nexport type transferAccountsLayoutParams = BaseAccountsLayoutParams & {\n tokenPoolPda?: PublicKey;\n compressOrDecompressTokenAccount?: PublicKey;\n tokenProgram?: PublicKey;\n};\nexport type approveAccountsLayoutParams = BaseAccountsLayoutParams;\nexport type revokeAccountsLayoutParams = approveAccountsLayoutParams;\nexport type freezeAccountsLayoutParams = BaseAccountsLayoutParams & {\n mint: PublicKey;\n};\nexport type thawAccountsLayoutParams = freezeAccountsLayoutParams;\n\nexport const createTokenPoolAccountsLayout = (\n accounts: createTokenPoolAccountsLayoutParams,\n): AccountMeta[] => {\n const {\n feePayer,\n tokenPoolPda,\n systemProgram,\n mint,\n tokenProgram,\n cpiAuthorityPda,\n } = accounts;\n return [\n { pubkey: feePayer, isSigner: true, isWritable: true },\n { pubkey: tokenPoolPda, isSigner: false, isWritable: true },\n { pubkey: systemProgram, isSigner: false, isWritable: false },\n { pubkey: mint, isSigner: false, isWritable: true },\n { pubkey: tokenProgram, isSigner: false, isWritable: false },\n { pubkey: cpiAuthorityPda, isSigner: false, isWritable: false },\n ];\n};\n\nexport const addTokenPoolAccountsLayout = (\n accounts: addTokenPoolAccountsLayoutParams,\n): AccountMeta[] => {\n const {\n feePayer,\n tokenPoolPda,\n systemProgram,\n mint,\n tokenProgram,\n cpiAuthorityPda,\n existingTokenPoolPda,\n } = accounts;\n return [\n { pubkey: feePayer, isSigner: true, isWritable: true },\n { pubkey: tokenPoolPda, isSigner: false, isWritable: true },\n { pubkey: existingTokenPoolPda, isSigner: false, isWritable: false },\n { pubkey: systemProgram, isSigner: false, isWritable: false },\n { pubkey: mint, isSigner: false, isWritable: true },\n { pubkey: tokenProgram, isSigner: false, isWritable: false },\n { pubkey: cpiAuthorityPda, isSigner: false, isWritable: false },\n ];\n};\n\nexport const mintToAccountsLayout = (\n accounts: mintToAccountsLayoutParams,\n): AccountMeta[] => {\n const defaultPubkey = CompressedTokenProgram.programId;\n const {\n feePayer,\n authority,\n cpiAuthorityPda,\n mint,\n tokenPoolPda,\n tokenProgram,\n lightSystemProgram,\n registeredProgramPda,\n noopProgram,\n accountCompressionAuthority,\n accountCompressionProgram,\n merkleTree,\n selfProgram,\n systemProgram,\n solPoolPda,\n } = accounts;\n\n const accountsList: AccountMeta[] = [\n { pubkey: feePayer, isSigner: true, isWritable: true },\n { pubkey: authority, isSigner: true, isWritable: false },\n { pubkey: cpiAuthorityPda, isSigner: false, isWritable: false },\n { pubkey: mint, isSigner: false, isWritable: true },\n { pubkey: tokenPoolPda, isSigner: false, isWritable: true },\n { pubkey: tokenProgram, isSigner: false, isWritable: false },\n { pubkey: lightSystemProgram, isSigner: false, isWritable: false },\n { pubkey: registeredProgramPda, isSigner: false, isWritable: false },\n { pubkey: noopProgram, isSigner: false, isWritable: false },\n {\n pubkey: accountCompressionAuthority,\n isSigner: false,\n isWritable: false,\n },\n {\n pubkey: accountCompressionProgram,\n isSigner: false,\n isWritable: false,\n },\n { pubkey: merkleTree, isSigner: false, isWritable: true },\n { pubkey: selfProgram, isSigner: false, isWritable: false },\n { pubkey: systemProgram, isSigner: false, isWritable: false },\n {\n pubkey: solPoolPda ?? defaultPubkey,\n isSigner: false,\n isWritable: true,\n },\n ];\n\n return accountsList;\n};\n\nexport const transferAccountsLayout = (\n accounts: transferAccountsLayoutParams,\n): AccountMeta[] => {\n const defaultPubkey = CompressedTokenProgram.programId;\n const {\n feePayer,\n authority,\n cpiAuthorityPda,\n lightSystemProgram,\n registeredProgramPda,\n noopProgram,\n accountCompressionAuthority,\n accountCompressionProgram,\n selfProgram,\n tokenPoolPda,\n compressOrDecompressTokenAccount,\n tokenProgram,\n systemProgram,\n } = accounts;\n\n const accountsList: AccountMeta[] = [\n { pubkey: feePayer, isSigner: true, isWritable: true },\n { pubkey: authority, isSigner: true, isWritable: false },\n { pubkey: cpiAuthorityPda, isSigner: false, isWritable: false },\n { pubkey: lightSystemProgram, isSigner: false, isWritable: false },\n { pubkey: registeredProgramPda, isSigner: false, isWritable: false },\n { pubkey: noopProgram, isSigner: false, isWritable: false },\n {\n pubkey: accountCompressionAuthority,\n isSigner: false,\n isWritable: false,\n },\n {\n pubkey: accountCompressionProgram,\n isSigner: false,\n isWritable: false,\n },\n { pubkey: selfProgram, isSigner: false, isWritable: false },\n {\n pubkey: tokenPoolPda ?? defaultPubkey,\n isSigner: false,\n isWritable: true,\n },\n {\n pubkey: compressOrDecompressTokenAccount ?? defaultPubkey,\n isSigner: false,\n isWritable: true,\n },\n {\n pubkey: tokenProgram ?? defaultPubkey,\n isSigner: false,\n isWritable: false,\n },\n { pubkey: systemProgram, isSigner: false, isWritable: false },\n ];\n\n return accountsList;\n};\n\nexport const approveAccountsLayout = (\n accounts: approveAccountsLayoutParams,\n): AccountMeta[] => {\n const {\n feePayer,\n authority,\n cpiAuthorityPda,\n lightSystemProgram,\n registeredProgramPda,\n noopProgram,\n accountCompressionAuthority,\n accountCompressionProgram,\n selfProgram,\n systemProgram,\n } = accounts;\n\n return [\n { pubkey: feePayer, isSigner: true, isWritable: true },\n { pubkey: authority, isSigner: true, isWritable: false },\n { pubkey: cpiAuthorityPda, isSigner: false, isWritable: false },\n { pubkey: lightSystemProgram, isSigner: false, isWritable: false },\n { pubkey: registeredProgramPda, isSigner: false, isWritable: false },\n { pubkey: noopProgram, isSigner: false, isWritable: false },\n {\n pubkey: accountCompressionAuthority,\n isSigner: false,\n isWritable: false,\n },\n {\n pubkey: accountCompressionProgram,\n isSigner: false,\n isWritable: false,\n },\n { pubkey: selfProgram, isSigner: false, isWritable: false },\n { pubkey: systemProgram, isSigner: false, isWritable: false },\n ];\n};\n\nexport const revokeAccountsLayout = approveAccountsLayout;\n\nexport const freezeAccountsLayout = (\n accounts: freezeAccountsLayoutParams,\n): AccountMeta[] => {\n const {\n feePayer,\n authority,\n cpiAuthorityPda,\n lightSystemProgram,\n registeredProgramPda,\n noopProgram,\n accountCompressionAuthority,\n accountCompressionProgram,\n selfProgram,\n systemProgram,\n mint,\n } = accounts;\n\n return [\n { pubkey: feePayer, isSigner: true, isWritable: true },\n { pubkey: authority, isSigner: true, isWritable: false },\n { pubkey: cpiAuthorityPda, isSigner: false, isWritable: false },\n { pubkey: lightSystemProgram, isSigner: false, isWritable: false },\n { pubkey: registeredProgramPda, isSigner: false, isWritable: false },\n { pubkey: noopProgram, isSigner: false, isWritable: false },\n {\n pubkey: accountCompressionAuthority,\n isSigner: false,\n isWritable: false,\n },\n {\n pubkey: accountCompressionProgram,\n isSigner: false,\n isWritable: false,\n },\n { pubkey: selfProgram, isSigner: false, isWritable: false },\n { pubkey: systemProgram, isSigner: false, isWritable: false },\n { pubkey: mint, isSigner: false, isWritable: false },\n ];\n};\n\nexport const thawAccountsLayout = freezeAccountsLayout;\n\nexport const CompressedTokenInstructionDataApproveLayout = struct([\n struct(\n [array(u8(), 32, 'a'), array(u8(), 64, 'b'), array(u8(), 32, 'c')],\n 'proof',\n ),\n publicKey('mint'),\n vec(InputTokenDataWithContextLayout, 'inputTokenDataWithContext'),\n option(CpiContextLayout, 'cpiContext'),\n publicKey('delegate'),\n u64('delegatedAmount'),\n u8('delegateMerkleTreeIndex'),\n u8('changeAccountMerkleTreeIndex'),\n option(u64(), 'delegateLamports'),\n]);\n\nexport const CompressedTokenInstructionDataRevokeLayout = struct([\n struct(\n [array(u8(), 32, 'a'), array(u8(), 64, 'b'), array(u8(), 32, 'c')],\n 'proof',\n ),\n publicKey('mint'),\n vec(InputTokenDataWithContextLayout, 'inputTokenDataWithContext'),\n option(CpiContextLayout, 'cpiContext'),\n u8('outputAccountMerkleTreeIndex'),\n]);\n\n// Approve and revoke instuctions do not support optional proof yet.\nconst emptyProof: ValidityProof = {\n a: new Array(32).fill(0),\n b: new Array(64).fill(0),\n c: new Array(32).fill(0),\n};\n\nfunction isEmptyProof(proof: ValidityProof): boolean {\n return (\n proof.a.every(a => a === 0) &&\n proof.b.every(b => b === 0) &&\n proof.c.every(c => c === 0)\n );\n}\n\nexport function encodeApproveInstructionData(\n data: CompressedTokenInstructionDataApprove,\n): Buffer {\n const buffer = Buffer.alloc(1000);\n\n const proofOption = data.proof ?? emptyProof;\n\n const len = CompressedTokenInstructionDataApproveLayout.encode(\n {\n ...data,\n proof: proofOption,\n },\n buffer,\n );\n\n const lengthBuffer = Buffer.alloc(4);\n lengthBuffer.writeUInt32LE(len, 0);\n\n const dataBuffer = buffer.subarray(0, len);\n\n return Buffer.concat([\n new Uint8Array(APPROVE_DISCRIMINATOR),\n new Uint8Array(lengthBuffer),\n new Uint8Array(dataBuffer),\n ]);\n}\n\nexport function decodeApproveInstructionData(\n buffer: Buffer,\n): CompressedTokenInstructionDataApprove {\n const data = CompressedTokenInstructionDataApproveLayout.decode(\n buffer.subarray(APPROVE_DISCRIMINATOR.length),\n ) as CompressedTokenInstructionDataApprove;\n return {\n ...data,\n proof: isEmptyProof(data.proof!) ? null : data.proof!,\n };\n}\n\nexport function encodeRevokeInstructionData(\n data: CompressedTokenInstructionDataRevoke,\n): Buffer {\n const buffer = Buffer.alloc(1000);\n\n const proofOption = data.proof ?? emptyProof;\n\n const len = CompressedTokenInstructionDataRevokeLayout.encode(\n {\n ...data,\n proof: proofOption,\n },\n buffer,\n );\n\n const lengthBuffer = Buffer.alloc(4);\n lengthBuffer.writeUInt32LE(len, 0);\n\n const dataBuffer = buffer.subarray(0, len);\n\n return Buffer.concat([\n new Uint8Array(REVOKE_DISCRIMINATOR),\n new Uint8Array(lengthBuffer),\n new Uint8Array(dataBuffer),\n ]);\n}\n\nexport function decodeRevokeInstructionData(\n buffer: Buffer,\n): CompressedTokenInstructionDataRevoke {\n const data = CompressedTokenInstructionDataRevokeLayout.decode(\n buffer.subarray(REVOKE_DISCRIMINATOR.length),\n ) as CompressedTokenInstructionDataRevoke;\n return {\n ...data,\n proof: isEmptyProof(data.proof!) ? null : data.proof!,\n };\n}\n","import {\n PublicKey,\n TransactionInstruction,\n SystemProgram,\n Connection,\n AddressLookupTableProgram,\n AccountMeta,\n ComputeBudgetProgram,\n} from '@solana/web3.js';\nimport BN from 'bn.js';\nimport { Buffer } from 'buffer';\nimport {\n ValidityProof,\n LightSystemProgram,\n ParsedTokenAccount,\n bn,\n defaultStaticAccountsStruct,\n sumUpLamports,\n toArray,\n validateSameOwner,\n validateSufficientBalance,\n defaultTestStateTreeAccounts,\n TreeInfo,\n CompressedProof,\n featureFlags,\n TreeType,\n} from '@lightprotocol/stateless.js';\nimport {\n MINT_SIZE,\n TOKEN_2022_PROGRAM_ID,\n TOKEN_PROGRAM_ID,\n createInitializeMint2Instruction,\n createMintToInstruction,\n} from '@solana/spl-token';\nimport {\n CPI_AUTHORITY_SEED,\n POOL_SEED,\n CREATE_TOKEN_POOL_DISCRIMINATOR,\n ADD_TOKEN_POOL_DISCRIMINATOR,\n} from './constants';\nimport { checkMint, packCompressedTokenAccounts } from './utils';\nimport {\n encodeTransferInstructionData,\n encodeCompressSplTokenAccountInstructionData,\n encodeMintToInstructionData,\n createTokenPoolAccountsLayout,\n mintToAccountsLayout,\n transferAccountsLayout,\n approveAccountsLayout,\n revokeAccountsLayout,\n encodeApproveInstructionData,\n encodeRevokeInstructionData,\n addTokenPoolAccountsLayout,\n encodeBatchCompressInstructionData,\n} from './layout';\nimport {\n BatchCompressInstructionData,\n CompressedTokenInstructionDataApprove,\n CompressedTokenInstructionDataRevoke,\n CompressedTokenInstructionDataTransfer,\n DelegatedTransfer,\n TokenTransferOutputData,\n} from './types';\nimport {\n checkTokenPoolInfo,\n TokenPoolInfo,\n} from './utils/get-token-pool-infos';\n\nexport type CompressParams = {\n /**\n * Fee payer\n */\n payer: PublicKey;\n /**\n * Owner of uncompressed token account\n */\n owner: PublicKey;\n /**\n * Source SPL Token account address\n */\n source: PublicKey;\n /**\n * Recipient address(es)\n */\n toAddress: PublicKey | PublicKey[];\n /**\n * Token amount(s) to compress\n */\n amount: number | BN | number[] | BN[];\n /**\n * SPL Token mint address\n */\n mint: PublicKey;\n /**\n * State tree to write to\n */\n outputStateTreeInfo: TreeInfo;\n /**\n * Token pool\n */\n tokenPoolInfo: TokenPoolInfo;\n};\n\nexport type CompressSplTokenAccountParams = {\n /**\n * Fee payer\n */\n feePayer: PublicKey;\n /**\n * SPL Token account owner\n */\n authority: PublicKey;\n /**\n * SPL Token account to compress\n */\n tokenAccount: PublicKey;\n /**\n * SPL Token mint address\n */\n mint: PublicKey;\n /**\n * Amount to leave in token account\n */\n remainingAmount?: BN;\n /**\n * State tree to write to\n */\n outputStateTreeInfo: TreeInfo;\n /**\n * Token pool\n */\n tokenPoolInfo: TokenPoolInfo;\n};\n\nexport type DecompressParams = {\n /**\n * Fee payer\n */\n payer: PublicKey;\n /**\n * Source compressed token accounts\n */\n inputCompressedTokenAccounts: ParsedTokenAccount[];\n /**\n * Destination uncompressed token account\n */\n toAddress: PublicKey;\n /**\n * Token amount to decompress\n */\n amount: number | BN;\n /**\n * Validity proof for input state\n */\n recentValidityProof: ValidityProof | CompressedProof | null;\n /**\n * Recent state root indices\n */\n recentInputStateRootIndices: number[];\n /**\n * Token pool(s)\n */\n tokenPoolInfos: TokenPoolInfo | TokenPoolInfo[];\n};\n\nexport type TransferParams = {\n /**\n * Fee payer\n */\n payer: PublicKey;\n /**\n * Source compressed token accounts\n */\n inputCompressedTokenAccounts: ParsedTokenAccount[];\n /**\n * Recipient address\n */\n toAddress: PublicKey;\n /**\n * Token amount to transfer\n */\n amount: BN | number;\n /**\n * Validity proof for input state\n */\n recentValidityProof: ValidityProof | CompressedProof | null;\n /**\n * Recent state root indices\n */\n recentInputStateRootIndices: number[];\n};\n\nexport type ApproveParams = {\n /**\n * Fee payer\n */\n payer: PublicKey;\n /**\n * Source compressed token accounts\n */\n inputCompressedTokenAccounts: ParsedTokenAccount[];\n /**\n * Recipient address\n */\n toAddress: PublicKey;\n /**\n * Token amount to approve\n */\n amount: BN | number;\n /**\n * Validity proof for input state\n */\n recentValidityProof: ValidityProof | CompressedProof | null;\n /**\n * Recent state root indices\n */\n recentInputStateRootIndices: number[];\n};\n\nexport type RevokeParams = {\n /**\n * Fee payer\n */\n payer: PublicKey;\n /**\n * Input compressed token accounts\n */\n inputCompressedTokenAccounts: ParsedTokenAccount[];\n /**\n * Validity proof for input state\n */\n recentValidityProof: ValidityProof | CompressedProof | null;\n /**\n * Recent state root indices\n */\n recentInputStateRootIndices: number[];\n};\n\n/**\n * Create Mint account for compressed Tokens\n */\nexport type CreateMintParams = {\n /**\n * Fee payer\n */\n feePayer: PublicKey;\n /**\n * SPL Mint address\n */\n mint: PublicKey;\n /**\n * Mint authority\n */\n authority: PublicKey;\n /**\n * Optional: freeze authority\n */\n freezeAuthority: PublicKey | null;\n /**\n * Mint decimals\n */\n decimals: number;\n /**\n * lamport amount for mint account rent exemption\n */\n rentExemptBalance: number;\n /**\n * Optional: The token program ID. Default: SPL Token Program ID\n */\n tokenProgramId?: PublicKey;\n /**\n * Optional: Mint size to use, defaults to MINT_SIZE\n */\n mintSize?: number;\n};\n\n/**\n * Parameters for merging compressed token accounts\n */\nexport type MergeTokenAccountsParams = {\n /**\n * Fee payer\n */\n payer: PublicKey;\n /**\n * Owner of the compressed token accounts to be merged\n */\n owner: PublicKey;\n /**\n * SPL Token mint address\n */\n mint: PublicKey;\n /**\n * Array of compressed token accounts to merge\n */\n inputCompressedTokenAccounts: ParsedTokenAccount[];\n /**\n * Validity proof for state inclusion\n */\n recentValidityProof: ValidityProof | CompressedProof | null;\n /**\n * State root indices of the input state\n */\n recentInputStateRootIndices: number[];\n};\n\n/**\n * Create compressed token accounts\n */\nexport type MintToParams = {\n /**\n * Fee payer\n */\n feePayer: PublicKey;\n /**\n * Token mint address\n */\n mint: PublicKey;\n /**\n * Mint authority\n */\n authority: PublicKey;\n /**\n * Recipient address(es)\n */\n toPubkey: PublicKey[] | PublicKey;\n /**\n * Token amount(s) to mint\n */\n amount: BN | BN[] | number | number[];\n /**\n * State tree for minted tokens\n */\n outputStateTreeInfo: TreeInfo;\n /**\n * Token pool\n */\n tokenPoolInfo: TokenPoolInfo;\n};\n\n/**\n * Register an existing SPL mint account to the compressed token program\n * Creates an omnibus account for the mint\n */\nexport type CreateTokenPoolParams = {\n /**\n * Fee payer\n */\n feePayer: PublicKey;\n /**\n * SPL Mint address\n */\n mint: PublicKey;\n /**\n * Optional: The token program ID. Default: SPL Token Program ID\n */\n tokenProgramId?: PublicKey;\n};\n\nexport type AddTokenPoolParams = {\n /**\n * Fee payer\n */\n feePayer: PublicKey;\n /**\n * Token mint address\n */\n mint: PublicKey;\n /**\n * Token pool index\n */\n poolIndex: number;\n /**\n * Optional: Token program ID. Default: SPL Token Program ID\n */\n tokenProgramId?: PublicKey;\n};\n\n/**\n * Mint from existing SPL mint to compressed token accounts\n */\nexport type ApproveAndMintToParams = {\n /**\n * Fee payer\n */\n feePayer: PublicKey;\n /**\n * SPL Mint address\n */\n mint: PublicKey;\n /**\n * Mint authority\n */\n authority: PublicKey;\n /**\n * Mint authority (associated) token account\n */\n authorityTokenAccount: PublicKey;\n /**\n * Recipient address\n */\n toPubkey: PublicKey;\n /**\n * Token amount to mint\n */\n amount: BN | number;\n /**\n * State tree to write to\n */\n outputStateTreeInfo: TreeInfo;\n /**\n * Token pool\n */\n tokenPoolInfo: TokenPoolInfo;\n};\n\nexport type CreateTokenProgramLookupTableParams = {\n /**\n * Fee payer\n */\n payer: PublicKey;\n /**\n * Authority of the transaction\n */\n authority: PublicKey;\n /**\n * Optional Mint addresses to store in the lookup table\n */\n mints?: PublicKey[];\n /**\n * Recently finalized Solana slot\n */\n recentSlot: number;\n /**\n * Optional additional addresses to store in the lookup table\n */\n remainingAccounts?: PublicKey[];\n};\n\n/**\n * Sum up the token amounts of the compressed token accounts\n */\nexport const sumUpTokenAmount = (accounts: ParsedTokenAccount[]): BN => {\n return accounts.reduce(\n (acc, account: ParsedTokenAccount) => acc.add(account.parsed.amount),\n bn(0),\n );\n};\n\n/**\n * Validate that all the compressed token accounts are owned by the same owner.\n */\nexport const validateSameTokenOwner = (accounts: ParsedTokenAccount[]) => {\n const owner = accounts[0].parsed.owner;\n accounts.forEach(acc => {\n if (!acc.parsed.owner.equals(owner)) {\n throw new Error('Token accounts must be owned by the same owner');\n }\n });\n};\n\n/**\n * Parse compressed token accounts to get the mint, current owner and delegate.\n */\nexport const parseTokenData = (\n compressedTokenAccounts: ParsedTokenAccount[],\n) => {\n const mint = compressedTokenAccounts[0].parsed.mint;\n const currentOwner = compressedTokenAccounts[0].parsed.owner;\n const delegate = compressedTokenAccounts[0].parsed.delegate;\n\n return { mint, currentOwner, delegate };\n};\n\nexport const parseMaybeDelegatedTransfer = (\n inputs: ParsedTokenAccount[],\n outputs: TokenTransferOutputData[],\n): { delegatedTransfer: DelegatedTransfer | null; authority: PublicKey } => {\n if (inputs.length < 1)\n throw new Error('Must supply at least one input token account.');\n\n const owner = inputs[0].parsed.owner;\n\n const delegatedAccountsIndex = inputs.findIndex(a => a.parsed.delegate);\n\n /// Fast path: no delegated account used\n if (delegatedAccountsIndex === -1)\n return { delegatedTransfer: null, authority: owner };\n\n const delegate = inputs[delegatedAccountsIndex].parsed.delegate;\n const delegateChangeAccountIndex = outputs.length <= 1 ? null : 0;\n\n return {\n delegatedTransfer: {\n owner,\n delegateChangeAccountIndex,\n },\n authority: delegate!,\n };\n};\n\n/**\n * Create the output state for a transfer transaction.\n * @param inputCompressedTokenAccounts Input state\n * @param toAddress Recipient address\n * @param amount Amount of tokens to transfer\n * @returns Output token data for the transfer\n * instruction\n */\nexport function createTransferOutputState(\n inputCompressedTokenAccounts: ParsedTokenAccount[],\n toAddress: PublicKey,\n amount: number | BN,\n): TokenTransferOutputData[] {\n amount = bn(amount);\n const inputAmount = sumUpTokenAmount(inputCompressedTokenAccounts);\n const inputLamports = sumUpLamports(\n inputCompressedTokenAccounts.map(acc => acc.compressedAccount),\n );\n\n const changeAmount = inputAmount.sub(amount);\n\n validateSufficientBalance(changeAmount);\n\n if (changeAmount.eq(bn(0)) && inputLamports.eq(bn(0))) {\n return [\n {\n owner: toAddress,\n amount,\n lamports: inputLamports,\n tlv: null,\n },\n ];\n }\n\n /// validates token program\n validateSameOwner(\n inputCompressedTokenAccounts.map(acc => acc.compressedAccount),\n );\n validateSameTokenOwner(inputCompressedTokenAccounts);\n\n const outputCompressedAccounts: TokenTransferOutputData[] = [\n {\n owner: inputCompressedTokenAccounts[0].parsed.owner,\n amount: changeAmount,\n lamports: inputLamports,\n tlv: null,\n },\n {\n owner: toAddress,\n amount,\n lamports: bn(0),\n tlv: null,\n },\n ];\n return outputCompressedAccounts;\n}\n\n/**\n * Create the output state for a compress transaction.\n * @param inputCompressedTokenAccounts Input state\n * @param amount Amount of tokens to compress\n * @returns Output token data for the compress\n * instruction\n */\nexport function createDecompressOutputState(\n inputCompressedTokenAccounts: ParsedTokenAccount[],\n amount: number | BN,\n): TokenTransferOutputData[] {\n amount = bn(amount);\n const inputLamports = sumUpLamports(\n inputCompressedTokenAccounts.map(acc => acc.compressedAccount),\n );\n const inputAmount = sumUpTokenAmount(inputCompressedTokenAccounts);\n const changeAmount = inputAmount.sub(amount);\n\n validateSufficientBalance(changeAmount);\n\n /// lamports gets decompressed\n if (changeAmount.eq(bn(0)) && inputLamports.eq(bn(0))) {\n return [];\n }\n\n validateSameOwner(\n inputCompressedTokenAccounts.map(acc => acc.compressedAccount),\n );\n validateSameTokenOwner(inputCompressedTokenAccounts);\n\n const tokenTransferOutputs: TokenTransferOutputData[] = [\n {\n owner: inputCompressedTokenAccounts[0].parsed.owner,\n amount: changeAmount,\n lamports: inputLamports,\n tlv: null,\n },\n ];\n return tokenTransferOutputs;\n}\n\nexport class CompressedTokenProgram {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Public key that identifies the CompressedPda program\n */\n static programId: PublicKey = new PublicKey(\n 'cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m',\n );\n\n /**\n * Set a custom programId via PublicKey or base58 encoded string.\n * This method is not required for regular usage.\n *\n * Use this only if you know what you are doing.\n */\n static setProgramId(programId: PublicKey | string) {\n this.programId =\n typeof programId === 'string'\n ? new PublicKey(programId)\n : programId;\n }\n\n /**\n * Derive the token pool pda.\n * To derive the token pool pda with bump, use {@link deriveTokenPoolPdaWithIndex}.\n *\n * @param mint The mint of the token pool\n *\n * @returns The token pool pda\n */\n static deriveTokenPoolPda(mint: PublicKey): PublicKey {\n const seeds = [POOL_SEED, mint.toBuffer()];\n const [address, _] = PublicKey.findProgramAddressSync(\n seeds,\n this.programId,\n );\n return address;\n }\n\n /**\n * Find the index and bump for a given token pool pda and mint.\n *\n * @param poolPda The token pool pda to find the index and bump for\n * @param mint The mint of the token pool\n *\n * @returns The index and bump number.\n */\n static findTokenPoolIndexAndBump(\n poolPda: PublicKey,\n mint: PublicKey,\n ): [number, number] {\n for (let index = 0; index < 5; index++) {\n const derivedPda =\n CompressedTokenProgram.deriveTokenPoolPdaWithIndex(mint, index);\n if (derivedPda[0].equals(poolPda)) {\n return [index, derivedPda[1]];\n }\n }\n throw new Error('Token pool not found');\n }\n\n /**\n * Derive the token pool pda with index.\n *\n * @param mint The mint of the token pool\n * @param index Index. starts at 0. The Protocol supports 4 indexes aka token pools\n * per mint.\n *\n * @returns The token pool pda and bump.\n */\n static deriveTokenPoolPdaWithIndex(\n mint: PublicKey,\n index: number,\n ): [PublicKey, number] {\n let seeds: Buffer[] = [];\n if (index === 0) {\n seeds = [Buffer.from('pool'), mint.toBuffer(), Buffer.from([])]; // legacy, 1st\n } else {\n seeds = [\n Buffer.from('pool'),\n mint.toBuffer(),\n Buffer.from([index]),\n ];\n }\n const [address, bump] = PublicKey.findProgramAddressSync(\n seeds,\n this.programId,\n );\n return [address, bump];\n }\n\n /** @internal */\n static get deriveCpiAuthorityPda(): PublicKey {\n const [address, _] = PublicKey.findProgramAddressSync(\n [CPI_AUTHORITY_SEED],\n this.programId,\n );\n return address;\n }\n\n /**\n * Construct createMint instruction for compressed tokens.\n *\n * @param feePayer Fee payer.\n * @param mint SPL Mint address.\n * @param authority Mint authority.\n * @param freezeAuthority Optional: freeze authority.\n * @param decimals Decimals.\n * @param rentExemptBalance Lamport amount for mint account rent exemption.\n * @param tokenProgramId Optional: Token program ID. Default: SPL Token Program ID\n * @param mintSize Optional: mint size. Default: MINT_SIZE\n *\n * @returns [createMintAccountInstruction, initializeMintInstruction,\n * createTokenPoolInstruction]\n *\n * Note that `createTokenPoolInstruction` must be executed after\n * `initializeMintInstruction`.\n */\n static async createMint({\n feePayer,\n mint,\n authority,\n freezeAuthority,\n decimals,\n rentExemptBalance,\n tokenProgramId,\n mintSize,\n }: CreateMintParams): Promise<TransactionInstruction[]> {\n const tokenProgram = tokenProgramId ?? TOKEN_PROGRAM_ID;\n\n /// Create and initialize SPL Mint account\n const createMintAccountInstruction = SystemProgram.createAccount({\n fromPubkey: feePayer,\n lamports: rentExemptBalance,\n newAccountPubkey: mint,\n programId: tokenProgram,\n space: mintSize ?? MINT_SIZE,\n });\n\n const initializeMintInstruction = createInitializeMint2Instruction(\n mint,\n decimals,\n authority,\n freezeAuthority,\n tokenProgram,\n );\n\n const createTokenPoolInstruction = await this.createTokenPool({\n feePayer,\n mint,\n tokenProgramId: tokenProgram,\n });\n\n return [\n createMintAccountInstruction,\n initializeMintInstruction,\n createTokenPoolInstruction,\n ];\n }\n\n /**\n * Enable compression for an existing SPL mint, creating an omnibus account.\n * For new mints, use `CompressedTokenProgram.createMint`.\n *\n * @param feePayer Fee payer.\n * @param mint SPL Mint address.\n * @param tokenProgramId Optional: Token program ID. Default: SPL\n * Token Program ID\n *\n * @returns The createTokenPool instruction\n */\n static async createTokenPool({\n feePayer,\n mint,\n tokenProgramId,\n }: CreateTokenPoolParams): Promise<TransactionInstruction> {\n const tokenProgram = tokenProgramId ?? TOKEN_PROGRAM_ID;\n\n const tokenPoolPda = this.deriveTokenPoolPdaWithIndex(mint, 0);\n\n const keys = createTokenPoolAccountsLayout({\n mint,\n feePayer,\n tokenPoolPda: tokenPoolPda[0],\n tokenProgram,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n systemProgram: SystemProgram.programId,\n });\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data: CREATE_TOKEN_POOL_DISCRIMINATOR,\n });\n }\n\n /**\n * Add a token pool to an existing SPL mint. For new mints, use\n * {@link createTokenPool}.\n *\n * @param feePayer Fee payer.\n * @param mint SPL Mint address.\n * @param poolIndex Pool index.\n * @param tokenProgramId Optional: Token program ID. Default: SPL\n * Token Program ID\n *\n * @returns The addTokenPool instruction\n */\n static async addTokenPool({\n feePayer,\n mint,\n poolIndex,\n tokenProgramId,\n }: AddTokenPoolParams): Promise<TransactionInstruction> {\n if (poolIndex <= 0) {\n throw new Error(\n 'Pool index must be greater than 0. For 0, use CreateTokenPool instead.',\n );\n }\n if (poolIndex > 3) {\n throw new Error(\n `Invalid poolIndex ${poolIndex}. Max 4 pools per mint.`,\n );\n }\n\n const tokenProgram = tokenProgramId ?? TOKEN_PROGRAM_ID;\n\n const existingTokenPoolPda = this.deriveTokenPoolPdaWithIndex(\n mint,\n poolIndex - 1,\n );\n const tokenPoolPda = this.deriveTokenPoolPdaWithIndex(mint, poolIndex);\n\n const keys = addTokenPoolAccountsLayout({\n mint,\n feePayer,\n tokenPoolPda: tokenPoolPda[0],\n existingTokenPoolPda: existingTokenPoolPda[0],\n tokenProgram,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n systemProgram: SystemProgram.programId,\n });\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data: Buffer.concat([\n new Uint8Array(ADD_TOKEN_POOL_DISCRIMINATOR),\n new Uint8Array(Buffer.from([poolIndex])),\n ]),\n });\n }\n\n /**\n * Construct mintTo instruction for compressed tokens\n *\n * @param feePayer Fee payer.\n * @param mint SPL Mint address.\n * @param authority Mint authority.\n * @param toPubkey Recipient owner address.\n * @param amount Amount of tokens to mint.\n * @param outputStateTreeInfo State tree to write to.\n * @param tokenPoolInfo Token pool info.\n *\n * @returns The mintTo instruction\n */\n static async mintTo({\n feePayer,\n mint,\n authority,\n toPubkey,\n amount,\n outputStateTreeInfo,\n tokenPoolInfo,\n }: MintToParams): Promise<TransactionInstruction> {\n const systemKeys = defaultStaticAccountsStruct();\n const tokenProgram = tokenPoolInfo.tokenProgram;\n checkTokenPoolInfo(tokenPoolInfo, mint);\n\n const amounts = toArray<BN | number>(amount).map(amount => bn(amount));\n const toPubkeys = toArray(toPubkey);\n\n if (amounts.length !== toPubkeys.length) {\n throw new Error(\n 'Amount and toPubkey arrays must have the same length',\n );\n }\n\n const keys = mintToAccountsLayout({\n mint,\n feePayer,\n authority,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n tokenProgram,\n tokenPoolPda: tokenPoolInfo.tokenPoolPda,\n lightSystemProgram: LightSystemProgram.programId,\n registeredProgramPda: systemKeys.registeredProgramPda,\n noopProgram: systemKeys.noopProgram,\n accountCompressionAuthority: systemKeys.accountCompressionAuthority,\n accountCompressionProgram: systemKeys.accountCompressionProgram,\n merkleTree:\n outputStateTreeInfo.treeType === TreeType.StateV2\n ? outputStateTreeInfo.queue\n : outputStateTreeInfo.tree,\n selfProgram: this.programId,\n systemProgram: SystemProgram.programId,\n solPoolPda: null,\n });\n\n const data = encodeMintToInstructionData({\n recipients: toPubkeys,\n amounts,\n lamports: null,\n });\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n }\n\n /**\n * Mint tokens from registered SPL mint account to a compressed account\n *\n * @param feePayer Fee payer.\n * @param mint SPL Mint address.\n * @param authority Mint authority.\n * @param authorityTokenAccount The mint authority's associated token\n * account (ATA).\n * @param toPubkey Recipient owner address.\n * @param amount Amount of tokens to mint.\n * @param outputStateTreeInfo State tree to write to.\n * @param tokenPoolInfo Token pool info.\n *\n * @returns The mintTo instruction\n */\n static async approveAndMintTo({\n feePayer,\n mint,\n authority,\n authorityTokenAccount,\n toPubkey,\n amount,\n outputStateTreeInfo,\n tokenPoolInfo,\n }: ApproveAndMintToParams) {\n const amountBigInt: bigint = BigInt(amount.toString());\n\n /// 1. Mint to existing ATA of mintAuthority.\n const splMintToInstruction = createMintToInstruction(\n mint,\n authorityTokenAccount,\n authority,\n amountBigInt,\n [],\n tokenPoolInfo.tokenProgram,\n );\n\n /// 2. Compress from mint authority ATA to recipient compressed account\n const compressInstruction = await this.compress({\n payer: feePayer,\n owner: authority,\n source: authorityTokenAccount,\n toAddress: toPubkey,\n mint,\n amount,\n outputStateTreeInfo,\n tokenPoolInfo,\n });\n\n return [splMintToInstruction, compressInstruction];\n }\n\n /**\n * Construct transfer instruction for compressed tokens\n *\n * @param payer Fee payer.\n * @param inputCompressedTokenAccounts Source compressed token accounts.\n * @param toAddress Recipient owner address.\n * @param amount Amount of tokens to transfer.\n * @param recentValidityProof Recent validity proof.\n * @param recentInputStateRootIndices Recent state root indices.\n *\n * @returns The transfer instruction\n */\n static async transfer({\n payer,\n inputCompressedTokenAccounts,\n toAddress,\n amount,\n recentValidityProof,\n recentInputStateRootIndices,\n }: TransferParams): Promise<TransactionInstruction> {\n const tokenTransferOutputs: TokenTransferOutputData[] =\n createTransferOutputState(\n inputCompressedTokenAccounts,\n toAddress,\n amount,\n );\n\n const {\n inputTokenDataWithContext,\n packedOutputTokenData,\n remainingAccountMetas,\n } = packCompressedTokenAccounts({\n inputCompressedTokenAccounts,\n rootIndices: recentInputStateRootIndices,\n tokenTransferOutputs,\n });\n\n const { mint } = parseTokenData(inputCompressedTokenAccounts);\n\n const { delegatedTransfer, authority } = parseMaybeDelegatedTransfer(\n inputCompressedTokenAccounts,\n tokenTransferOutputs,\n );\n\n const rawData: CompressedTokenInstructionDataTransfer = {\n proof: recentValidityProof,\n mint,\n delegatedTransfer,\n inputTokenDataWithContext,\n outputCompressedAccounts: packedOutputTokenData,\n compressOrDecompressAmount: null,\n isCompress: false,\n cpiContext: null,\n lamportsChangeAccountMerkleTreeIndex: null,\n };\n const data = encodeTransferInstructionData(rawData);\n\n const {\n accountCompressionAuthority,\n noopProgram,\n registeredProgramPda,\n accountCompressionProgram,\n } = defaultStaticAccountsStruct();\n const keys = transferAccountsLayout({\n feePayer: payer,\n authority,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n lightSystemProgram: LightSystemProgram.programId,\n registeredProgramPda: registeredProgramPda,\n noopProgram: noopProgram,\n accountCompressionAuthority: accountCompressionAuthority,\n accountCompressionProgram: accountCompressionProgram,\n selfProgram: this.programId,\n tokenPoolPda: undefined,\n compressOrDecompressTokenAccount: undefined,\n tokenProgram: undefined,\n systemProgram: SystemProgram.programId,\n });\n\n keys.push(...remainingAccountMetas);\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n }\n\n /**\n * Create lookup table instructions for the token program's default\n * accounts.\n *\n * @param payer Fee payer.\n * @param authority Authority.\n * @param mints Mints.\n * @param recentSlot Recent slot.\n * @param remainingAccounts Remaining accounts.\n *\n * @returns [createInstruction, extendInstruction, option(extendInstruction2)]\n */\n static async createTokenProgramLookupTable({\n payer,\n authority,\n mints,\n recentSlot,\n remainingAccounts,\n }: CreateTokenProgramLookupTableParams) {\n const [createInstruction, lookupTableAddress] =\n AddressLookupTableProgram.createLookupTable({\n authority,\n payer: authority,\n recentSlot,\n });\n\n let optionalMintKeys: PublicKey[] = [];\n if (mints) {\n optionalMintKeys = [\n ...mints,\n ...mints.map(mint => this.deriveTokenPoolPda(mint)),\n ];\n }\n\n const extendInstruction = AddressLookupTableProgram.extendLookupTable({\n payer,\n authority,\n lookupTable: lookupTableAddress,\n addresses: [\n SystemProgram.programId,\n ComputeBudgetProgram.programId,\n this.deriveCpiAuthorityPda,\n LightSystemProgram.programId,\n CompressedTokenProgram.programId,\n defaultStaticAccountsStruct().registeredProgramPda,\n defaultStaticAccountsStruct().noopProgram,\n defaultStaticAccountsStruct().accountCompressionAuthority,\n defaultStaticAccountsStruct().accountCompressionProgram,\n defaultTestStateTreeAccounts().merkleTree,\n defaultTestStateTreeAccounts().nullifierQueue,\n defaultTestStateTreeAccounts().addressTree,\n defaultTestStateTreeAccounts().addressQueue,\n this.programId,\n TOKEN_PROGRAM_ID,\n TOKEN_2022_PROGRAM_ID,\n authority,\n ...optionalMintKeys,\n ],\n });\n\n const instructions = [createInstruction, extendInstruction];\n\n if (remainingAccounts && remainingAccounts.length > 0) {\n for (let i = 0; i < remainingAccounts.length; i += 25) {\n const chunk = remainingAccounts.slice(i, i + 25);\n const extendIx = AddressLookupTableProgram.extendLookupTable({\n payer,\n authority,\n lookupTable: lookupTableAddress,\n addresses: chunk,\n });\n instructions.push(extendIx);\n }\n }\n\n return {\n instructions,\n address: lookupTableAddress,\n };\n }\n\n /**\n * Create compress instruction\n *\n * @param payer Fee payer.\n * @param owner Owner of uncompressed token account.\n * @param source Source SPL Token account address.\n * @param toAddress Recipient owner address(es).\n * @param amount Amount of tokens to compress.\n * @param mint SPL Token mint address.\n * @param outputStateTreeInfo State tree to write to.\n * @param tokenPoolInfo Token pool info.\n *\n * @returns The compress instruction\n */\n static async compress({\n payer,\n owner,\n source,\n toAddress,\n amount,\n mint,\n outputStateTreeInfo,\n tokenPoolInfo,\n }: CompressParams): Promise<TransactionInstruction> {\n let tokenTransferOutputs: TokenTransferOutputData[];\n\n const amountArray = toArray<BN | number>(amount);\n const toAddressArray = toArray(toAddress);\n\n checkTokenPoolInfo(tokenPoolInfo, mint);\n\n if (amountArray.length !== toAddressArray.length) {\n throw new Error(\n 'Amount and toAddress arrays must have the same length',\n );\n }\n if (featureFlags.isV2()) {\n const [index, bump] = this.findTokenPoolIndexAndBump(\n tokenPoolInfo.tokenPoolPda,\n mint,\n );\n const rawData: BatchCompressInstructionData = {\n pubkeys: toAddressArray,\n amounts:\n amountArray.length > 1\n ? amountArray.map(amt => bn(amt))\n : null,\n lamports: null,\n amount: amountArray.length === 1 ? bn(amountArray[0]) : null,\n index,\n bump,\n };\n\n const data = encodeBatchCompressInstructionData(rawData);\n const keys = mintToAccountsLayout({\n mint,\n feePayer: payer,\n authority: owner,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n tokenProgram: tokenPoolInfo.tokenProgram,\n tokenPoolPda: tokenPoolInfo.tokenPoolPda,\n lightSystemProgram: LightSystemProgram.programId,\n ...defaultStaticAccountsStruct(),\n merkleTree: outputStateTreeInfo.queue,\n selfProgram: this.programId,\n systemProgram: SystemProgram.programId,\n solPoolPda: null,\n });\n keys.push({\n pubkey: source,\n isWritable: true,\n isSigner: false,\n });\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n } else {\n tokenTransferOutputs = amountArray.map((amt, index) => {\n const amountBN = bn(amt);\n return {\n owner: toAddressArray[index],\n amount: amountBN,\n lamports: null,\n tlv: null,\n };\n });\n\n const {\n inputTokenDataWithContext,\n packedOutputTokenData,\n remainingAccountMetas,\n } = packCompressedTokenAccounts({\n inputCompressedTokenAccounts: [],\n outputStateTreeInfo,\n rootIndices: [],\n tokenTransferOutputs,\n });\n\n const rawData: CompressedTokenInstructionDataTransfer = {\n proof: null,\n mint,\n delegatedTransfer: null,\n inputTokenDataWithContext,\n outputCompressedAccounts: packedOutputTokenData,\n compressOrDecompressAmount: Array.isArray(amount)\n ? amount\n .map(amt => bn(amt))\n .reduce((sum, amt) => sum.add(amt), bn(0))\n : bn(amount),\n isCompress: true,\n cpiContext: null,\n lamportsChangeAccountMerkleTreeIndex: null,\n };\n const data = encodeTransferInstructionData(rawData);\n const keys = transferAccountsLayout({\n ...defaultStaticAccountsStruct(),\n feePayer: payer,\n authority: owner,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n lightSystemProgram: LightSystemProgram.programId,\n selfProgram: this.programId,\n systemProgram: SystemProgram.programId,\n tokenPoolPda: tokenPoolInfo.tokenPoolPda,\n compressOrDecompressTokenAccount: source,\n tokenProgram: tokenPoolInfo.tokenProgram,\n });\n keys.push(...remainingAccountMetas);\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n }\n }\n\n /**\n * Construct decompress instruction\n *\n * @param payer Fee payer.\n * @param inputCompressedTokenAccounts Source compressed token accounts.\n * @param toAddress Destination **uncompressed** token\n * account address. (ATA)\n * @param amount Amount of tokens to decompress.\n * @param recentValidityProof Recent validity proof.\n * @param recentInputStateRootIndices Recent state root indices.\n * @param tokenPoolInfos Token pool info.\n *\n * @returns The decompress instruction\n */\n static async decompress({\n payer,\n inputCompressedTokenAccounts,\n toAddress,\n amount,\n recentValidityProof,\n recentInputStateRootIndices,\n tokenPoolInfos,\n }: DecompressParams): Promise<TransactionInstruction> {\n const amountBN = bn(amount);\n const tokenPoolInfosArray = toArray(tokenPoolInfos);\n\n const tokenTransferOutputs = createDecompressOutputState(\n inputCompressedTokenAccounts,\n amountBN,\n );\n\n /// Pack\n const {\n inputTokenDataWithContext,\n packedOutputTokenData,\n remainingAccountMetas,\n } = packCompressedTokenAccounts({\n inputCompressedTokenAccounts,\n rootIndices: recentInputStateRootIndices,\n tokenTransferOutputs: tokenTransferOutputs,\n remainingAccounts: tokenPoolInfosArray\n .slice(1)\n .map(info => info.tokenPoolPda),\n });\n\n const { mint } = parseTokenData(inputCompressedTokenAccounts);\n const { delegatedTransfer, authority } = parseMaybeDelegatedTransfer(\n inputCompressedTokenAccounts,\n tokenTransferOutputs,\n );\n\n const rawData: CompressedTokenInstructionDataTransfer = {\n proof: recentValidityProof,\n mint,\n delegatedTransfer,\n inputTokenDataWithContext,\n outputCompressedAccounts: packedOutputTokenData,\n compressOrDecompressAmount: amountBN,\n isCompress: false,\n cpiContext: null,\n lamportsChangeAccountMerkleTreeIndex: null,\n };\n const data = encodeTransferInstructionData(rawData);\n const tokenProgram = tokenPoolInfosArray[0].tokenProgram;\n\n const {\n accountCompressionAuthority,\n noopProgram,\n registeredProgramPda,\n accountCompressionProgram,\n } = defaultStaticAccountsStruct();\n\n const keys = transferAccountsLayout({\n feePayer: payer,\n authority: authority,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n lightSystemProgram: LightSystemProgram.programId,\n registeredProgramPda: registeredProgramPda,\n noopProgram: noopProgram,\n accountCompressionAuthority: accountCompressionAuthority,\n accountCompressionProgram: accountCompressionProgram,\n selfProgram: this.programId,\n tokenPoolPda: tokenPoolInfosArray[0].tokenPoolPda,\n compressOrDecompressTokenAccount: toAddress,\n tokenProgram,\n systemProgram: SystemProgram.programId,\n });\n keys.push(...remainingAccountMetas);\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n }\n\n /**\n * Create `mergeTokenAccounts` instruction\n *\n * @param payer Fee payer.\n * @param owner Owner of the compressed token\n * accounts to be merged.\n * @param inputCompressedTokenAccounts Source compressed token accounts.\n * @param mint SPL Token mint address.\n * @param recentValidityProof Recent validity proof.\n * @param recentInputStateRootIndices Recent state root indices.\n *\n * @returns instruction\n */\n static async mergeTokenAccounts({\n payer,\n owner,\n inputCompressedTokenAccounts,\n mint,\n recentValidityProof,\n recentInputStateRootIndices,\n }: MergeTokenAccountsParams): Promise<TransactionInstruction[]> {\n if (inputCompressedTokenAccounts.length > 4) {\n throw new Error('Cannot merge more than 4 token accounts at once');\n }\n\n checkMint(inputCompressedTokenAccounts, mint);\n\n const ix = await this.transfer({\n payer,\n inputCompressedTokenAccounts,\n toAddress: owner,\n amount: inputCompressedTokenAccounts.reduce(\n (sum, account) => sum.add(account.parsed.amount),\n bn(0),\n ),\n recentInputStateRootIndices,\n recentValidityProof,\n });\n\n return [ix];\n }\n\n /**\n * Create `compressSplTokenAccount` instruction\n *\n * @param feePayer Fee payer.\n * @param authority SPL Token account owner.\n * @param tokenAccount SPL Token account to compress.\n * @param mint SPL Token mint address.\n * @param remainingAmount Optional: Amount to leave in token account.\n * @param outputStateTreeInfo State tree to write to.\n * @param tokenPoolInfo Token pool info.\n *\n * @returns instruction\n */\n static async compressSplTokenAccount({\n feePayer,\n authority,\n tokenAccount,\n mint,\n remainingAmount,\n outputStateTreeInfo,\n tokenPoolInfo,\n }: CompressSplTokenAccountParams): Promise<TransactionInstruction> {\n checkTokenPoolInfo(tokenPoolInfo, mint);\n const remainingAccountMetas: AccountMeta[] = [\n {\n pubkey:\n outputStateTreeInfo.treeType === TreeType.StateV2\n ? outputStateTreeInfo.queue\n : outputStateTreeInfo.tree,\n isSigner: false,\n isWritable: true,\n },\n ];\n\n const data = encodeCompressSplTokenAccountInstructionData({\n owner: authority,\n remainingAmount: remainingAmount ?? null,\n cpiContext: null,\n });\n const {\n accountCompressionAuthority,\n noopProgram,\n registeredProgramPda,\n accountCompressionProgram,\n } = defaultStaticAccountsStruct();\n\n const keys = transferAccountsLayout({\n feePayer,\n authority,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n lightSystemProgram: LightSystemProgram.programId,\n registeredProgramPda: registeredProgramPda,\n noopProgram: noopProgram,\n accountCompressionAuthority: accountCompressionAuthority,\n accountCompressionProgram: accountCompressionProgram,\n selfProgram: this.programId,\n tokenPoolPda: tokenPoolInfo.tokenPoolPda,\n compressOrDecompressTokenAccount: tokenAccount,\n tokenProgram: tokenPoolInfo.tokenProgram,\n systemProgram: SystemProgram.programId,\n });\n\n keys.push(...remainingAccountMetas);\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n }\n\n /**\n * Get the program ID for a mint\n *\n * @param mint SPL Token mint address.\n * @param connection Connection.\n *\n * @returns program ID\n */\n static async getMintProgramId(\n mint: PublicKey,\n connection: Connection,\n ): Promise<PublicKey | undefined> {\n return (await connection.getAccountInfo(mint))?.owner;\n }\n\n /**\n * Create `approve` instruction to delegate compressed tokens.\n *\n * @param payer Fee payer.\n * @param inputCompressedTokenAccounts Source compressed token accounts.\n * @param toAddress Owner to delegate to.\n * @param amount Amount of tokens to delegate.\n * @param recentValidityProof Recent validity proof.\n * @param recentInputStateRootIndices Recent state root indices.\n *\n * @returns instruction\n */\n static async approve({\n payer,\n inputCompressedTokenAccounts,\n toAddress,\n amount,\n recentValidityProof,\n recentInputStateRootIndices,\n }: ApproveParams): Promise<TransactionInstruction> {\n const { inputTokenDataWithContext, remainingAccountMetas } =\n packCompressedTokenAccounts({\n inputCompressedTokenAccounts,\n rootIndices: recentInputStateRootIndices,\n tokenTransferOutputs: [],\n });\n\n const { mint, currentOwner } = parseTokenData(\n inputCompressedTokenAccounts,\n );\n\n const CHANGE_INDEX =\n inputCompressedTokenAccounts[0].compressedAccount.treeInfo\n .treeType === TreeType.StateV2\n ? 1\n : 0;\n\n const rawData: CompressedTokenInstructionDataApprove = {\n proof: recentValidityProof,\n mint,\n inputTokenDataWithContext,\n cpiContext: null,\n delegate: toAddress,\n delegatedAmount: bn(amount),\n delegateMerkleTreeIndex: CHANGE_INDEX,\n changeAccountMerkleTreeIndex: CHANGE_INDEX,\n delegateLamports: null,\n };\n\n const data = encodeApproveInstructionData(rawData);\n\n const {\n accountCompressionAuthority,\n noopProgram,\n registeredProgramPda,\n accountCompressionProgram,\n } = defaultStaticAccountsStruct();\n\n const keys = approveAccountsLayout({\n feePayer: payer,\n authority: currentOwner,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n lightSystemProgram: LightSystemProgram.programId,\n registeredProgramPda: registeredProgramPda,\n noopProgram: noopProgram,\n accountCompressionAuthority: accountCompressionAuthority,\n accountCompressionProgram: accountCompressionProgram,\n selfProgram: this.programId,\n systemProgram: SystemProgram.programId,\n });\n\n keys.push(...remainingAccountMetas);\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n }\n\n /**\n * Create `revoke` instruction to revoke delegation of compressed tokens.\n *\n * @param payer Fee payer.\n * @param inputCompressedTokenAccounts Source compressed token accounts.\n * @param recentValidityProof Recent validity proof.\n * @param recentInputStateRootIndices Recent state root indices.\n *\n * @returns instruction\n */\n static async revoke({\n payer,\n inputCompressedTokenAccounts,\n recentValidityProof,\n recentInputStateRootIndices,\n }: RevokeParams): Promise<TransactionInstruction> {\n validateSameTokenOwner(inputCompressedTokenAccounts);\n\n const { inputTokenDataWithContext, remainingAccountMetas } =\n packCompressedTokenAccounts({\n inputCompressedTokenAccounts,\n rootIndices: recentInputStateRootIndices,\n tokenTransferOutputs: [],\n });\n\n const { mint, currentOwner } = parseTokenData(\n inputCompressedTokenAccounts,\n );\n\n const rawData: CompressedTokenInstructionDataRevoke = {\n proof: recentValidityProof,\n mint,\n inputTokenDataWithContext,\n cpiContext: null,\n outputAccountMerkleTreeIndex:\n inputCompressedTokenAccounts[0].compressedAccount.treeInfo\n .treeType === TreeType.StateV2\n ? 2\n : 1,\n };\n const data = encodeRevokeInstructionData(rawData);\n\n const {\n accountCompressionAuthority,\n noopProgram,\n registeredProgramPda,\n accountCompressionProgram,\n } = defaultStaticAccountsStruct();\n const keys = revokeAccountsLayout({\n feePayer: payer,\n authority: currentOwner,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n lightSystemProgram: LightSystemProgram.programId,\n registeredProgramPda: registeredProgramPda,\n noopProgram: noopProgram,\n accountCompressionAuthority: accountCompressionAuthority,\n accountCompressionProgram: accountCompressionProgram,\n selfProgram: this.programId,\n systemProgram: SystemProgram.programId,\n });\n\n keys.push(...remainingAccountMetas);\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n }\n}\n","export type LightCompressedToken = {\n version: '1.2.0';\n name: 'light_compressed_token';\n instructions: [\n {\n name: 'createTokenPool';\n docs: [\n 'This instruction creates a token pool for a given mint. Every spl mint',\n 'can have one token pool. When a token is compressed the tokens are',\n 'transferrred to the token pool, and their compressed equivalent is',\n 'minted into a Merkle tree.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'tokenPoolPda';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'mint';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'tokenProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [];\n },\n {\n name: 'addTokenPool';\n docs: [\n 'This instruction creates an additional token pool for a given mint.',\n 'The maximum number of token pools per mint is 5.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'tokenPoolPda';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'existingTokenPoolPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'mint';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'tokenProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'tokenPoolIndex';\n type: 'u8';\n },\n ];\n },\n {\n name: 'mintTo';\n docs: [\n 'Mints tokens from an spl token mint to a list of compressed accounts.',\n 'Minted tokens are transferred to a pool account owned by the compressed',\n 'token program. The instruction creates one compressed output account for',\n 'every amount and pubkey input pair. A constant amount of lamports can be',\n 'transferred to each output account to enable. A use case to add lamports',\n 'to a compressed token account is to prevent spam. This is the only way',\n 'to add lamports to a compressed token account.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'mint';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'tokenPoolPda';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'tokenProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n docs: ['programs'];\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'merkleTree';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'solPoolPda';\n isMut: true;\n isSigner: false;\n isOptional: true;\n },\n ];\n args: [\n {\n name: 'publicKeys';\n type: {\n vec: 'publicKey';\n };\n },\n {\n name: 'amounts';\n type: {\n vec: 'u64';\n };\n },\n {\n name: 'lamports';\n type: {\n option: 'u64';\n };\n },\n ];\n },\n {\n name: 'compressSplTokenAccount';\n docs: [\n 'Compresses the balance of an spl token account sub an optional remaining',\n 'amount. This instruction does not close the spl token account. To close',\n 'the account bundle a close spl account instruction in your transaction.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ];\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n docs: ['this program is the signer of the cpi.'];\n },\n {\n name: 'tokenPoolPda';\n isMut: true;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'compressOrDecompressTokenAccount';\n isMut: true;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'tokenProgram';\n isMut: false;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'owner';\n type: 'publicKey';\n },\n {\n name: 'remainingAmount';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'cpiContext';\n type: {\n option: {\n defined: 'CompressedCpiContext';\n };\n };\n },\n ];\n },\n {\n name: 'transfer';\n docs: [\n 'Transfers compressed tokens from one account to another. All accounts',\n 'must be of the same mint. Additional spl tokens can be compressed or',\n 'decompressed. In one transaction only compression or decompression is',\n 'possible. Lamports can be transferred alongside tokens. If output token',\n 'accounts specify less lamports than inputs the remaining lamports are',\n 'transferred to an output compressed account. Signer must be owner or',\n 'delegate. If a delegated token account is transferred the delegate is',\n 'not preserved.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ];\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n docs: ['this program is the signer of the cpi.'];\n },\n {\n name: 'tokenPoolPda';\n isMut: true;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'compressOrDecompressTokenAccount';\n isMut: true;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'tokenProgram';\n isMut: false;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'inputs';\n type: 'bytes';\n },\n ];\n },\n {\n name: 'approve';\n docs: [\n 'Delegates an amount to a delegate. A compressed token account is either',\n 'completely delegated or not. Prior delegates are not preserved. Cannot',\n 'be called by a delegate.',\n 'The instruction creates two output accounts:',\n '1. one account with delegated amount',\n '2. one account with remaining(change) amount',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ];\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n docs: ['this program is the signer of the cpi.'];\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'inputs';\n type: 'bytes';\n },\n ];\n },\n {\n name: 'revoke';\n docs: [\n 'Revokes a delegation. The instruction merges all inputs into one output',\n 'account. Cannot be called by a delegate. Delegates are not preserved.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ];\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n docs: ['this program is the signer of the cpi.'];\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'inputs';\n type: 'bytes';\n },\n ];\n },\n {\n name: 'freeze';\n docs: [\n 'Freezes compressed token accounts. Inputs must not be frozen. Creates as',\n 'many outputs as inputs. Balances and delegates are preserved.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n docs: ['that this program is the signer of the cpi.'];\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'mint';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'inputs';\n type: 'bytes';\n },\n ];\n },\n {\n name: 'thaw';\n docs: [\n 'Thaws frozen compressed token accounts. Inputs must be frozen. Creates',\n 'as many outputs as inputs. Balances and delegates are preserved.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n docs: ['that this program is the signer of the cpi.'];\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'mint';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'inputs';\n type: 'bytes';\n },\n ];\n },\n {\n name: 'burn';\n docs: [\n 'Burns compressed tokens and spl tokens from the pool account. Delegates',\n 'can burn tokens. The output compressed token account remains delegated.',\n 'Creates one output compressed token account.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ];\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'mint';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'tokenPoolPda';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'tokenProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'inputs';\n type: 'bytes';\n },\n ];\n },\n {\n name: 'stubIdlBuild';\n docs: [\n 'This function is a stub to allow Anchor to include the input types in',\n 'the IDL. It should not be included in production builds nor be called in',\n 'practice.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ];\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n docs: ['this program is the signer of the cpi.'];\n },\n {\n name: 'tokenPoolPda';\n isMut: true;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'compressOrDecompressTokenAccount';\n isMut: true;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'tokenProgram';\n isMut: false;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'inputs1';\n type: {\n defined: 'CompressedTokenInstructionDataTransfer';\n };\n },\n {\n name: 'inputs2';\n type: {\n defined: 'TokenData';\n };\n },\n ];\n },\n ];\n types: [\n {\n name: 'AccountState';\n type: {\n kind: 'enum';\n variants: [\n {\n name: 'Initialized';\n },\n {\n name: 'Frozen';\n },\n ];\n };\n },\n {\n name: 'CompressedAccount';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'owner';\n type: 'publicKey';\n },\n {\n name: 'lamports';\n type: 'u64';\n },\n {\n name: 'address';\n type: {\n option: {\n array: ['u8', 32];\n };\n };\n },\n {\n name: 'data';\n type: {\n option: {\n defined: 'CompressedAccountData';\n };\n };\n },\n ];\n };\n },\n {\n name: 'CompressedAccountData';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'discriminator';\n type: {\n array: ['u8', 8];\n };\n },\n {\n name: 'data';\n type: 'bytes';\n },\n {\n name: 'dataHash';\n type: {\n array: ['u8', 32];\n };\n },\n ];\n };\n },\n {\n name: 'CompressedCpiContext';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'setContext';\n docs: [\n 'Is set by the program that is invoking the CPI to signal that is should',\n 'set the cpi context.',\n ];\n type: 'bool';\n },\n {\n name: 'firstSetContext';\n docs: [\n 'Is set to wipe the cpi context since someone could have set it before',\n 'with unrelated data.',\n ];\n type: 'bool';\n },\n {\n name: 'cpiContextAccountIndex';\n docs: [\n 'Index of cpi context account in remaining accounts.',\n ];\n type: 'u8';\n },\n ];\n };\n },\n {\n name: 'CompressedProof';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'a';\n type: {\n array: ['u8', 32];\n };\n },\n {\n name: 'b';\n type: {\n array: ['u8', 64];\n };\n },\n {\n name: 'c';\n type: {\n array: ['u8', 32];\n };\n },\n ];\n };\n },\n {\n name: 'CompressedTokenInstructionDataTransfer';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'proof';\n type: {\n option: {\n defined: 'CompressedProof';\n };\n };\n },\n {\n name: 'mint';\n type: 'publicKey';\n },\n {\n name: 'delegatedTransfer';\n docs: [\n 'Is required if the signer is delegate,',\n '-> delegate is authority account,',\n 'owner = Some(owner) is the owner of the token account.',\n ];\n type: {\n option: {\n defined: 'DelegatedTransfer';\n };\n };\n },\n {\n name: 'inputTokenDataWithContext';\n type: {\n vec: {\n defined: 'InputTokenDataWithContext';\n };\n };\n },\n {\n name: 'outputCompressedAccounts';\n type: {\n vec: {\n defined: 'PackedTokenTransferOutputData';\n };\n };\n },\n {\n name: 'isCompress';\n type: 'bool';\n },\n {\n name: 'compressOrDecompressAmount';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'cpiContext';\n type: {\n option: {\n defined: 'CompressedCpiContext';\n };\n };\n },\n {\n name: 'lamportsChangeAccountMerkleTreeIndex';\n type: {\n option: 'u8';\n };\n },\n ];\n };\n },\n {\n name: 'CompressedTokenInstructionDataRevoke';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'proof';\n type: {\n option: {\n defined: 'CompressedProof';\n };\n };\n },\n {\n name: 'mint';\n type: 'publicKey';\n },\n {\n name: 'inputTokenDataWithContext';\n type: {\n vec: {\n defined: 'InputTokenDataWithContext';\n };\n };\n },\n {\n name: 'cpiContext';\n type: {\n option: {\n defined: 'CompressedCpiContext';\n };\n };\n },\n {\n name: 'outputAccountMerkleTreeIndex';\n type: 'u8';\n },\n ];\n };\n },\n {\n name: 'CompressedTokenInstructionDataApprove';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'proof';\n type: {\n option: {\n defined: 'CompressedProof';\n };\n };\n },\n {\n name: 'mint';\n type: 'publicKey';\n },\n {\n name: 'inputTokenDataWithContext';\n type: {\n vec: {\n defined: 'InputTokenDataWithContext';\n };\n };\n },\n {\n name: 'cpiContext';\n type: {\n option: {\n defined: 'CompressedCpiContext';\n };\n };\n },\n {\n name: 'delegate';\n type: 'publicKey';\n },\n {\n name: 'delegatedAmount';\n type: 'u64';\n },\n {\n name: 'delegateMerkleTreeIndex';\n type: 'u8';\n },\n {\n name: 'changeAccountMerkleTreeIndex';\n type: 'u8';\n },\n {\n name: 'delegateLamports';\n type: {\n option: 'u64';\n };\n },\n ];\n };\n },\n {\n name: 'DelegatedTransfer';\n docs: [\n 'Struct to provide the owner when the delegate is signer of the transaction.',\n ];\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'owner';\n type: 'publicKey';\n },\n {\n name: 'delegateChangeAccountIndex';\n docs: [\n 'Index of change compressed account in output compressed accounts. In',\n \"case that the delegate didn't spend the complete delegated compressed\",\n 'account balance the change compressed account will be delegated to her',\n 'as well.',\n ];\n type: {\n option: 'u8';\n };\n },\n ];\n };\n },\n {\n name: 'InputTokenDataWithContext';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'amount';\n type: 'u64';\n },\n {\n name: 'delegateIndex';\n type: {\n option: 'u8';\n };\n },\n {\n name: 'merkleContext';\n type: {\n defined: 'PackedMerkleContext';\n };\n },\n {\n name: 'rootIndex';\n type: 'u16';\n },\n {\n name: 'lamports';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'tlv';\n docs: [\n 'Placeholder for TokenExtension tlv data (unimplemented)',\n ];\n type: {\n option: 'bytes';\n };\n },\n ];\n };\n },\n {\n name: 'InstructionDataInvoke';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'proof';\n type: {\n option: {\n defined: 'CompressedProof';\n };\n };\n },\n {\n name: 'inputCompressedAccountsWithMerkleContext';\n type: {\n vec: {\n defined: 'PackedCompressedAccountWithMerkleContext';\n };\n };\n },\n {\n name: 'outputCompressedAccounts';\n type: {\n vec: {\n defined: 'OutputCompressedAccountWithPackedContext';\n };\n };\n },\n {\n name: 'relayFee';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'newAddressParams';\n type: {\n vec: {\n defined: 'NewAddressParamsPacked';\n };\n };\n },\n {\n name: 'compressOrDecompressLamports';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'isCompress';\n type: 'bool';\n },\n ];\n };\n },\n {\n name: 'InstructionDataInvokeCpi';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'proof';\n type: {\n option: {\n defined: 'CompressedProof';\n };\n };\n },\n {\n name: 'newAddressParams';\n type: {\n vec: {\n defined: 'NewAddressParamsPacked';\n };\n };\n },\n {\n name: 'inputCompressedAccountsWithMerkleContext';\n type: {\n vec: {\n defined: 'PackedCompressedAccountWithMerkleContext';\n };\n };\n },\n {\n name: 'outputCompressedAccounts';\n type: {\n vec: {\n defined: 'OutputCompressedAccountWithPackedContext';\n };\n };\n },\n {\n name: 'relayFee';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'compressOrDecompressLamports';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'isCompress';\n type: 'bool';\n },\n {\n name: 'cpiContext';\n type: {\n option: {\n defined: 'CompressedCpiContext';\n };\n };\n },\n ];\n };\n },\n {\n name: 'MerkleTreeSequenceNumber';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'pubkey';\n type: 'publicKey';\n },\n {\n name: 'seq';\n type: 'u64';\n },\n ];\n };\n },\n {\n name: 'NewAddressParamsPacked';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'seed';\n type: {\n array: ['u8', 32];\n };\n },\n {\n name: 'addressQueueAccountIndex';\n type: 'u8';\n },\n {\n name: 'addressMerkleTreeAccountIndex';\n type: 'u8';\n },\n {\n name: 'addressMerkleTreeRootIndex';\n type: 'u16';\n },\n ];\n };\n },\n {\n name: 'OutputCompressedAccountWithPackedContext';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'compressedAccount';\n type: {\n defined: 'CompressedAccount';\n };\n },\n {\n name: 'merkleTreeIndex';\n type: 'u8';\n },\n ];\n };\n },\n {\n name: 'PackedCompressedAccountWithMerkleContext';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'compressedAccount';\n type: {\n defined: 'CompressedAccount';\n };\n },\n {\n name: 'merkleContext';\n type: {\n defined: 'PackedMerkleContext';\n };\n },\n {\n name: 'rootIndex';\n docs: [\n 'Index of root used in inclusion validity proof.',\n ];\n type: 'u16';\n },\n {\n name: 'readOnly';\n docs: [\n 'Placeholder to mark accounts read-only unimplemented set to false.',\n ];\n type: 'bool';\n },\n ];\n };\n },\n {\n name: 'PackedMerkleContext';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'merkleTreePubkeyIndex';\n type: 'u8';\n },\n {\n name: 'queuePubkeyIndex';\n type: 'u8';\n },\n {\n name: 'leafIndex';\n type: 'u32';\n },\n {\n name: 'proveByIndex';\n type: 'bool';\n },\n ];\n };\n },\n {\n name: 'PackedTokenTransferOutputData';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'owner';\n type: 'publicKey';\n },\n {\n name: 'amount';\n type: 'u64';\n },\n {\n name: 'lamports';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'merkleTreeIndex';\n type: 'u8';\n },\n {\n name: 'tlv';\n docs: [\n 'Placeholder for TokenExtension tlv data (unimplemented)',\n ];\n type: {\n option: 'bytes';\n };\n },\n ];\n };\n },\n {\n name: 'PublicTransactionEvent';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'inputCompressedAccountHashes';\n type: {\n vec: {\n array: ['u8', 32];\n };\n };\n },\n {\n name: 'outputCompressedAccountHashes';\n type: {\n vec: {\n array: ['u8', 32];\n };\n };\n },\n {\n name: 'outputCompressedAccounts';\n type: {\n vec: {\n defined: 'OutputCompressedAccountWithPackedContext';\n };\n };\n },\n {\n name: 'outputLeafIndices';\n type: {\n vec: 'u32';\n };\n },\n {\n name: 'sequenceNumbers';\n type: {\n vec: {\n defined: 'MerkleTreeSequenceNumber';\n };\n };\n },\n {\n name: 'relayFee';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'isCompress';\n type: 'bool';\n },\n {\n name: 'compressOrDecompressLamports';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'pubkeyArray';\n type: {\n vec: 'publicKey';\n };\n },\n {\n name: 'message';\n type: {\n option: 'bytes';\n };\n },\n ];\n };\n },\n {\n name: 'QueueIndex';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'queueId';\n docs: ['Id of queue in queue account.'];\n type: 'u8';\n },\n {\n name: 'index';\n docs: ['Index of compressed account hash in queue.'];\n type: 'u16';\n },\n ];\n };\n },\n {\n name: 'TokenData';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'mint';\n docs: ['The mint associated with this account'];\n type: 'publicKey';\n },\n {\n name: 'owner';\n docs: ['The owner of this account.'];\n type: 'publicKey';\n },\n {\n name: 'amount';\n docs: ['The amount of tokens this account holds.'];\n type: 'u64';\n },\n {\n name: 'delegate';\n docs: [\n 'If `delegate` is `Some` then `delegated_amount` represents',\n 'the amount authorized by the delegate',\n ];\n type: {\n option: 'publicKey';\n };\n },\n {\n name: 'state';\n docs: [\"The account's state\"];\n type: {\n defined: 'AccountState';\n };\n },\n {\n name: 'tlv';\n docs: [\n 'Placeholder for TokenExtension tlv data (unimplemented)',\n ];\n type: {\n option: 'bytes';\n };\n },\n ];\n };\n },\n ];\n errors: [\n {\n code: 6000;\n name: 'PublicKeyAmountMissmatch';\n msg: 'public keys and amounts must be of same length';\n },\n {\n code: 6001;\n name: 'ComputeInputSumFailed';\n msg: 'ComputeInputSumFailed';\n },\n {\n code: 6002;\n name: 'ComputeOutputSumFailed';\n msg: 'ComputeOutputSumFailed';\n },\n {\n code: 6003;\n name: 'ComputeCompressSumFailed';\n msg: 'ComputeCompressSumFailed';\n },\n {\n code: 6004;\n name: 'ComputeDecompressSumFailed';\n msg: 'ComputeDecompressSumFailed';\n },\n {\n code: 6005;\n name: 'SumCheckFailed';\n msg: 'SumCheckFailed';\n },\n {\n code: 6006;\n name: 'DecompressRecipientUndefinedForDecompress';\n msg: 'DecompressRecipientUndefinedForDecompress';\n },\n {\n code: 6007;\n name: 'CompressedPdaUndefinedForDecompress';\n msg: 'CompressedPdaUndefinedForDecompress';\n },\n {\n code: 6008;\n name: 'DeCompressAmountUndefinedForDecompress';\n msg: 'DeCompressAmountUndefinedForDecompress';\n },\n {\n code: 6009;\n name: 'CompressedPdaUndefinedForCompress';\n msg: 'CompressedPdaUndefinedForCompress';\n },\n {\n code: 6010;\n name: 'DeCompressAmountUndefinedForCompress';\n msg: 'DeCompressAmountUndefinedForCompress';\n },\n {\n code: 6011;\n name: 'DelegateSignerCheckFailed';\n msg: 'DelegateSignerCheckFailed';\n },\n {\n code: 6012;\n name: 'MintTooLarge';\n msg: 'Minted amount greater than u64::MAX';\n },\n {\n code: 6013;\n name: 'SplTokenSupplyMismatch';\n msg: 'SplTokenSupplyMismatch';\n },\n {\n code: 6014;\n name: 'HeapMemoryCheckFailed';\n msg: 'HeapMemoryCheckFailed';\n },\n {\n code: 6015;\n name: 'InstructionNotCallable';\n msg: 'The instruction is not callable';\n },\n {\n code: 6016;\n name: 'ArithmeticUnderflow';\n msg: 'ArithmeticUnderflow';\n },\n {\n code: 6017;\n name: 'HashToFieldError';\n msg: 'HashToFieldError';\n },\n {\n code: 6018;\n name: 'InvalidAuthorityMint';\n msg: 'Expected the authority to be also a mint authority';\n },\n {\n code: 6019;\n name: 'InvalidFreezeAuthority';\n msg: 'Provided authority is not the freeze authority';\n },\n {\n code: 6020;\n name: 'InvalidDelegateIndex';\n },\n {\n code: 6021;\n name: 'TokenPoolPdaUndefined';\n },\n {\n code: 6022;\n name: 'IsTokenPoolPda';\n msg: 'Compress or decompress recipient is the same account as the token pool pda.';\n },\n {\n code: 6023;\n name: 'InvalidTokenPoolPda';\n },\n {\n code: 6024;\n name: 'NoInputTokenAccountsProvided';\n },\n {\n code: 6025;\n name: 'NoInputsProvided';\n },\n {\n code: 6026;\n name: 'MintHasNoFreezeAuthority';\n },\n {\n code: 6027;\n name: 'MintWithInvalidExtension';\n },\n {\n code: 6028;\n name: 'InsufficientTokenAccountBalance';\n msg: 'The token account balance is less than the remaining amount.';\n },\n {\n code: 6029;\n name: 'InvalidTokenPoolBump';\n msg: 'Max number of token pools reached.';\n },\n {\n code: 6030;\n name: 'FailedToDecompress';\n },\n {\n code: 6031;\n name: 'FailedToBurnSplTokensFromTokenPool';\n },\n {\n code: 6032;\n name: 'NoMatchingBumpFound';\n },\n ];\n};\nexport const IDL: LightCompressedToken = {\n version: '1.2.0',\n name: 'light_compressed_token',\n instructions: [\n {\n name: 'createTokenPool',\n docs: [\n 'This instruction creates a token pool for a given mint. Every spl mint',\n 'can have one token pool. When a token is compressed the tokens are',\n 'transferrred to the token pool, and their compressed equivalent is',\n 'minted into a Merkle tree.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'tokenPoolPda',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'mint',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'tokenProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [],\n },\n {\n name: 'addTokenPool',\n docs: [\n 'This instruction creates an additional token pool for a given mint.',\n 'The maximum number of token pools per mint is 5.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'tokenPoolPda',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'existingTokenPoolPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'mint',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'tokenProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'tokenPoolIndex',\n type: 'u8',\n },\n ],\n },\n {\n name: 'mintTo',\n docs: [\n 'Mints tokens from an spl token mint to a list of compressed accounts.',\n 'Minted tokens are transferred to a pool account owned by the compressed',\n 'token program. The instruction creates one compressed output account for',\n 'every amount and pubkey input pair. A constant amount of lamports can be',\n 'transferred to each output account to enable. A use case to add lamports',\n 'to a compressed token account is to prevent spam. This is the only way',\n 'to add lamports to a compressed token account.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'mint',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'tokenPoolPda',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'tokenProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n docs: ['programs'],\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'merkleTree',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'solPoolPda',\n isMut: true,\n isSigner: false,\n isOptional: true,\n },\n ],\n args: [\n {\n name: 'publicKeys',\n type: {\n vec: 'publicKey',\n },\n },\n {\n name: 'amounts',\n type: {\n vec: 'u64',\n },\n },\n {\n name: 'lamports',\n type: {\n option: 'u64',\n },\n },\n ],\n },\n {\n name: 'compressSplTokenAccount',\n docs: [\n 'Compresses the balance of an spl token account sub an optional remaining',\n 'amount. This instruction does not close the spl token account. To close',\n 'the account bundle a close spl account instruction in your transaction.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ],\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n docs: ['this program is the signer of the cpi.'],\n },\n {\n name: 'tokenPoolPda',\n isMut: true,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'compressOrDecompressTokenAccount',\n isMut: true,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'tokenProgram',\n isMut: false,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'owner',\n type: 'publicKey',\n },\n {\n name: 'remainingAmount',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'cpiContext',\n type: {\n option: {\n defined: 'CompressedCpiContext',\n },\n },\n },\n ],\n },\n {\n name: 'transfer',\n docs: [\n 'Transfers compressed tokens from one account to another. All accounts',\n 'must be of the same mint. Additional spl tokens can be compressed or',\n 'decompressed. In one transaction only compression or decompression is',\n 'possible. Lamports can be transferred alongside tokens. If output token',\n 'accounts specify less lamports than inputs the remaining lamports are',\n 'transferred to an output compressed account. Signer must be owner or',\n 'delegate. If a delegated token account is transferred the delegate is',\n 'not preserved.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ],\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n docs: ['this program is the signer of the cpi.'],\n },\n {\n name: 'tokenPoolPda',\n isMut: true,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'compressOrDecompressTokenAccount',\n isMut: true,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'tokenProgram',\n isMut: false,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'inputs',\n type: 'bytes',\n },\n ],\n },\n {\n name: 'approve',\n docs: [\n 'Delegates an amount to a delegate. A compressed token account is either',\n 'completely delegated or not. Prior delegates are not preserved. Cannot',\n 'be called by a delegate.',\n 'The instruction creates two output accounts:',\n '1. one account with delegated amount',\n '2. one account with remaining(change) amount',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ],\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n docs: ['this program is the signer of the cpi.'],\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'inputs',\n type: 'bytes',\n },\n ],\n },\n {\n name: 'revoke',\n docs: [\n 'Revokes a delegation. The instruction merges all inputs into one output',\n 'account. Cannot be called by a delegate. Delegates are not preserved.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ],\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n docs: ['this program is the signer of the cpi.'],\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'inputs',\n type: 'bytes',\n },\n ],\n },\n {\n name: 'freeze',\n docs: [\n 'Freezes compressed token accounts. Inputs must not be frozen. Creates as',\n 'many outputs as inputs. Balances and delegates are preserved.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n docs: ['that this program is the signer of the cpi.'],\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'mint',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'inputs',\n type: 'bytes',\n },\n ],\n },\n {\n name: 'thaw',\n docs: [\n 'Thaws frozen compressed token accounts. Inputs must be frozen. Creates',\n 'as many outputs as inputs. Balances and delegates are preserved.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n docs: ['that this program is the signer of the cpi.'],\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'mint',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'inputs',\n type: 'bytes',\n },\n ],\n },\n {\n name: 'burn',\n docs: [\n 'Burns compressed tokens and spl tokens from the pool account. Delegates',\n 'can burn tokens. The output compressed token account remains delegated.',\n 'Creates one output compressed token account.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ],\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'mint',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'tokenPoolPda',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'tokenProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'inputs',\n type: 'bytes',\n },\n ],\n },\n {\n name: 'stubIdlBuild',\n docs: [\n 'This function is a stub to allow Anchor to include the input types in',\n 'the IDL. It should not be included in production builds nor be called in',\n 'practice.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ],\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n docs: ['this program is the signer of the cpi.'],\n },\n {\n name: 'tokenPoolPda',\n isMut: true,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'compressOrDecompressTokenAccount',\n isMut: true,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'tokenProgram',\n isMut: false,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'inputs1',\n type: {\n defined: 'CompressedTokenInstructionDataTransfer',\n },\n },\n {\n name: 'inputs2',\n type: {\n defined: 'TokenData',\n },\n },\n ],\n },\n ],\n types: [\n {\n name: 'AccountState',\n type: {\n kind: 'enum',\n variants: [\n {\n name: 'Initialized',\n },\n {\n name: 'Frozen',\n },\n ],\n },\n },\n {\n name: 'CompressedAccount',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'owner',\n type: 'publicKey',\n },\n {\n name: 'lamports',\n type: 'u64',\n },\n {\n name: 'address',\n type: {\n option: {\n array: ['u8', 32],\n },\n },\n },\n {\n name: 'data',\n type: {\n option: {\n defined: 'CompressedAccountData',\n },\n },\n },\n ],\n },\n },\n {\n name: 'CompressedAccountData',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'discriminator',\n type: {\n array: ['u8', 8],\n },\n },\n {\n name: 'data',\n type: 'bytes',\n },\n {\n name: 'dataHash',\n type: {\n array: ['u8', 32],\n },\n },\n ],\n },\n },\n {\n name: 'CompressedCpiContext',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'setContext',\n docs: [\n 'Is set by the program that is invoking the CPI to signal that is should',\n 'set the cpi context.',\n ],\n type: 'bool',\n },\n {\n name: 'firstSetContext',\n docs: [\n 'Is set to wipe the cpi context since someone could have set it before',\n 'with unrelated data.',\n ],\n type: 'bool',\n },\n {\n name: 'cpiContextAccountIndex',\n docs: [\n 'Index of cpi context account in remaining accounts.',\n ],\n type: 'u8',\n },\n ],\n },\n },\n {\n name: 'CompressedProof',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'a',\n type: {\n array: ['u8', 32],\n },\n },\n {\n name: 'b',\n type: {\n array: ['u8', 64],\n },\n },\n {\n name: 'c',\n type: {\n array: ['u8', 32],\n },\n },\n ],\n },\n },\n {\n name: 'CompressedTokenInstructionDataTransfer',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'proof',\n type: {\n option: {\n defined: 'CompressedProof',\n },\n },\n },\n {\n name: 'mint',\n type: 'publicKey',\n },\n {\n name: 'delegatedTransfer',\n docs: [\n 'Is required if the signer is delegate,',\n '-> delegate is authority account,',\n 'owner = Some(owner) is the owner of the token account.',\n ],\n type: {\n option: {\n defined: 'DelegatedTransfer',\n },\n },\n },\n {\n name: 'inputTokenDataWithContext',\n type: {\n vec: {\n defined: 'InputTokenDataWithContext',\n },\n },\n },\n {\n name: 'outputCompressedAccounts',\n type: {\n vec: {\n defined: 'PackedTokenTransferOutputData',\n },\n },\n },\n {\n name: 'isCompress',\n type: 'bool',\n },\n {\n name: 'compressOrDecompressAmount',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'cpiContext',\n type: {\n option: {\n defined: 'CompressedCpiContext',\n },\n },\n },\n {\n name: 'lamportsChangeAccountMerkleTreeIndex',\n type: {\n option: 'u8',\n },\n },\n ],\n },\n },\n {\n name: 'CompressedTokenInstructionDataRevoke',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'proof',\n type: {\n option: {\n defined: 'CompressedProof',\n },\n },\n },\n {\n name: 'mint',\n type: 'publicKey',\n },\n {\n name: 'inputTokenDataWithContext',\n type: {\n vec: {\n defined: 'InputTokenDataWithContext',\n },\n },\n },\n {\n name: 'cpiContext',\n type: {\n option: {\n defined: 'CompressedCpiContext',\n },\n },\n },\n {\n name: 'outputAccountMerkleTreeIndex',\n type: 'u8',\n },\n ],\n },\n },\n {\n name: 'CompressedTokenInstructionDataApprove',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'proof',\n type: {\n option: {\n defined: 'CompressedProof',\n },\n },\n },\n {\n name: 'mint',\n type: 'publicKey',\n },\n {\n name: 'inputTokenDataWithContext',\n type: {\n vec: {\n defined: 'InputTokenDataWithContext',\n },\n },\n },\n {\n name: 'cpiContext',\n type: {\n option: {\n defined: 'CompressedCpiContext',\n },\n },\n },\n {\n name: 'delegate',\n type: 'publicKey',\n },\n {\n name: 'delegatedAmount',\n type: 'u64',\n },\n {\n name: 'delegateMerkleTreeIndex',\n type: 'u8',\n },\n {\n name: 'changeAccountMerkleTreeIndex',\n type: 'u8',\n },\n {\n name: 'delegateLamports',\n type: {\n option: 'u64',\n },\n },\n ],\n },\n },\n {\n name: 'DelegatedTransfer',\n docs: [\n 'Struct to provide the owner when the delegate is signer of the transaction.',\n ],\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'owner',\n type: 'publicKey',\n },\n {\n name: 'delegateChangeAccountIndex',\n docs: [\n 'Index of change compressed account in output compressed accounts. In',\n \"case that the delegate didn't spend the complete delegated compressed\",\n 'account balance the change compressed account will be delegated to her',\n 'as well.',\n ],\n type: {\n option: 'u8',\n },\n },\n ],\n },\n },\n {\n name: 'InputTokenDataWithContext',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'amount',\n type: 'u64',\n },\n {\n name: 'delegateIndex',\n type: {\n option: 'u8',\n },\n },\n {\n name: 'merkleContext',\n type: {\n defined: 'PackedMerkleContext',\n },\n },\n {\n name: 'rootIndex',\n type: 'u16',\n },\n {\n name: 'lamports',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'tlv',\n docs: [\n 'Placeholder for TokenExtension tlv data (unimplemented)',\n ],\n type: {\n option: 'bytes',\n },\n },\n ],\n },\n },\n {\n name: 'InstructionDataInvoke',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'proof',\n type: {\n option: {\n defined: 'CompressedProof',\n },\n },\n },\n {\n name: 'inputCompressedAccountsWithMerkleContext',\n type: {\n vec: {\n defined:\n 'PackedCompressedAccountWithMerkleContext',\n },\n },\n },\n {\n name: 'outputCompressedAccounts',\n type: {\n vec: {\n defined:\n 'OutputCompressedAccountWithPackedContext',\n },\n },\n },\n {\n name: 'relayFee',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'newAddressParams',\n type: {\n vec: {\n defined: 'NewAddressParamsPacked',\n },\n },\n },\n {\n name: 'compressOrDecompressLamports',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'isCompress',\n type: 'bool',\n },\n ],\n },\n },\n {\n name: 'InstructionDataInvokeCpi',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'proof',\n type: {\n option: {\n defined: 'CompressedProof',\n },\n },\n },\n {\n name: 'newAddressParams',\n type: {\n vec: {\n defined: 'NewAddressParamsPacked',\n },\n },\n },\n {\n name: 'inputCompressedAccountsWithMerkleContext',\n type: {\n vec: {\n defined:\n 'PackedCompressedAccountWithMerkleContext',\n },\n },\n },\n {\n name: 'outputCompressedAccounts',\n type: {\n vec: {\n defined:\n 'OutputCompressedAccountWithPackedContext',\n },\n },\n },\n {\n name: 'relayFee',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'compressOrDecompressLamports',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'isCompress',\n type: 'bool',\n },\n {\n name: 'cpiContext',\n type: {\n option: {\n defined: 'CompressedCpiContext',\n },\n },\n },\n ],\n },\n },\n {\n name: 'MerkleTreeSequenceNumber',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'pubkey',\n type: 'publicKey',\n },\n {\n name: 'seq',\n type: 'u64',\n },\n ],\n },\n },\n {\n name: 'NewAddressParamsPacked',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'seed',\n type: {\n array: ['u8', 32],\n },\n },\n {\n name: 'addressQueueAccountIndex',\n type: 'u8',\n },\n {\n name: 'addressMerkleTreeAccountIndex',\n type: 'u8',\n },\n {\n name: 'addressMerkleTreeRootIndex',\n type: 'u16',\n },\n ],\n },\n },\n {\n name: 'OutputCompressedAccountWithPackedContext',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'compressedAccount',\n type: {\n defined: 'CompressedAccount',\n },\n },\n {\n name: 'merkleTreeIndex',\n type: 'u8',\n },\n ],\n },\n },\n {\n name: 'PackedCompressedAccountWithMerkleContext',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'compressedAccount',\n type: {\n defined: 'CompressedAccount',\n },\n },\n {\n name: 'merkleContext',\n type: {\n defined: 'PackedMerkleContext',\n },\n },\n {\n name: 'rootIndex',\n docs: [\n 'Index of root used in inclusion validity proof.',\n ],\n type: 'u16',\n },\n {\n name: 'readOnly',\n docs: [\n 'Placeholder to mark accounts read-only unimplemented set to false.',\n ],\n type: 'bool',\n },\n ],\n },\n },\n {\n name: 'PackedMerkleContext',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'merkleTreePubkeyIndex',\n type: 'u8',\n },\n {\n name: 'queuePubkeyIndex',\n type: 'u8',\n },\n {\n name: 'leafIndex',\n type: 'u32',\n },\n {\n name: 'proveByIndex',\n type: 'bool',\n },\n ],\n },\n },\n {\n name: 'PackedTokenTransferOutputData',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'owner',\n type: 'publicKey',\n },\n {\n name: 'amount',\n type: 'u64',\n },\n {\n name: 'lamports',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'merkleTreeIndex',\n type: 'u8',\n },\n {\n name: 'tlv',\n docs: [\n 'Placeholder for TokenExtension tlv data (unimplemented)',\n ],\n type: {\n option: 'bytes',\n },\n },\n ],\n },\n },\n {\n name: 'PublicTransactionEvent',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'inputCompressedAccountHashes',\n type: {\n vec: {\n array: ['u8', 32],\n },\n },\n },\n {\n name: 'outputCompressedAccountHashes',\n type: {\n vec: {\n array: ['u8', 32],\n },\n },\n },\n {\n name: 'outputCompressedAccounts',\n type: {\n vec: {\n defined:\n 'OutputCompressedAccountWithPackedContext',\n },\n },\n },\n {\n name: 'outputLeafIndices',\n type: {\n vec: 'u32',\n },\n },\n {\n name: 'sequenceNumbers',\n type: {\n vec: {\n defined: 'MerkleTreeSequenceNumber',\n },\n },\n },\n {\n name: 'relayFee',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'isCompress',\n type: 'bool',\n },\n {\n name: 'compressOrDecompressLamports',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'pubkeyArray',\n type: {\n vec: 'publicKey',\n },\n },\n {\n name: 'message',\n type: {\n option: 'bytes',\n },\n },\n ],\n },\n },\n {\n name: 'QueueIndex',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'queueId',\n docs: ['Id of queue in queue account.'],\n type: 'u8',\n },\n {\n name: 'index',\n docs: ['Index of compressed account hash in queue.'],\n type: 'u16',\n },\n ],\n },\n },\n {\n name: 'TokenData',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'mint',\n docs: ['The mint associated with this account'],\n type: 'publicKey',\n },\n {\n name: 'owner',\n docs: ['The owner of this account.'],\n type: 'publicKey',\n },\n {\n name: 'amount',\n docs: ['The amount of tokens this account holds.'],\n type: 'u64',\n },\n {\n name: 'delegate',\n docs: [\n 'If `delegate` is `Some` then `delegated_amount` represents',\n 'the amount authorized by the delegate',\n ],\n type: {\n option: 'publicKey',\n },\n },\n {\n name: 'state',\n docs: [\"The account's state\"],\n type: {\n defined: 'AccountState',\n },\n },\n {\n name: 'tlv',\n docs: [\n 'Placeholder for TokenExtension tlv data (unimplemented)',\n ],\n type: {\n option: 'bytes',\n },\n },\n ],\n },\n },\n ],\n errors: [\n {\n code: 6000,\n name: 'PublicKeyAmountMissmatch',\n msg: 'public keys and amounts must be of same length',\n },\n {\n code: 6001,\n name: 'ComputeInputSumFailed',\n msg: 'ComputeInputSumFailed',\n },\n {\n code: 6002,\n name: 'ComputeOutputSumFailed',\n msg: 'ComputeOutputSumFailed',\n },\n {\n code: 6003,\n name: 'ComputeCompressSumFailed',\n msg: 'ComputeCompressSumFailed',\n },\n {\n code: 6004,\n name: 'ComputeDecompressSumFailed',\n msg: 'ComputeDecompressSumFailed',\n },\n {\n code: 6005,\n name: 'SumCheckFailed',\n msg: 'SumCheckFailed',\n },\n {\n code: 6006,\n name: 'DecompressRecipientUndefinedForDecompress',\n msg: 'DecompressRecipientUndefinedForDecompress',\n },\n {\n code: 6007,\n name: 'CompressedPdaUndefinedForDecompress',\n msg: 'CompressedPdaUndefinedForDecompress',\n },\n {\n code: 6008,\n name: 'DeCompressAmountUndefinedForDecompress',\n msg: 'DeCompressAmountUndefinedForDecompress',\n },\n {\n code: 6009,\n name: 'CompressedPdaUndefinedForCompress',\n msg: 'CompressedPdaUndefinedForCompress',\n },\n {\n code: 6010,\n name: 'DeCompressAmountUndefinedForCompress',\n msg: 'DeCompressAmountUndefinedForCompress',\n },\n {\n code: 6011,\n name: 'DelegateSignerCheckFailed',\n msg: 'DelegateSignerCheckFailed',\n },\n {\n code: 6012,\n name: 'MintTooLarge',\n msg: 'Minted amount greater than u64::MAX',\n },\n {\n code: 6013,\n name: 'SplTokenSupplyMismatch',\n msg: 'SplTokenSupplyMismatch',\n },\n {\n code: 6014,\n name: 'HeapMemoryCheckFailed',\n msg: 'HeapMemoryCheckFailed',\n },\n {\n code: 6015,\n name: 'InstructionNotCallable',\n msg: 'The instruction is not callable',\n },\n {\n code: 6016,\n name: 'ArithmeticUnderflow',\n msg: 'ArithmeticUnderflow',\n },\n {\n code: 6017,\n name: 'HashToFieldError',\n msg: 'HashToFieldError',\n },\n {\n code: 6018,\n name: 'InvalidAuthorityMint',\n msg: 'Expected the authority to be also a mint authority',\n },\n {\n code: 6019,\n name: 'InvalidFreezeAuthority',\n msg: 'Provided authority is not the freeze authority',\n },\n {\n code: 6020,\n name: 'InvalidDelegateIndex',\n },\n {\n code: 6021,\n name: 'TokenPoolPdaUndefined',\n },\n {\n code: 6022,\n name: 'IsTokenPoolPda',\n msg: 'Compress or decompress recipient is the same account as the token pool pda.',\n },\n {\n code: 6023,\n name: 'InvalidTokenPoolPda',\n },\n {\n code: 6024,\n name: 'NoInputTokenAccountsProvided',\n },\n {\n code: 6025,\n name: 'NoInputsProvided',\n },\n {\n code: 6026,\n name: 'MintHasNoFreezeAuthority',\n },\n {\n code: 6027,\n name: 'MintWithInvalidExtension',\n },\n {\n code: 6028,\n name: 'InsufficientTokenAccountBalance',\n msg: 'The token account balance is less than the remaining amount.',\n },\n {\n code: 6029,\n name: 'InvalidTokenPoolBump',\n msg: 'Max number of token pools reached.',\n },\n {\n code: 6030,\n name: 'FailedToDecompress',\n },\n {\n code: 6031,\n name: 'FailedToBurnSplTokensFromTokenPool',\n },\n {\n code: 6032,\n name: 'NoMatchingBumpFound',\n },\n ],\n};\n","import {\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionInstruction,\n TransactionSignature,\n} from '@solana/web3.js';\nimport { CompressedTokenProgram } from '../program';\nimport {\n Rpc,\n buildAndSignTx,\n sendAndConfirmTx,\n} from '@lightprotocol/stateless.js';\nimport { getTokenPoolInfos } from '../utils/get-token-pool-infos';\n\n/**\n * Register an existing mint with the CompressedToken program\n *\n * @param rpc RPC connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param confirmOptions Options for confirming the transaction\n * @param tokenProgramId Optional: Address of the token program. Default:\n * TOKEN_PROGRAM_ID\n *\n * @return transaction signature\n */\nexport async function createTokenPool(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n confirmOptions?: ConfirmOptions,\n tokenProgramId?: PublicKey,\n): Promise<TransactionSignature> {\n tokenProgramId = tokenProgramId\n ? tokenProgramId\n : await CompressedTokenProgram.getMintProgramId(mint, rpc);\n\n const ix = await CompressedTokenProgram.createTokenPool({\n feePayer: payer.publicKey,\n mint,\n tokenProgramId,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n\n const tx = buildAndSignTx([ix], payer, blockhash);\n\n const txId = await sendAndConfirmTx(rpc, tx, confirmOptions);\n\n return txId;\n}\n\n/**\n * Create additional token pools for an existing mint\n *\n * @param rpc RPC connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param numMaxAdditionalPools Number of additional token pools to create. Max\n * 3.\n * @param confirmOptions Optional: Options for confirming the transaction\n * @param tokenProgramId Optional: Address of the token program. Default:\n * TOKEN_PROGRAM_ID\n *\n * @return transaction signature\n */\nexport async function addTokenPools(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n numMaxAdditionalPools: number,\n confirmOptions?: ConfirmOptions,\n tokenProgramId?: PublicKey,\n) {\n tokenProgramId = tokenProgramId\n ? tokenProgramId\n : await CompressedTokenProgram.getMintProgramId(mint, rpc);\n const instructions: TransactionInstruction[] = [];\n\n const infos = (await getTokenPoolInfos(rpc, mint)).slice(0, 4);\n\n // Get indices of uninitialized pools\n const uninitializedIndices = [];\n for (let i = 0; i < infos.length; i++) {\n if (!infos[i].isInitialized) {\n uninitializedIndices.push(i);\n }\n }\n\n // Create instructions for requested number of pools\n for (let i = 0; i < numMaxAdditionalPools; i++) {\n if (i >= uninitializedIndices.length) {\n break;\n }\n\n instructions.push(\n await CompressedTokenProgram.addTokenPool({\n mint,\n feePayer: payer.publicKey,\n tokenProgramId,\n poolIndex: uninitializedIndices[i],\n }),\n );\n }\n const { blockhash } = await rpc.getLatestBlockhash();\n\n const tx = buildAndSignTx(instructions, payer, blockhash);\n\n const txId = await sendAndConfirmTx(rpc, tx, confirmOptions);\n\n return txId;\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n bn,\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n} from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport { CompressedTokenProgram } from '../program';\nimport {\n selectMinCompressedTokenAccountsForTransfer,\n selectTokenAccountsForApprove,\n} from '../utils';\n\n/**\n * Approve a delegate to spend tokens\n *\n * @param rpc Rpc to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param amount Number of tokens to delegate\n * @param owner Owner of the SPL token account.\n * @param delegate Address of the delegate\n * @param confirmOptions Options for confirming the transaction\n *\n * @return Signature of the confirmed transaction\n */\nexport async function approve(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n amount: number | BN,\n owner: Signer,\n delegate: PublicKey,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n amount = bn(amount);\n const compressedTokenAccounts = await rpc.getCompressedTokenAccountsByOwner(\n owner.publicKey,\n {\n mint,\n },\n );\n\n const [inputAccounts] = selectTokenAccountsForApprove(\n compressedTokenAccounts.items,\n amount,\n );\n\n const proof = await rpc.getValidityProofV0(\n inputAccounts.map(account => ({\n hash: account.compressedAccount.hash,\n tree: account.compressedAccount.treeInfo.tree,\n queue: account.compressedAccount.treeInfo.queue,\n })),\n );\n\n const ix = await CompressedTokenProgram.approve({\n payer: payer.publicKey,\n inputCompressedTokenAccounts: inputAccounts,\n toAddress: delegate,\n amount,\n recentInputStateRootIndices: proof.rootIndices,\n recentValidityProof: proof.compressedProof,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n const signedTx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 350_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n\n return sendAndConfirmTx(rpc, signedTx, confirmOptions);\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport BN from 'bn.js';\nimport {\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n selectStateTreeInfo,\n toArray,\n TreeInfo,\n} from '@lightprotocol/stateless.js';\nimport { CompressedTokenProgram } from '../program';\nimport { getOrCreateAssociatedTokenAccount } from '@solana/spl-token';\n\nimport {\n getTokenPoolInfos,\n selectTokenPoolInfo,\n TokenPoolInfo,\n} from '../utils/get-token-pool-infos';\n\n/**\n * Mint compressed tokens to a solana address from an external mint authority\n *\n * @param rpc Rpc to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param toPubkey Address of the account to mint to\n * @param authority Minting authority\n * @param amount Amount to mint\n * @param outputStateTreeInfo Optional: State tree account that the compressed\n * tokens should be inserted into. Defaults to a\n * shared state tree account.\n * @param tokenPoolInfo Optional: Token pool info.\n * @param confirmOptions Options for confirming the transaction\n *\n * @return Signature of the confirmed transaction\n */\nexport async function approveAndMintTo(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n toPubkey: PublicKey,\n authority: Signer,\n amount: number | BN,\n outputStateTreeInfo?: TreeInfo,\n tokenPoolInfo?: TokenPoolInfo,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n outputStateTreeInfo =\n outputStateTreeInfo ??\n selectStateTreeInfo(await rpc.getStateTreeInfos());\n tokenPoolInfo =\n tokenPoolInfo ??\n selectTokenPoolInfo(await getTokenPoolInfos(rpc, mint));\n\n const authorityTokenAccount = await getOrCreateAssociatedTokenAccount(\n rpc,\n payer,\n mint,\n authority.publicKey,\n undefined,\n undefined,\n confirmOptions,\n tokenPoolInfo.tokenProgram,\n );\n\n const ixs = await CompressedTokenProgram.approveAndMintTo({\n feePayer: payer.publicKey,\n mint,\n authority: authority.publicKey,\n authorityTokenAccount: authorityTokenAccount.address,\n amount,\n toPubkey,\n outputStateTreeInfo,\n tokenPoolInfo,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [authority]);\n\n const tx = buildAndSignTx(\n [\n ComputeBudgetProgram.setComputeUnitLimit({\n units: 150_000 + toArray(amount).length * 20_000,\n }),\n ...ixs,\n ],\n payer,\n blockhash,\n additionalSigners,\n );\n\n return await sendAndConfirmTx(rpc, tx, confirmOptions);\n}\n","import {\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n ComputeBudgetProgram,\n} from '@solana/web3.js';\nimport {\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n selectStateTreeInfo,\n toArray,\n TreeInfo,\n} from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport { CompressedTokenProgram } from '../program';\nimport {\n getTokenPoolInfos,\n selectTokenPoolInfo,\n TokenPoolInfo,\n} from '../utils/get-token-pool-infos';\n\n/**\n * Compress SPL tokens\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param amount Number of tokens to compress.\n * @param owner Owner of the SPL token account.\n * @param sourceTokenAccount Source SPL token account. (ATA)\n * @param toAddress Recipient owner address.\n * @param outputStateTreeInfo Optional: State tree account that the compressed\n * tokens should be inserted into. Defaults to a\n * shared state tree account.\n * @param tokenPoolInfo Optional: Token pool info.\n * @param confirmOptions Options for confirming the transaction\n *\n * @return Signature of the confirmed transaction\n */\nexport async function compress(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n amount: number | BN | number[] | BN[],\n owner: Signer,\n sourceTokenAccount: PublicKey,\n toAddress: PublicKey | Array<PublicKey>,\n outputStateTreeInfo?: TreeInfo,\n tokenPoolInfo?: TokenPoolInfo,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n outputStateTreeInfo =\n outputStateTreeInfo ??\n selectStateTreeInfo(await rpc.getStateTreeInfos());\n tokenPoolInfo =\n tokenPoolInfo ??\n selectTokenPoolInfo(await getTokenPoolInfos(rpc, mint));\n\n const compressIx = await CompressedTokenProgram.compress({\n payer: payer.publicKey,\n owner: owner.publicKey,\n source: sourceTokenAccount,\n toAddress,\n amount,\n mint,\n outputStateTreeInfo,\n tokenPoolInfo,\n });\n\n const blockhashCtx = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n const signedTx = buildAndSignTx(\n [\n ComputeBudgetProgram.setComputeUnitLimit({\n units: 130_000 + toArray(amount).length * 20_000,\n }),\n compressIx,\n ],\n payer,\n blockhashCtx.blockhash,\n additionalSigners,\n );\n\n return await sendAndConfirmTx(rpc, signedTx, confirmOptions, blockhashCtx);\n}\n","import {\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n ComputeBudgetProgram,\n} from '@solana/web3.js';\nimport {\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n selectStateTreeInfo,\n TreeInfo,\n} from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport {\n getTokenPoolInfos,\n selectTokenPoolInfo,\n TokenPoolInfo,\n} from '../utils/get-token-pool-infos';\nimport { CompressedTokenProgram } from '../program';\n\n/**\n * Compress SPL tokens into compressed token format\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param owner Owner of the token account\n * @param tokenAccount Token account to compress\n * @param remainingAmount Optional: amount to leave in token account.\n * Default: 0\n * @param outputStateTreeInfo Optional: State tree account that the compressed\n * account into\n * @param tokenPoolInfo Optional: Token pool info.\n * @param confirmOptions Options for confirming the transaction\n\n *\n * @return Signature of the confirmed transaction\n */\nexport async function compressSplTokenAccount(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n owner: Signer,\n tokenAccount: PublicKey,\n remainingAmount?: BN,\n outputStateTreeInfo?: TreeInfo,\n tokenPoolInfo?: TokenPoolInfo,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n outputStateTreeInfo =\n outputStateTreeInfo ??\n selectStateTreeInfo(await rpc.getStateTreeInfos());\n tokenPoolInfo =\n tokenPoolInfo ??\n selectTokenPoolInfo(await getTokenPoolInfos(rpc, mint));\n\n const compressIx = await CompressedTokenProgram.compressSplTokenAccount({\n feePayer: payer.publicKey,\n authority: owner.publicKey,\n tokenAccount,\n mint,\n remainingAmount,\n outputStateTreeInfo,\n tokenPoolInfo,\n });\n\n const blockhashCtx = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n\n const signedTx = buildAndSignTx(\n [\n ComputeBudgetProgram.setComputeUnitLimit({\n units: 150_000,\n }),\n compressIx,\n ],\n payer,\n blockhashCtx.blockhash,\n additionalSigners,\n );\n\n return await sendAndConfirmTx(rpc, signedTx, confirmOptions, blockhashCtx);\n}\n","import {\n ConfirmOptions,\n Keypair,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport { CompressedTokenProgram } from '../program';\nimport {\n MINT_SIZE,\n TOKEN_2022_PROGRAM_ID,\n TOKEN_PROGRAM_ID,\n} from '@solana/spl-token';\nimport {\n Rpc,\n buildAndSignTx,\n dedupeSigner,\n sendAndConfirmTx,\n} from '@lightprotocol/stateless.js';\n\n/**\n * Create and initialize a new compressed token mint\n *\n * @param rpc RPC connection to use\n * @param payer Fee payer\n * @param mintAuthority Account that will control minting\n * @param decimals Location of the decimal place\n * @param keypair Optional: Mint keypair. Defaults to a random\n * keypair.\n * @param confirmOptions Options for confirming the transaction\n * @param tokenProgramId Optional: Program ID for the token. Defaults to\n * TOKEN_PROGRAM_ID.\n * @param freezeAuthority Optional: Account that will control freeze and thaw.\n * Defaults to none.\n *\n * @return Object with mint address and transaction signature\n */\nexport async function createMint(\n rpc: Rpc,\n payer: Signer,\n mintAuthority: PublicKey | Signer,\n decimals: number,\n keypair = Keypair.generate(),\n confirmOptions?: ConfirmOptions,\n tokenProgramId?: PublicKey | boolean,\n freezeAuthority?: PublicKey | Signer,\n): Promise<{ mint: PublicKey; transactionSignature: TransactionSignature }> {\n const rentExemptBalance =\n await rpc.getMinimumBalanceForRentExemption(MINT_SIZE);\n\n // If true, uses TOKEN_2022_PROGRAM_ID.\n // If false or undefined, defaults to TOKEN_PROGRAM_ID.\n // Otherwise, uses the provided tokenProgramId.\n const resolvedTokenProgramId =\n tokenProgramId === true\n ? TOKEN_2022_PROGRAM_ID\n : tokenProgramId || TOKEN_PROGRAM_ID;\n\n const ixs = await CompressedTokenProgram.createMint({\n feePayer: payer.publicKey,\n mint: keypair.publicKey,\n decimals,\n authority:\n 'secretKey' in mintAuthority\n ? mintAuthority.publicKey\n : mintAuthority,\n freezeAuthority:\n freezeAuthority && 'secretKey' in freezeAuthority\n ? freezeAuthority.publicKey\n : (freezeAuthority ?? null),\n rentExemptBalance,\n tokenProgramId: resolvedTokenProgramId,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n\n const additionalSigners = dedupeSigner(\n payer,\n [mintAuthority, freezeAuthority].filter(\n (signer): signer is Signer =>\n signer != undefined && 'secretKey' in signer,\n ),\n );\n\n const tx = buildAndSignTx(ixs, payer, blockhash, [\n ...additionalSigners,\n keypair,\n ]);\n const txId = await sendAndConfirmTx(rpc, tx, confirmOptions);\n\n return { mint: keypair.publicKey, transactionSignature: txId };\n}\n","import { PublicKey, Signer, TransactionSignature } from '@solana/web3.js';\nimport {\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n} from '@lightprotocol/stateless.js';\n\nimport { CompressedTokenProgram } from '../program';\n\n/**\n * Create a lookup table for the token program's default accounts\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param authority Authority of the lookup table\n * @param mints Optional array of mint public keys to include in\n * the lookup table\n * @param additionalAccounts Optional array of additional account public keys\n * to include in the lookup table\n *\n * @return Object with transaction signatures and the address of the created\n * lookup table\n */\nexport async function createTokenProgramLookupTable(\n rpc: Rpc,\n payer: Signer,\n authority: Signer,\n mints?: PublicKey[],\n additionalAccounts?: PublicKey[],\n): Promise<{ txIds: TransactionSignature[]; address: PublicKey }> {\n const recentSlot = await rpc.getSlot('finalized');\n const { instructions, address } =\n await CompressedTokenProgram.createTokenProgramLookupTable({\n payer: payer.publicKey,\n authority: authority.publicKey,\n mints,\n remainingAccounts: additionalAccounts,\n recentSlot,\n });\n\n const additionalSigners = dedupeSigner(payer, [authority]);\n const txIds = [];\n\n for (const instruction of instructions) {\n const blockhashCtx = await rpc.getLatestBlockhash();\n const signedTx = buildAndSignTx(\n [instruction],\n payer,\n blockhashCtx.blockhash,\n additionalSigners,\n );\n const txId = await sendAndConfirmTx(\n rpc,\n signedTx,\n { commitment: 'finalized' },\n blockhashCtx,\n );\n txIds.push(txId);\n }\n\n return { txIds, address };\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n bn,\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n} from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport { CompressedTokenProgram } from '../program';\nimport { selectMinCompressedTokenAccountsForTransfer } from '../utils';\nimport {\n selectTokenPoolInfosForDecompression,\n TokenPoolInfo,\n} from '../utils/get-token-pool-infos';\nimport { getTokenPoolInfos } from '../utils/get-token-pool-infos';\n\n/**\n * Decompress compressed tokens\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param amount Number of tokens to transfer\n * @param owner Owner of the compressed tokens\n * @param toAddress Destination **uncompressed** token account\n * address. (ATA)\n * @param tokenPoolInfos Optional: Token pool infos.\n * @param confirmOptions Options for confirming the transaction\n *\n * @return confirmed transaction signature\n */\nexport async function decompress(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n amount: number | BN,\n owner: Signer,\n toAddress: PublicKey,\n tokenPoolInfos?: TokenPoolInfo[],\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n amount = bn(amount);\n\n const compressedTokenAccounts = await rpc.getCompressedTokenAccountsByOwner(\n owner.publicKey,\n {\n mint,\n },\n );\n\n const [inputAccounts] = selectMinCompressedTokenAccountsForTransfer(\n compressedTokenAccounts.items,\n amount,\n );\n\n const proof = await rpc.getValidityProofV0(\n inputAccounts.map(account => ({\n hash: account.compressedAccount.hash,\n tree: account.compressedAccount.treeInfo.tree,\n queue: account.compressedAccount.treeInfo.queue,\n })),\n );\n\n tokenPoolInfos = tokenPoolInfos ?? (await getTokenPoolInfos(rpc, mint));\n\n const selectedTokenPoolInfos = selectTokenPoolInfosForDecompression(\n tokenPoolInfos,\n amount,\n );\n\n const ix = await CompressedTokenProgram.decompress({\n payer: payer.publicKey,\n inputCompressedTokenAccounts: inputAccounts,\n toAddress,\n amount,\n tokenPoolInfos: selectedTokenPoolInfos,\n recentInputStateRootIndices: proof.rootIndices,\n recentValidityProof: proof.compressedProof,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n const signedTx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 350_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n return await sendAndConfirmTx(rpc, signedTx, confirmOptions);\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n bn,\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n} from '@lightprotocol/stateless.js';\n\nimport BN from 'bn.js';\n\nimport { CompressedTokenProgram } from '../program';\nimport { selectMinCompressedTokenAccountsForTransfer } from '../utils';\nimport {\n selectTokenPoolInfosForDecompression,\n TokenPoolInfo,\n} from '../utils/get-token-pool-infos';\nimport { getTokenPoolInfos } from '../utils/get-token-pool-infos';\n\n/**\n * Decompress delegated compressed tokens. Remaining compressed tokens are\n * returned to the owner without delegation.\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param amount Number of tokens to decompress\n * @param owner Owner of the compressed tokens\n * @param toAddress Destination **uncompressed** token account\n * address. (ATA)\n * @param tokenPoolInfos Optional: Token pool infos.\n * @param confirmOptions Options for confirming the transaction\n *\n * @return Signature of the confirmed transaction\n */\nexport async function decompressDelegated(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n amount: number | BN,\n owner: Signer,\n toAddress: PublicKey,\n tokenPoolInfos?: TokenPoolInfo[],\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n amount = bn(amount);\n\n const compressedTokenAccounts =\n await rpc.getCompressedTokenAccountsByDelegate(owner.publicKey, {\n mint,\n });\n\n const [inputAccounts] = selectMinCompressedTokenAccountsForTransfer(\n compressedTokenAccounts.items,\n amount,\n );\n\n const proof = await rpc.getValidityProofV0(\n inputAccounts.map(account => ({\n hash: account.compressedAccount.hash,\n tree: account.compressedAccount.treeInfo.tree,\n queue: account.compressedAccount.treeInfo.queue,\n })),\n );\n\n const tokenPoolInfosToUse =\n tokenPoolInfos ??\n selectTokenPoolInfosForDecompression(\n await getTokenPoolInfos(rpc, mint),\n amount,\n );\n\n const ix = await CompressedTokenProgram.decompress({\n payer: payer.publicKey,\n inputCompressedTokenAccounts: inputAccounts,\n toAddress,\n amount,\n recentInputStateRootIndices: proof.rootIndices,\n recentValidityProof: proof.compressedProof,\n tokenPoolInfos: tokenPoolInfosToUse,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n const signedTx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 350_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n\n return sendAndConfirmTx(rpc, signedTx, confirmOptions);\n}\n","import { PublicKey } from '@solana/web3.js';\nimport BN from 'bn.js';\nimport { Buffer } from 'buffer';\nimport {\n ValidityProof,\n PackedMerkleContextLegacy,\n CompressedCpiContext,\n} from '@lightprotocol/stateless.js';\nimport { TokenPoolInfo } from './utils/get-token-pool-infos';\n\nexport type TokenTransferOutputData = {\n /**\n * The owner of the output token account\n */\n owner: PublicKey;\n /**\n * The amount of tokens of the output token account\n */\n amount: BN;\n /**\n * lamports associated with the output token account\n */\n lamports: BN | null;\n /**\n * TokenExtension tlv\n */\n tlv: Buffer | null;\n};\n\nexport type PackedTokenTransferOutputData = {\n /**\n * The owner of the output token account\n */\n owner: PublicKey;\n /**\n * The amount of tokens of the output token account\n */\n amount: BN;\n /**\n * lamports associated with the output token account\n */\n lamports: BN | null;\n /**\n * Merkle tree pubkey index in remaining accounts\n */\n merkleTreeIndex: number;\n /**\n * TokenExtension tlv\n */\n tlv: Buffer | null;\n};\n\nexport type InputTokenDataWithContext = {\n amount: BN;\n delegateIndex: number | null;\n merkleContext: PackedMerkleContextLegacy;\n rootIndex: number;\n lamports: BN | null;\n tlv: Buffer | null;\n};\n\nexport type DelegatedTransfer = {\n owner: PublicKey;\n delegateChangeAccountIndex: number | null;\n};\n\nexport type BatchCompressInstructionData = {\n pubkeys: PublicKey[];\n amounts: BN[] | null;\n lamports: BN | null;\n amount: BN | null;\n index: number;\n bump: number;\n};\n\nexport type MintToInstructionData = {\n recipients: PublicKey[];\n amounts: BN[];\n lamports: BN | null;\n};\nexport type CompressSplTokenAccountInstructionData = {\n owner: PublicKey;\n remainingAmount: BN | null;\n cpiContext: CompressedCpiContext | null;\n};\n\nexport function isSingleTokenPoolInfo(\n tokenPoolInfos: TokenPoolInfo | TokenPoolInfo[],\n): tokenPoolInfos is TokenPoolInfo {\n return !Array.isArray(tokenPoolInfos);\n}\n\nexport type CompressedTokenInstructionDataTransfer = {\n /**\n * Validity proof\n */\n proof: ValidityProof | null;\n /**\n * The mint of the transfer\n */\n mint: PublicKey;\n /**\n * Whether the signer is a delegate\n */\n delegatedTransfer: DelegatedTransfer | null;\n /**\n * Input token data with packed merkle context\n */\n inputTokenDataWithContext: InputTokenDataWithContext[];\n /**\n * Data of the output token accounts\n */\n outputCompressedAccounts: PackedTokenTransferOutputData[];\n /**\n * Whether it's a compress or decompress action if compressOrDecompressAmount is non-null\n */\n isCompress: boolean;\n /**\n * If null, it's a transfer.\n * If some, the amount that is being deposited into (compress) or withdrawn from (decompress) the token escrow\n */\n compressOrDecompressAmount: BN | null;\n /**\n * CPI context if\n */\n cpiContext: CompressedCpiContext | null;\n /**\n * The index of the Merkle tree for a lamport change account.\n */\n lamportsChangeAccountMerkleTreeIndex: number | null;\n};\n\nexport type TokenData = {\n /**\n * The mint associated with this account\n */\n mint: PublicKey;\n /**\n * The owner of this account\n */\n owner: PublicKey;\n /**\n * The amount of tokens this account holds\n */\n amount: BN;\n /**\n * If `delegate` is `Some` then `delegated_amount` represents the amount\n * authorized by the delegate\n */\n delegate: PublicKey | null;\n /**\n * The account's state\n */\n state: number;\n /**\n * TokenExtension tlv\n */\n tlv: Buffer | null;\n};\n\nexport type CompressedTokenInstructionDataApprove = {\n proof: ValidityProof | null;\n mint: PublicKey;\n inputTokenDataWithContext: InputTokenDataWithContext[];\n cpiContext: CompressedCpiContext | null;\n delegate: PublicKey;\n delegatedAmount: BN;\n delegateMerkleTreeIndex: number;\n changeAccountMerkleTreeIndex: number;\n delegateLamports: BN | null;\n};\n\nexport type CompressedTokenInstructionDataRevoke = {\n proof: ValidityProof | null;\n mint: PublicKey;\n inputTokenDataWithContext: InputTokenDataWithContext[];\n cpiContext: CompressedCpiContext | null;\n outputAccountMerkleTreeIndex: number;\n};\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n Rpc,\n dedupeSigner,\n buildAndSignTx,\n sendAndConfirmTx,\n bn,\n} from '@lightprotocol/stateless.js';\nimport { CompressedTokenProgram } from '../program';\n\n/**\n * Merge multiple compressed token accounts for a given mint into a single\n * account\n *\n * @param rpc RPC connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param owner Owner of the token accounts to be merged\n * @param confirmOptions Options for confirming the transaction\n *\n * @return confirmed transaction signature\n */\nexport async function mergeTokenAccounts(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n owner: Signer,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n const compressedTokenAccounts = await rpc.getCompressedTokenAccountsByOwner(\n owner.publicKey,\n { mint },\n );\n\n if (compressedTokenAccounts.items.length === 0) {\n throw new Error(\n `No compressed token accounts found for mint ${mint.toBase58()}`,\n );\n }\n\n const instructions = [\n ComputeBudgetProgram.setComputeUnitLimit({ units: 1_000_000 }),\n ];\n\n for (\n let i = 0;\n i < compressedTokenAccounts.items.slice(0, 8).length;\n i += 4\n ) {\n const batch = compressedTokenAccounts.items.slice(i, i + 4);\n\n const proof = await rpc.getValidityProof(\n batch.map(account => bn(account.compressedAccount.hash)),\n );\n\n const batchInstructions =\n await CompressedTokenProgram.mergeTokenAccounts({\n payer: payer.publicKey,\n owner: owner.publicKey,\n inputCompressedTokenAccounts: batch,\n mint,\n recentValidityProof: proof.compressedProof,\n recentInputStateRootIndices: proof.rootIndices,\n });\n\n instructions.push(...batchInstructions);\n }\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n\n const signedTx = buildAndSignTx(\n instructions,\n payer,\n blockhash,\n additionalSigners,\n );\n\n return sendAndConfirmTx(rpc, signedTx, confirmOptions);\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport BN from 'bn.js';\nimport {\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n selectStateTreeInfo,\n TreeInfo,\n} from '@lightprotocol/stateless.js';\nimport { CompressedTokenProgram } from '../program';\nimport {\n getTokenPoolInfos,\n selectTokenPoolInfo,\n TokenPoolInfo,\n} from '../utils/get-token-pool-infos';\n\n/**\n * Mint compressed tokens to a solana address\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param toPubkey Address of the account to mint to. Can be an\n * array of addresses if the amount is an array of\n * amounts.\n * @param authority Mint authority\n * @param amount Amount to mint. Pass an array of amounts if the\n * toPubkey is an array of addresses.\n * @param outputStateTreeInfo Optional: State tree account that the compressed\n * tokens should be part of. Defaults to the\n * default state tree account.\n * @param tokenPoolInfo Optional: Token pool information\n * @param confirmOptions Options for confirming the transaction\n *\n * @return Signature of the confirmed transaction\n */\nexport async function mintTo(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n toPubkey: PublicKey | PublicKey[],\n authority: Signer,\n amount: number | BN | number[] | BN[],\n outputStateTreeInfo?: TreeInfo,\n tokenPoolInfo?: TokenPoolInfo,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n outputStateTreeInfo =\n outputStateTreeInfo ??\n selectStateTreeInfo(await rpc.getStateTreeInfos());\n tokenPoolInfo =\n tokenPoolInfo ??\n selectTokenPoolInfo(await getTokenPoolInfos(rpc, mint));\n\n const ix = await CompressedTokenProgram.mintTo({\n feePayer: payer.publicKey,\n mint,\n authority: authority.publicKey,\n amount,\n toPubkey,\n outputStateTreeInfo,\n tokenPoolInfo,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [authority]);\n\n const tx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 1_000_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n\n return sendAndConfirmTx(rpc, tx, confirmOptions);\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n ParsedTokenAccount,\n} from '@lightprotocol/stateless.js';\nimport { CompressedTokenProgram } from '../program';\n\n/**\n * Revoke one or more delegated token accounts\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param accounts Delegated compressed token accounts to revoke\n * @param owner Owner of the compressed tokens\n * @param confirmOptions Options for confirming the transaction\n *\n * @return Signature of the confirmed transaction\n */\nexport async function revoke(\n rpc: Rpc,\n payer: Signer,\n accounts: ParsedTokenAccount[],\n owner: Signer,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n const proof = await rpc.getValidityProofV0(\n accounts.map(account => ({\n hash: account.compressedAccount.hash,\n tree: account.compressedAccount.treeInfo.tree,\n queue: account.compressedAccount.treeInfo.queue,\n })),\n );\n checkOwner(owner, accounts);\n checkIsDelegated(accounts);\n\n const ix = await CompressedTokenProgram.revoke({\n payer: payer.publicKey,\n inputCompressedTokenAccounts: accounts,\n recentInputStateRootIndices: proof.rootIndices,\n recentValidityProof: proof.compressedProof,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n const signedTx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 500_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n\n return sendAndConfirmTx(rpc, signedTx, confirmOptions);\n}\n\nfunction checkOwner(owner: Signer, accounts: ParsedTokenAccount[]) {\n if (!owner.publicKey.equals(accounts[0].parsed.owner)) {\n throw new Error(\n `Owner ${owner.publicKey.toBase58()} does not match account ${accounts[0].parsed.owner.toBase58()}`,\n );\n }\n}\n\nfunction checkIsDelegated(accounts: ParsedTokenAccount[]) {\n if (accounts.some(account => account.parsed.delegate === null)) {\n throw new Error('Account is not delegated');\n }\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n bn,\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n StateTreeInfo,\n selectStateTreeInfo,\n} from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport { CompressedTokenProgram } from '../program';\nimport { selectMinCompressedTokenAccountsForTransfer } from '../utils';\n\n/**\n * Transfer compressed tokens from one owner to another\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param amount Number of tokens to transfer\n * @param owner Owner of the compressed tokens\n * @param toAddress Destination address of the recipient\n * @param confirmOptions Options for confirming the transaction\n *\n * @return confirmed transaction signature\n */\nexport async function transfer(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n amount: number | BN,\n owner: Signer,\n toAddress: PublicKey,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n amount = bn(amount);\n const compressedTokenAccounts = await rpc.getCompressedTokenAccountsByOwner(\n owner.publicKey,\n {\n mint,\n },\n );\n\n const [inputAccounts] = selectMinCompressedTokenAccountsForTransfer(\n compressedTokenAccounts.items,\n amount,\n );\n\n const proof = await rpc.getValidityProofV0(\n inputAccounts.map(account => ({\n hash: account.compressedAccount.hash,\n tree: account.compressedAccount.treeInfo.tree,\n queue: account.compressedAccount.treeInfo.queue,\n })),\n );\n\n const ix = await CompressedTokenProgram.transfer({\n payer: payer.publicKey,\n inputCompressedTokenAccounts: inputAccounts,\n toAddress,\n amount,\n recentInputStateRootIndices: proof.rootIndices,\n recentValidityProof: proof.compressedProof,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n const signedTx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 500_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n\n return sendAndConfirmTx(rpc, signedTx, confirmOptions);\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n bn,\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n} from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport { CompressedTokenProgram } from '../program';\nimport { selectMinCompressedTokenAccountsForTransfer } from '../utils';\n\n/**\n * Transfer delegated compressed tokens to another owner\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param amount Number of tokens to transfer\n * @param owner Owner of the compressed tokens\n * @param toAddress Destination address of the recipient\n * @param confirmOptions Options for confirming the transaction\n *\n * @return confirmed transaction signature\n */\nexport async function transferDelegated(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n amount: number | BN,\n owner: Signer,\n toAddress: PublicKey,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n amount = bn(amount);\n const compressedTokenAccounts =\n await rpc.getCompressedTokenAccountsByDelegate(owner.publicKey, {\n mint,\n });\n\n const [inputAccounts] = selectMinCompressedTokenAccountsForTransfer(\n compressedTokenAccounts.items,\n amount,\n );\n\n const proof = await rpc.getValidityProofV0(\n inputAccounts.map(account => ({\n hash: account.compressedAccount.hash,\n tree: account.compressedAccount.treeInfo.tree,\n queue: account.compressedAccount.treeInfo.queue,\n })),\n );\n\n const ix = await CompressedTokenProgram.transfer({\n payer: payer.publicKey,\n inputCompressedTokenAccounts: inputAccounts,\n toAddress,\n amount,\n recentInputStateRootIndices: proof.rootIndices,\n recentValidityProof: proof.compressedProof,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n const signedTx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 500_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n\n return sendAndConfirmTx(rpc, signedTx, confirmOptions);\n}\n"],"names":["POOL_SEED","Buffer","from","CPI_AUTHORITY_SEED","CREATE_TOKEN_POOL_DISCRIMINATOR","MINT_TO_DISCRIMINATOR","BATCH_COMPRESS_DISCRIMINATOR","TRANSFER_DISCRIMINATOR","COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR","APPROVE_DISCRIMINATOR","REVOKE_DISCRIMINATOR","ADD_TOKEN_POOL_DISCRIMINATOR","checkTokenPoolInfo","tokenPoolInfo","mint","equals","Error","isInitialized","toBase58","async","getTokenPoolInfos","rpc","commitment","addressesAndBumps","Array","length","_","i","CompressedTokenProgram","deriveTokenPoolPdaWithIndex","accountInfos","getMultipleAccountsInfo","map","addressAndBump","parsedInfos","unpackAccount","owner","tokenProgram","parsedInfo","tokenPoolPda","address","activity","undefined","balance","bn","amount","toString","poolIndex","bump","Action","shuffleArray","array","j","Math","floor","random","selectTokenPoolInfo","infos","filteredInfos","filter","info","selectTokenPoolInfosForDecompression","decompressAmount","sufficientBalanceInfo","find","gte","mul","sort","a","b","every","isZero","ERROR_NO_ACCOUNTS_FOUND","selectTokenAccountsForApprove","accounts","approveAmount","maxInputs","exactMatch","account","parsed","eq","compressedAccount","lamports","selectMinCompressedTokenAccountsForTransfer","transferAmount","selectedAccounts","accumulatedAmount","accumulatedLamports","maxPossibleAmount","selectMinCompressedTokenAccountsForTransferOrPartial","lt","totalBalance","reduce","acc","add","cmp","push","slice","total","console","log","selectSmartCompressedTokenAccountsForTransferOrPartial","nonZeroAccounts","remainingAccounts","smallestAccount","min","max","packCompressedTokenAccounts","params","inputCompressedTokenAccounts","outputStateTreeInfo","rootIndices","tokenTransferOutputs","_remainingAccounts","delegateIndex","delegate","getIndexOrAdd","packedInputTokenData","forEach","index","merkleTreePubkeyIndex","treeInfo","tree","queuePubkeyIndex","queue","merkleContext","leafIndex","proveByIndex","rootIndex","tlv","activeTreeInfo","nextTreeInfo","activeTreeOrQueue","treeType","TreeType","StateV2","featureFlags","isV2","paddedOutputStateMerkleTrees","padOutputStateMerkleTrees","packedOutputTokenData","merkleTreeIndex","_a","remainingAccountMetas","pubkey","isWritable","isSigner","inputTokenDataWithContext","checkMint","compressedTokenAccounts","CompressedProofLayout","struct","u8","PackedTokenTransferOutputDataLayout","publicKey","u64","option","vecU8","InputTokenDataWithContextLayout","u32","bool","u16","DelegatedTransferLayout","CpiContextLayout","CompressedTokenInstructionDataTransferLayout","vec","mintToLayout","batchCompressLayout","compressSplTokenAccountInstructionDataLayout","encodeMintToInstructionData","data","buffer","alloc","len","encode","recipients","amounts","concat","Uint8Array","subarray","encodeBatchCompressInstructionData","lengthBuffer","writeUInt32LE","dataBuffer","encodeCompressSplTokenAccountInstructionData","remainingAmount","cpiContext","encodeTransferInstructionData","createTokenPoolAccountsLayout","feePayer","systemProgram","cpiAuthorityPda","addTokenPoolAccountsLayout","existingTokenPoolPda","mintToAccountsLayout","defaultPubkey","programId","authority","lightSystemProgram","registeredProgramPda","noopProgram","accountCompressionAuthority","accountCompressionProgram","merkleTree","selfProgram","solPoolPda","transferAccountsLayout","compressOrDecompressTokenAccount","approveAccountsLayout","revokeAccountsLayout","freezeAccountsLayout","thawAccountsLayout","CompressedTokenInstructionDataApproveLayout","CompressedTokenInstructionDataRevokeLayout","emptyProof","fill","c","isEmptyProof","proof","encodeApproveInstructionData","proofOption","Object","assign","encodeRevokeInstructionData","sumUpTokenAmount","validateSameTokenOwner","parseTokenData","currentOwner","parseMaybeDelegatedTransfer","inputs","outputs","delegatedAccountsIndex","findIndex","delegatedTransfer","delegateChangeAccountIndex","createTransferOutputState","toAddress","inputAmount","inputLamports","sumUpLamports","changeAmount","sub","validateSufficientBalance","validateSameOwner","createDecompressOutputState","constructor","setProgramId","this","PublicKey","deriveTokenPoolPda","seeds","toBuffer","findProgramAddressSync","findTokenPoolIndexAndBump","poolPda","derivedPda","deriveCpiAuthorityPda","createMint","freezeAuthority","decimals","rentExemptBalance","tokenProgramId","mintSize","TOKEN_PROGRAM_ID","SystemProgram","createAccount","fromPubkey","newAccountPubkey","space","MINT_SIZE","createInitializeMint2Instruction","createTokenPool","keys","TransactionInstruction","addTokenPool","mintTo","toPubkey","systemKeys","defaultStaticAccountsStruct","toArray","toPubkeys","LightSystemProgram","approveAndMintTo","authorityTokenAccount","amountBigInt","BigInt","createMintToInstruction","compress","payer","source","transfer","recentValidityProof","recentInputStateRootIndices","outputCompressedAccounts","compressOrDecompressAmount","isCompress","lamportsChangeAccountMerkleTreeIndex","createTokenProgramLookupTable","mints","recentSlot","createInstruction","lookupTableAddress","AddressLookupTableProgram","createLookupTable","optionalMintKeys","instructions","extendLookupTable","lookupTable","addresses","ComputeBudgetProgram","defaultTestStateTreeAccounts","nullifierQueue","addressTree","addressQueue","TOKEN_2022_PROGRAM_ID","chunk","extendIx","amountArray","toAddressArray","pubkeys","amt","amountBN","isArray","sum","decompress","tokenPoolInfos","tokenPoolInfosArray","mergeTokenAccounts","compressSplTokenAccount","tokenAccount","getMintProgramId","connection","getAccountInfo","approve","CHANGE_INDEX","delegatedAmount","delegateMerkleTreeIndex","changeAccountMerkleTreeIndex","delegateLamports","revoke","outputAccountMerkleTreeIndex","version","name","docs","isMut","args","type","isOptional","defined","types","kind","variants","fields","errors","code","msg","numMaxAdditionalPools","confirmOptions","uninitializedIndices","blockhash","getLatestBlockhash","tx","buildAndSignTx","sendAndConfirmTx","getCompressedTokenAccountsByOwner","inputAccounts","items","getValidityProofV0","hash","ix","compressedProof","additionalSigners","dedupeSigner","signedTx","setComputeUnitLimit","units","selectStateTreeInfo","getStateTreeInfos","getOrCreateAssociatedTokenAccount","ixs","sourceTokenAccount","compressIx","blockhashCtx","mintAuthority","keypair","Keypair","generate","getMinimumBalanceForRentExemption","resolvedTokenProgramId","signer","txId","transactionSignature","additionalAccounts","getSlot","txIds","instruction","decode","selectedTokenPoolInfos","getCompressedTokenAccountsByDelegate","tokenPoolInfosToUse","batch","getValidityProof","batchInstructions","checkOwner","some","checkIsDelegated","totalLamports"],"mappings":"oqqBACa,MAAAA,GAAYC,EAAOC,KAAK,QAExBC,GAAqBF,EAAOC,KAAK,iBAIjCE,GAAkCH,EAAOC,KAAK,CACvD,GAAI,IAAK,GAAI,IAAK,IAAK,IAAK,IAAK,MAExBG,GAAwBJ,EAAOC,KAAK,CAC7C,IAAK,GAAI,GAAI,IAAK,GAAI,IAAK,IAAK,MAEvBI,GAA+BL,EAAOC,KAAK,CACpD,GAAI,IAAK,IAAK,GAAI,IAAK,GAAI,IAAK,MAEvBK,GAAyBN,EAAOC,KAAK,CAC9C,IAAK,GAAI,IAAK,IAAK,IAAK,EAAG,GAAI,MAEtBM,GAA2CP,EAAOC,KAAK,CAChE,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,KAG1BO,GAAwBR,EAAOC,KAAK,CAC7C,GAAI,GAAI,IAAK,GAAI,IAAK,IAAK,GAAI,KAEtBQ,GAAuBT,EAAOC,KAAK,CAC5C,IAAK,GAAI,GAAI,GAAI,IAAK,IAAK,GAAI,MAEtBS,GAA+BV,EAAOC,KAAK,CACpD,IAAK,IAAK,IAAK,GAAI,GAAI,IAAK,EAAG,MClBnB,SAAAU,GACZC,EACA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AGzBX,UAAEA,SAAoBlV,EAAImV,qBAC1BW,EAAoBC,EAAYA,aAACpF,EAAO,CAAC5P,IACzCiV,EAAWX,EAAcA,eAC3B,CAACrD,EAAAA,qBAAqBiE,oBAAoB,CAAEC,MAAO,MAAYN,GAC/DjF,EACAuE,EACAY,GAGJ,OAAOR,mBAAiBtV,EAAKgW,EAAUhB,EAC3C"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../../src/constants.ts","../../../../../src/utils/get-token-pool-infos.ts","../../../../../src/utils/select-input-accounts.ts","../../../../../src/utils/pack-compressed-token-accounts.ts","../../../../../src/utils/validation.ts","../../../../../node_modules/.pnpm/buffer-layout@1.2.2/node_modules/buffer-layout/lib/Layout.js","../../../../../node_modules/.pnpm/bn.js@5.2.1/node_modules/bn.js/lib/bn.js","../../../../../node_modules/.pnpm/@coral-xyz+borsh@0.29.0_@solana+web3.js@1.98.0/node_modules/@coral-xyz/borsh/dist/index.js","../../../../../src/layout.ts","../../../../../src/program.ts","../../../../../src/compressible/derivation.ts","../../../../../src/idl.ts","../../../../../src/actions/create-token-pool.ts","../../../../../src/actions/approve.ts","../../../../../src/actions/approve-and-mint-to.ts","../../../../../src/actions/compress.ts","../../../../../src/actions/compress-spl-token-account.ts","../../../../../src/actions/create-mint.ts","../../../../../src/actions/create-token-program-lookup-table.ts","../../../../../src/actions/decompress.ts","../../../../../src/actions/decompress-delegated.ts","../../../../../src/types.ts","../../../../../src/actions/merge-token-accounts.ts","../../../../../src/actions/mint-to.ts","../../../../../src/actions/revoke.ts","../../../../../src/actions/transfer.ts","../../../../../src/actions/transfer-delegated.ts"],"sourcesContent":["import { Buffer } from 'buffer';\nexport const POOL_SEED = Buffer.from('pool');\n\nexport const CPI_AUTHORITY_SEED = Buffer.from('cpi_authority');\n\nexport const SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE = 1461600;\n\nexport const CREATE_TOKEN_POOL_DISCRIMINATOR = Buffer.from([\n 23, 169, 27, 122, 147, 169, 209, 152,\n]);\nexport const MINT_TO_DISCRIMINATOR = Buffer.from([\n 241, 34, 48, 186, 37, 179, 123, 192,\n]);\nexport const BATCH_COMPRESS_DISCRIMINATOR = Buffer.from([\n 65, 206, 101, 37, 147, 42, 221, 144,\n]);\nexport const TRANSFER_DISCRIMINATOR = Buffer.from([\n 163, 52, 200, 231, 140, 3, 69, 186,\n]);\nexport const COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR = Buffer.from([\n 112, 230, 105, 101, 145, 202, 157, 97,\n]);\n\nexport const APPROVE_DISCRIMINATOR = Buffer.from([\n 69, 74, 217, 36, 115, 117, 97, 76,\n]);\nexport const REVOKE_DISCRIMINATOR = Buffer.from([\n 170, 23, 31, 34, 133, 173, 93, 242,\n]);\nexport const ADD_TOKEN_POOL_DISCRIMINATOR = Buffer.from([\n 114, 143, 210, 73, 96, 115, 1, 228,\n]);\n","import { Commitment, PublicKey } from '@solana/web3.js';\nimport { unpackAccount } from '@solana/spl-token';\nimport { CompressedTokenProgram } from '../program';\nimport { bn, Rpc } from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\n\n/**\n * Check if the token pool info is initialized and has a balance.\n * @param mint The mint of the token pool\n * @param tokenPoolInfo The token pool info\n * @returns True if the token pool info is initialized and has a balance\n */\nexport function checkTokenPoolInfo(\n tokenPoolInfo: TokenPoolInfo,\n mint: PublicKey,\n): boolean {\n if (!tokenPoolInfo.mint.equals(mint)) {\n throw new Error(`TokenPool mint does not match the provided mint.`);\n }\n\n if (!tokenPoolInfo.isInitialized) {\n throw new Error(\n `TokenPool is not initialized. Please create a compressed token pool for mint: ${mint.toBase58()} via createTokenPool().`,\n );\n }\n return true;\n}\n\n/**\n * Get the token pool infos for a given mint.\n * @param rpc The RPC client\n * @param mint The mint of the token pool\n * @param commitment The commitment to use\n *\n * @returns The token pool infos\n */\nexport async function getTokenPoolInfos(\n rpc: Rpc,\n mint: PublicKey,\n commitment?: Commitment,\n): Promise<TokenPoolInfo[]> {\n const addressesAndBumps = Array.from({ length: 5 }, (_, i) =>\n CompressedTokenProgram.deriveTokenPoolPdaWithIndex(mint, i),\n );\n\n const accountInfos = await rpc.getMultipleAccountsInfo(\n addressesAndBumps.map(addressAndBump => addressAndBump[0]),\n commitment,\n );\n\n if (accountInfos[0] === null) {\n throw new Error(\n `TokenPool not found. Please create a compressed token pool for mint: ${mint.toBase58()} via createTokenPool().`,\n );\n }\n\n const parsedInfos = addressesAndBumps.map((addressAndBump, i) =>\n accountInfos[i]\n ? unpackAccount(\n addressAndBump[0],\n accountInfos[i],\n accountInfos[i].owner,\n )\n : null,\n );\n\n const tokenProgram = accountInfos[0].owner;\n return parsedInfos.map((parsedInfo, i) => {\n if (!parsedInfo) {\n return {\n mint,\n tokenPoolPda: addressesAndBumps[i][0],\n tokenProgram,\n activity: undefined,\n balance: bn(0),\n isInitialized: false,\n poolIndex: i,\n bump: addressesAndBumps[i][1],\n };\n }\n\n return {\n mint,\n tokenPoolPda: parsedInfo.address,\n tokenProgram,\n activity: undefined,\n balance: bn(parsedInfo.amount.toString()),\n isInitialized: true,\n poolIndex: i,\n bump: addressesAndBumps[i][1],\n };\n });\n}\n\nexport type TokenPoolActivity = {\n signature: string;\n amount: BN;\n action: Action;\n};\n\n/**\n * Token pool pda info.\n */\nexport type TokenPoolInfo = {\n /**\n * The mint of the token pool\n */\n mint: PublicKey;\n /**\n * The token pool address\n */\n tokenPoolPda: PublicKey;\n /**\n * The token program of the token pool\n */\n tokenProgram: PublicKey;\n /**\n * count of txs and volume in the past 60 seconds.\n */\n activity?: {\n txs: number;\n amountAdded: BN;\n amountRemoved: BN;\n };\n /**\n * Whether the token pool is initialized\n */\n isInitialized: boolean;\n /**\n * The balance of the token pool\n */\n balance: BN;\n /**\n * The index of the token pool\n */\n poolIndex: number;\n /**\n * The bump used to derive the token pool pda\n */\n bump: number;\n};\n\n/**\n * @internal\n */\nexport enum Action {\n Compress = 1,\n Decompress = 2,\n Transfer = 3,\n}\n\n/**\n * @internal\n */\nconst shuffleArray = <T>(array: T[]): T[] => {\n for (let i = array.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [array[i], array[j]] = [array[j], array[i]];\n }\n return array;\n};\n\n/**\n * For `compress` and `mintTo` instructions only.\n * Select a random token pool info from the token pool infos.\n *\n * For `decompress`, use {@link selectTokenPoolInfosForDecompression} instead.\n *\n * @param infos The token pool infos\n *\n * @returns A random token pool info\n */\nexport function selectTokenPoolInfo(infos: TokenPoolInfo[]): TokenPoolInfo {\n const shuffledInfos = shuffleArray(infos);\n\n // filter only infos that are initialized\n const filteredInfos = shuffledInfos.filter(info => info.isInitialized);\n\n if (filteredInfos.length === 0) {\n throw new Error(\n 'Please pass at least one initialized token pool info.',\n );\n }\n\n // Return a single random token pool info\n return filteredInfos[0];\n}\n\n/**\n * Select one or multiple token pool infos from the token pool infos.\n *\n * Use this function for `decompress`.\n *\n * For `compress`, `mintTo` use {@link selectTokenPoolInfo} instead.\n *\n * @param infos The token pool infos\n * @param decompressAmount The amount of tokens to withdraw\n *\n * @returns Array with one or more token pool infos.\n */\nexport function selectTokenPoolInfosForDecompression(\n infos: TokenPoolInfo[],\n decompressAmount: number | BN,\n): TokenPoolInfo[] {\n if (infos.length === 0) {\n throw new Error('Please pass at least one token pool info.');\n }\n\n infos = shuffleArray(infos);\n // Find the first info where balance is 10x the requested amount\n const sufficientBalanceInfo = infos.find(info =>\n info.balance.gte(bn(decompressAmount).mul(bn(10))),\n );\n\n // filter only infos that are initialized\n infos = infos\n .filter(info => info.isInitialized)\n .sort((a, b) => a.poolIndex - b.poolIndex);\n\n const allBalancesZero = infos.every(info => info.balance.isZero());\n if (allBalancesZero) {\n throw new Error(\n 'All provided token pool balances are zero. Please pass recent token pool infos.',\n );\n }\n\n // If none found, return all infos\n return sufficientBalanceInfo ? [sufficientBalanceInfo] : infos;\n}\n","import { bn, ParsedTokenAccount } from '@lightprotocol/stateless.js';\n\nimport BN from 'bn.js';\n\nexport const ERROR_NO_ACCOUNTS_FOUND =\n 'Could not find accounts to select for transfer.';\n\n/**\n * Selects token accounts for approval, first trying to find an exact match, then falling back to minimum selection.\n *\n * @param {ParsedTokenAccount[]} accounts - Token accounts to choose from.\n * @param {BN} approveAmount - Amount to approve.\n * @param {number} [maxInputs=4] - Max accounts to select when falling back to minimum selection.\n * @returns {[\n * selectedAccounts: ParsedTokenAccount[],\n * total: BN,\n * totalLamports: BN | null,\n * maxPossibleAmount: BN\n * ]} - Returns:\n * - selectedAccounts: Accounts chosen for approval.\n * - total: Total amount from selected accounts.\n * - totalLamports: Total lamports from selected accounts.\n * - maxPossibleAmount: Max approvable amount given maxInputs.\n */\nexport function selectTokenAccountsForApprove(\n accounts: ParsedTokenAccount[],\n approveAmount: BN,\n maxInputs: number = 4,\n): [\n selectedAccounts: ParsedTokenAccount[],\n total: BN,\n totalLamports: BN | null,\n maxPossibleAmount: BN,\n] {\n // First try to find an exact match\n const exactMatch = accounts.find(account =>\n account.parsed.amount.eq(approveAmount),\n );\n if (exactMatch) {\n return [\n [exactMatch],\n exactMatch.parsed.amount,\n exactMatch.compressedAccount.lamports,\n exactMatch.parsed.amount,\n ];\n }\n\n // If no exact match, fall back to minimum selection\n return selectMinCompressedTokenAccountsForTransfer(\n accounts,\n approveAmount,\n maxInputs,\n );\n}\n\n/**\n * Selects the minimum number of compressed token accounts required for a\n * decompress instruction, up to a specified maximum.\n *\n * @param {ParsedTokenAccount[]} accounts Token accounts to choose from.\n * @param {BN} amount Amount to decompress.\n * @param {number} [maxInputs=4] Max accounts to select. Default\n * is 4.\n *\n * @returns Returns selected accounts and their totals.\n */\nexport function selectMinCompressedTokenAccountsForDecompression(\n accounts: ParsedTokenAccount[],\n amount: BN,\n maxInputs: number = 4,\n): {\n selectedAccounts: ParsedTokenAccount[];\n total: BN;\n totalLamports: BN | null;\n maxPossibleAmount: BN;\n} {\n const [selectedAccounts, total, totalLamports, maxPossibleAmount] =\n selectMinCompressedTokenAccountsForTransfer(\n accounts,\n amount,\n maxInputs,\n );\n return { selectedAccounts, total, totalLamports, maxPossibleAmount };\n}\n\n/**\n * Selects the minimum number of compressed token accounts required for a\n * transfer or decompression instruction, up to a specified maximum.\n *\n * @param {ParsedTokenAccount[]} accounts Token accounts to choose from.\n * @param {BN} transferAmount Amount to transfer or decompress.\n * @param {number} [maxInputs=4] Max accounts to select. Default\n * is 4.\n *\n * @returns Returns selected accounts and their totals. [\n * selectedAccounts: ParsedTokenAccount[],\n * total: BN,\n * totalLamports: BN | null,\n * maxPossibleAmount: BN\n * ]\n */\nexport function selectMinCompressedTokenAccountsForTransfer(\n accounts: ParsedTokenAccount[],\n transferAmount: BN,\n maxInputs: number = 4,\n): [\n selectedAccounts: ParsedTokenAccount[],\n total: BN,\n totalLamports: BN | null,\n maxPossibleAmount: BN,\n] {\n const [\n selectedAccounts,\n accumulatedAmount,\n accumulatedLamports,\n maxPossibleAmount,\n ] = selectMinCompressedTokenAccountsForTransferOrPartial(\n accounts,\n transferAmount,\n maxInputs,\n );\n\n if (accumulatedAmount.lt(bn(transferAmount))) {\n const totalBalance = accounts.reduce(\n (acc, account) => acc.add(account.parsed.amount),\n bn(0),\n );\n if (selectedAccounts.length >= maxInputs) {\n throw new Error(\n `Account limit exceeded: max ${maxPossibleAmount.toString()} (${maxInputs} accounts) per transaction. Total balance: ${totalBalance.toString()} (${accounts.length} accounts). Consider multiple transfers to spend full balance.`,\n );\n } else {\n throw new Error(\n `Insufficient balance for transfer. Required: ${transferAmount.toString()}, available: ${totalBalance.toString()}.`,\n );\n }\n }\n\n if (selectedAccounts.length === 0) {\n throw new Error(ERROR_NO_ACCOUNTS_FOUND);\n }\n\n return [\n selectedAccounts,\n accumulatedAmount,\n accumulatedLamports,\n maxPossibleAmount,\n ];\n}\n\n/**\n * Executes {@link selectMinCompressedTokenAccountsForTransfer} strategy,\n * returns partial amounts if insufficient accounts are found instead of\n * throwing an error.\n */\nexport function selectMinCompressedTokenAccountsForTransferOrPartial(\n accounts: ParsedTokenAccount[],\n transferAmount: BN,\n maxInputs: number = 4,\n): [\n selectedAccounts: ParsedTokenAccount[],\n total: BN,\n totalLamports: BN | null,\n maxPossibleAmount: BN,\n] {\n if (accounts.length === 0) {\n throw new Error(ERROR_NO_ACCOUNTS_FOUND);\n }\n\n let accumulatedAmount = bn(0);\n let accumulatedLamports = bn(0);\n let maxPossibleAmount = bn(0);\n\n const selectedAccounts: ParsedTokenAccount[] = [];\n\n accounts.sort((a, b) => b.parsed.amount.cmp(a.parsed.amount));\n\n for (const account of accounts) {\n if (selectedAccounts.length >= maxInputs) break;\n if (accumulatedAmount.gte(bn(transferAmount))) break;\n\n if (\n !account.parsed.amount.isZero() ||\n !account.compressedAccount.lamports.isZero()\n ) {\n accumulatedAmount = accumulatedAmount.add(account.parsed.amount);\n accumulatedLamports = accumulatedLamports.add(\n account.compressedAccount.lamports,\n );\n selectedAccounts.push(account);\n }\n }\n\n // Max, considering maxInputs\n maxPossibleAmount = accounts\n .slice(0, maxInputs)\n .reduce((total, account) => total.add(account.parsed.amount), bn(0));\n\n if (accumulatedAmount.lt(bn(transferAmount))) {\n console.log(\n `Insufficient balance for transfer. Requested: ${transferAmount.toString()}, Returns max available: ${maxPossibleAmount.toString()}.`,\n );\n }\n\n if (selectedAccounts.length === 0) {\n throw new Error(ERROR_NO_ACCOUNTS_FOUND);\n }\n\n return [\n selectedAccounts,\n accumulatedAmount,\n accumulatedLamports,\n maxPossibleAmount,\n ];\n}\n\n/**\n * Selects compressed token accounts for a transfer, ensuring one extra account\n * if possible, up to maxInputs.\n *\n * 1. Sorts accounts by amount (desc)\n * 2. Selects accounts until transfer amount is met or maxInputs is reached,\n * attempting to add one extra account if possible.\n *\n * @param {ParsedTokenAccount[]} accounts - The list of token accounts to select from.\n * @param {BN} transferAmount - The token amount to be transferred.\n * @param {number} [maxInputs=4] - The maximum number of accounts to select. Default: 4.\n * @returns {[\n * selectedAccounts: ParsedTokenAccount[],\n * total: BN,\n * totalLamports: BN | null,\n * maxPossibleAmount: BN\n * ]} - An array containing:\n * - selectedAccounts: The accounts selected for the transfer.\n * - total: The total amount accumulated from the selected accounts.\n * - totalLamports: The total lamports accumulated from the selected accounts.\n * - maxPossibleAmount: The maximum possible amount that can be transferred considering maxInputs.\n *\n * @example\n * const accounts = [\n * { parsed: { amount: new BN(100) }, compressedAccount: { lamports: new BN(10) } },\n * { parsed: { amount: new BN(50) }, compressedAccount: { lamports: new BN(5) } },\n * { parsed: { amount: new BN(25) }, compressedAccount: { lamports: new BN(2) } },\n * ];\n * const transferAmount = new BN(75);\n * const maxInputs = 2;\n *\n * const [selectedAccounts, total, totalLamports, maxPossibleAmount] =\n * selectSmartCompressedTokenAccountsForTransfer(accounts, transferAmount, maxInputs);\n *\n * console.log(selectedAccounts.length); // 2\n * console.log(total.toString()); // '150'\n * console.log(totalLamports!.toString()); // '15'\n * console.log(maxPossibleAmount.toString()); // '150'\n */\nexport function selectSmartCompressedTokenAccountsForTransfer(\n accounts: ParsedTokenAccount[],\n transferAmount: BN,\n maxInputs: number = 4,\n): [\n selectedAccounts: ParsedTokenAccount[],\n total: BN,\n totalLamports: BN | null,\n maxPossibleAmount: BN,\n] {\n const [\n selectedAccounts,\n accumulatedAmount,\n accumulatedLamports,\n maxPossibleAmount,\n ] = selectSmartCompressedTokenAccountsForTransferOrPartial(\n accounts,\n transferAmount,\n maxInputs,\n );\n\n if (accumulatedAmount.lt(bn(transferAmount))) {\n const totalBalance = accounts.reduce(\n (acc, account) => acc.add(account.parsed.amount),\n bn(0),\n );\n if (selectedAccounts.length >= maxInputs) {\n throw new Error(\n `Account limit exceeded: max ${maxPossibleAmount.toString()} (${maxInputs} accounts) per transaction. Total balance: ${totalBalance.toString()} (${accounts.length} accounts). Consider multiple transfers to spend full balance.`,\n );\n } else {\n throw new Error(\n `Insufficient balance. Required: ${transferAmount.toString()}, available: ${totalBalance.toString()}.`,\n );\n }\n }\n\n if (selectedAccounts.length === 0) {\n throw new Error(ERROR_NO_ACCOUNTS_FOUND);\n }\n\n return [\n selectedAccounts,\n accumulatedAmount,\n accumulatedLamports,\n maxPossibleAmount,\n ];\n}\n\n/**\n * Executes {@link selectMinCompressedTokenAccountsForTransfer} strategy,\n * returns partial amounts if insufficient accounts are found instead of\n * throwing an error.\n */\nexport function selectSmartCompressedTokenAccountsForTransferOrPartial(\n accounts: ParsedTokenAccount[],\n transferAmount: BN,\n maxInputs: number = 4,\n): [\n selectedAccounts: ParsedTokenAccount[],\n total: BN,\n totalLamports: BN | null,\n maxPossibleAmount: BN,\n] {\n if (accounts.length === 0) {\n throw new Error(ERROR_NO_ACCOUNTS_FOUND);\n }\n\n let accumulatedAmount = bn(0);\n let accumulatedLamports = bn(0);\n\n const selectedAccounts: ParsedTokenAccount[] = [];\n\n // we can ignore zero value accounts.\n const nonZeroAccounts = accounts.filter(\n account =>\n !account.parsed.amount.isZero() ||\n !account.compressedAccount.lamports.isZero(),\n );\n\n nonZeroAccounts.sort((a, b) => b.parsed.amount.cmp(a.parsed.amount));\n\n for (const account of nonZeroAccounts) {\n if (selectedAccounts.length >= maxInputs) break;\n accumulatedAmount = accumulatedAmount.add(account.parsed.amount);\n accumulatedLamports = accumulatedLamports.add(\n account.compressedAccount.lamports,\n );\n selectedAccounts.push(account);\n\n if (accumulatedAmount.gte(bn(transferAmount))) {\n // Select smallest additional account if maxInputs not reached\n const remainingAccounts = nonZeroAccounts.slice(\n selectedAccounts.length,\n );\n if (remainingAccounts.length > 0) {\n const smallestAccount = remainingAccounts.reduce((min, acc) =>\n acc.parsed.amount.lt(min.parsed.amount) ? acc : min,\n );\n if (selectedAccounts.length < maxInputs) {\n selectedAccounts.push(smallestAccount);\n accumulatedAmount = accumulatedAmount.add(\n smallestAccount.parsed.amount,\n );\n accumulatedLamports = accumulatedLamports.add(\n smallestAccount.compressedAccount.lamports,\n );\n }\n }\n break;\n }\n }\n\n const maxPossibleAmount = nonZeroAccounts\n .slice(0, maxInputs)\n .reduce((max, account) => max.add(account.parsed.amount), bn(0));\n\n if (selectedAccounts.length === 0) {\n throw new Error(ERROR_NO_ACCOUNTS_FOUND);\n }\n\n return [\n selectedAccounts,\n accumulatedAmount,\n accumulatedLamports,\n maxPossibleAmount,\n ];\n}\n","import {\n ParsedTokenAccount,\n InputTokenDataWithContext,\n getIndexOrAdd,\n bn,\n padOutputStateMerkleTrees,\n TreeType,\n featureFlags,\n TreeInfo,\n} from '@lightprotocol/stateless.js';\nimport { PublicKey, AccountMeta } from '@solana/web3.js';\nimport {\n PackedTokenTransferOutputData,\n TokenTransferOutputData,\n} from '../types';\n\nexport type PackCompressedTokenAccountsParams = {\n /** Input state to be consumed */\n inputCompressedTokenAccounts: ParsedTokenAccount[];\n /**\n * State trees that the output should be inserted into. Defaults to the 0th\n * state tree of the input state. Gets padded to the length of\n * outputCompressedAccounts.\n */\n outputStateTreeInfo?: TreeInfo;\n /** Optional remaining accounts to append to */\n remainingAccounts?: PublicKey[];\n /**\n * Root indices that are used on-chain to fetch the correct root\n * from the state Merkle tree account for validity proof verification.\n */\n rootIndices: number[];\n tokenTransferOutputs: TokenTransferOutputData[];\n};\n\n/**\n * Packs Compressed Token Accounts.\n */\nexport function packCompressedTokenAccounts(\n params: PackCompressedTokenAccountsParams,\n): {\n inputTokenDataWithContext: InputTokenDataWithContext[];\n remainingAccountMetas: AccountMeta[];\n packedOutputTokenData: PackedTokenTransferOutputData[];\n} {\n const {\n inputCompressedTokenAccounts,\n outputStateTreeInfo,\n remainingAccounts = [],\n rootIndices,\n tokenTransferOutputs,\n } = params;\n\n const _remainingAccounts = remainingAccounts.slice();\n let delegateIndex: number | null = null;\n\n if (\n inputCompressedTokenAccounts.length > 0 &&\n inputCompressedTokenAccounts[0].parsed.delegate\n ) {\n delegateIndex = getIndexOrAdd(\n _remainingAccounts,\n inputCompressedTokenAccounts[0].parsed.delegate,\n );\n }\n\n const packedInputTokenData: InputTokenDataWithContext[] = [];\n /// pack inputs\n inputCompressedTokenAccounts.forEach(\n (account: ParsedTokenAccount, index) => {\n const merkleTreePubkeyIndex = getIndexOrAdd(\n _remainingAccounts,\n account.compressedAccount.treeInfo.tree,\n );\n\n const queuePubkeyIndex = getIndexOrAdd(\n _remainingAccounts,\n account.compressedAccount.treeInfo.queue,\n );\n\n packedInputTokenData.push({\n amount: account.parsed.amount,\n delegateIndex,\n merkleContext: {\n merkleTreePubkeyIndex,\n queuePubkeyIndex,\n leafIndex: account.compressedAccount.leafIndex,\n proveByIndex: account.compressedAccount.proveByIndex,\n },\n rootIndex: rootIndices[index],\n lamports: account.compressedAccount.lamports.eq(bn(0))\n ? null\n : account.compressedAccount.lamports,\n tlv: null,\n });\n },\n );\n\n if (inputCompressedTokenAccounts.length > 0 && outputStateTreeInfo) {\n throw new Error(\n 'Cannot specify both input accounts and outputStateTreeInfo',\n );\n }\n\n let treeInfo: TreeInfo;\n if (inputCompressedTokenAccounts.length > 0) {\n treeInfo = inputCompressedTokenAccounts[0].compressedAccount.treeInfo;\n } else if (outputStateTreeInfo) {\n treeInfo = outputStateTreeInfo;\n } else {\n throw new Error(\n 'Neither input accounts nor outputStateTreeInfo are available',\n );\n }\n\n // Use next tree if available, otherwise fall back to current tree.\n // `nextTreeInfo` always takes precedence.\n const activeTreeInfo = treeInfo.nextTreeInfo || treeInfo;\n let activeTreeOrQueue = activeTreeInfo.tree;\n\n if (activeTreeInfo.treeType === TreeType.StateV2) {\n if (featureFlags.isV2()) {\n activeTreeOrQueue = activeTreeInfo.queue;\n } else throw new Error('V2 trees are not supported yet');\n }\n\n // Pack output state trees\n const paddedOutputStateMerkleTrees = padOutputStateMerkleTrees(\n activeTreeOrQueue,\n tokenTransferOutputs.length,\n );\n const packedOutputTokenData: PackedTokenTransferOutputData[] = [];\n paddedOutputStateMerkleTrees.forEach((account, index) => {\n const merkleTreeIndex = getIndexOrAdd(_remainingAccounts, account);\n packedOutputTokenData.push({\n owner: tokenTransferOutputs[index].owner,\n amount: tokenTransferOutputs[index].amount,\n lamports: tokenTransferOutputs[index].lamports?.eq(bn(0))\n ? null\n : tokenTransferOutputs[index].lamports,\n merkleTreeIndex,\n tlv: null,\n });\n });\n // to meta\n const remainingAccountMetas = _remainingAccounts.map(\n (account): AccountMeta => ({\n pubkey: account,\n isWritable: true,\n isSigner: false,\n }),\n );\n\n return {\n inputTokenDataWithContext: packedInputTokenData,\n remainingAccountMetas,\n packedOutputTokenData,\n };\n}\n","import { ParsedTokenAccount } from '@lightprotocol/stateless.js';\nimport { PublicKey } from '@solana/web3.js';\n\n/**\n * Check if all input accounts belong to the same mint.\n *\n * @param compressedTokenAccounts The compressed token accounts\n * @param mint The mint of the token pool\n * @returns True if all input accounts belong to the same mint\n */\nexport function checkMint(\n compressedTokenAccounts: ParsedTokenAccount[],\n mint: PublicKey,\n): boolean {\n if (\n !compressedTokenAccounts.every(account =>\n account.parsed.mint.equals(mint),\n )\n ) {\n throw new Error(`All input accounts must belong to the same mint`);\n }\n\n return true;\n}\n","/* The MIT License (MIT)\n *\n * Copyright 2015-2018 Peter A. Bigot\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\n/**\n * Support for translating between Buffer instances and JavaScript\n * native types.\n *\n * {@link module:Layout~Layout|Layout} is the basis of a class\n * hierarchy that associates property names with sequences of encoded\n * bytes.\n *\n * Layouts are supported for these scalar (numeric) types:\n * * {@link module:Layout~UInt|Unsigned integers in little-endian\n * format} with {@link module:Layout.u8|8-bit}, {@link\n * module:Layout.u16|16-bit}, {@link module:Layout.u24|24-bit},\n * {@link module:Layout.u32|32-bit}, {@link\n * module:Layout.u40|40-bit}, and {@link module:Layout.u48|48-bit}\n * representation ranges;\n * * {@link module:Layout~UIntBE|Unsigned integers in big-endian\n * format} with {@link module:Layout.u16be|16-bit}, {@link\n * module:Layout.u24be|24-bit}, {@link module:Layout.u32be|32-bit},\n * {@link module:Layout.u40be|40-bit}, and {@link\n * module:Layout.u48be|48-bit} representation ranges;\n * * {@link module:Layout~Int|Signed integers in little-endian\n * format} with {@link module:Layout.s8|8-bit}, {@link\n * module:Layout.s16|16-bit}, {@link module:Layout.s24|24-bit},\n * {@link module:Layout.s32|32-bit}, {@link\n * module:Layout.s40|40-bit}, and {@link module:Layout.s48|48-bit}\n * representation ranges;\n * * {@link module:Layout~IntBE|Signed integers in big-endian format}\n * with {@link module:Layout.s16be|16-bit}, {@link\n * module:Layout.s24be|24-bit}, {@link module:Layout.s32be|32-bit},\n * {@link module:Layout.s40be|40-bit}, and {@link\n * module:Layout.s48be|48-bit} representation ranges;\n * * 64-bit integral values that decode to an exact (if magnitude is\n * less than 2^53) or nearby integral Number in {@link\n * module:Layout.nu64|unsigned little-endian}, {@link\n * module:Layout.nu64be|unsigned big-endian}, {@link\n * module:Layout.ns64|signed little-endian}, and {@link\n * module:Layout.ns64be|unsigned big-endian} encodings;\n * * 32-bit floating point values with {@link\n * module:Layout.f32|little-endian} and {@link\n * module:Layout.f32be|big-endian} representations;\n * * 64-bit floating point values with {@link\n * module:Layout.f64|little-endian} and {@link\n * module:Layout.f64be|big-endian} representations;\n * * {@link module:Layout.const|Constants} that take no space in the\n * encoded expression.\n *\n * and for these aggregate types:\n * * {@link module:Layout.seq|Sequence}s of instances of a {@link\n * module:Layout~Layout|Layout}, with JavaScript representation as\n * an Array and constant or data-dependent {@link\n * module:Layout~Sequence#count|length};\n * * {@link module:Layout.struct|Structure}s that aggregate a\n * heterogeneous sequence of {@link module:Layout~Layout|Layout}\n * instances, with JavaScript representation as an Object;\n * * {@link module:Layout.union|Union}s that support multiple {@link\n * module:Layout~VariantLayout|variant layouts} over a fixed\n * (padded) or variable (not padded) span of bytes, using an\n * unsigned integer at the start of the data or a separate {@link\n * module:Layout.unionLayoutDiscriminator|layout element} to\n * determine which layout to use when interpreting the buffer\n * contents;\n * * {@link module:Layout.bits|BitStructure}s that contain a sequence\n * of individual {@link\n * module:Layout~BitStructure#addField|BitField}s packed into an 8,\n * 16, 24, or 32-bit unsigned integer starting at the least- or\n * most-significant bit;\n * * {@link module:Layout.cstr|C strings} of varying length;\n * * {@link module:Layout.blob|Blobs} of fixed- or variable-{@link\n * module:Layout~Blob#length|length} raw data.\n *\n * All {@link module:Layout~Layout|Layout} instances are immutable\n * after construction, to prevent internal state from becoming\n * inconsistent.\n *\n * @local Layout\n * @local ExternalLayout\n * @local GreedyCount\n * @local OffsetLayout\n * @local UInt\n * @local UIntBE\n * @local Int\n * @local IntBE\n * @local NearUInt64\n * @local NearUInt64BE\n * @local NearInt64\n * @local NearInt64BE\n * @local Float\n * @local FloatBE\n * @local Double\n * @local DoubleBE\n * @local Sequence\n * @local Structure\n * @local UnionDiscriminator\n * @local UnionLayoutDiscriminator\n * @local Union\n * @local VariantLayout\n * @local BitStructure\n * @local BitField\n * @local Boolean\n * @local Blob\n * @local CString\n * @local Constant\n * @local bindConstructorLayout\n * @module Layout\n * @license MIT\n * @author Peter A. Bigot\n * @see {@link https://github.com/pabigot/buffer-layout|buffer-layout on GitHub}\n */\n\n'use strict';\n\n/**\n * Base class for layout objects.\n *\n * **NOTE** This is an abstract base class; you can create instances\n * if it amuses you, but they won't support the {@link\n * Layout#encode|encode} or {@link Layout#decode|decode} functions.\n *\n * @param {Number} span - Initializer for {@link Layout#span|span}. The\n * parameter must be an integer; a negative value signifies that the\n * span is {@link Layout#getSpan|value-specific}.\n *\n * @param {string} [property] - Initializer for {@link\n * Layout#property|property}.\n *\n * @abstract\n */\nclass Layout {\n constructor(span, property) {\n if (!Number.isInteger(span)) {\n throw new TypeError('span must be an integer');\n }\n\n /** The span of the layout in bytes.\n *\n * Positive values are generally expected.\n *\n * Zero will only appear in {@link Constant}s and in {@link\n * Sequence}s where the {@link Sequence#count|count} is zero.\n *\n * A negative value indicates that the span is value-specific, and\n * must be obtained using {@link Layout#getSpan|getSpan}. */\n this.span = span;\n\n /** The property name used when this layout is represented in an\n * Object.\n *\n * Used only for layouts that {@link Layout#decode|decode} to Object\n * instances. If left undefined the span of the unnamed layout will\n * be treated as padding: it will not be mutated by {@link\n * Layout#encode|encode} nor represented as a property in the\n * decoded Object. */\n this.property = property;\n }\n\n /** Function to create an Object into which decoded properties will\n * be written.\n *\n * Used only for layouts that {@link Layout#decode|decode} to Object\n * instances, which means:\n * * {@link Structure}\n * * {@link Union}\n * * {@link VariantLayout}\n * * {@link BitStructure}\n *\n * If left undefined the JavaScript representation of these layouts\n * will be Object instances.\n *\n * See {@link bindConstructorLayout}.\n */\n makeDestinationObject() {\n return {};\n }\n\n /**\n * Decode from a Buffer into an JavaScript value.\n *\n * @param {Buffer} b - the buffer from which encoded data is read.\n *\n * @param {Number} [offset] - the offset at which the encoded data\n * starts. If absent a zero offset is inferred.\n *\n * @returns {(Number|Array|Object)} - the value of the decoded data.\n *\n * @abstract\n */\n decode(b, offset) {\n throw new Error('Layout is abstract');\n }\n\n /**\n * Encode a JavaScript value into a Buffer.\n *\n * @param {(Number|Array|Object)} src - the value to be encoded into\n * the buffer. The type accepted depends on the (sub-)type of {@link\n * Layout}.\n *\n * @param {Buffer} b - the buffer into which encoded data will be\n * written.\n *\n * @param {Number} [offset] - the offset at which the encoded data\n * starts. If absent a zero offset is inferred.\n *\n * @returns {Number} - the number of bytes encoded, including the\n * space skipped for internal padding, but excluding data such as\n * {@link Sequence#count|lengths} when stored {@link\n * ExternalLayout|externally}. This is the adjustment to `offset`\n * producing the offset where data for the next layout would be\n * written.\n *\n * @abstract\n */\n encode(src, b, offset) {\n throw new Error('Layout is abstract');\n }\n\n /**\n * Calculate the span of a specific instance of a layout.\n *\n * @param {Buffer} b - the buffer that contains an encoded instance.\n *\n * @param {Number} [offset] - the offset at which the encoded instance\n * starts. If absent a zero offset is inferred.\n *\n * @return {Number} - the number of bytes covered by the layout\n * instance. If this method is not overridden in a subclass the\n * definition-time constant {@link Layout#span|span} will be\n * returned.\n *\n * @throws {RangeError} - if the length of the value cannot be\n * determined.\n */\n getSpan(b, offset) {\n if (0 > this.span) {\n throw new RangeError('indeterminate span');\n }\n return this.span;\n }\n\n /**\n * Replicate the layout using a new property.\n *\n * This function must be used to get a structurally-equivalent layout\n * with a different name since all {@link Layout} instances are\n * immutable.\n *\n * **NOTE** This is a shallow copy. All fields except {@link\n * Layout#property|property} are strictly equal to the origin layout.\n *\n * @param {String} property - the value for {@link\n * Layout#property|property} in the replica.\n *\n * @returns {Layout} - the copy with {@link Layout#property|property}\n * set to `property`.\n */\n replicate(property) {\n const rv = Object.create(this.constructor.prototype);\n Object.assign(rv, this);\n rv.property = property;\n return rv;\n }\n\n /**\n * Create an object from layout properties and an array of values.\n *\n * **NOTE** This function returns `undefined` if invoked on a layout\n * that does not return its value as an Object. Objects are\n * returned for things that are a {@link Structure}, which includes\n * {@link VariantLayout|variant layouts} if they are structures, and\n * excludes {@link Union}s. If you want this feature for a union\n * you must use {@link Union.getVariant|getVariant} to select the\n * desired layout.\n *\n * @param {Array} values - an array of values that correspond to the\n * default order for properties. As with {@link Layout#decode|decode}\n * layout elements that have no property name are skipped when\n * iterating over the array values. Only the top-level properties are\n * assigned; arguments are not assigned to properties of contained\n * layouts. Any unused values are ignored.\n *\n * @return {(Object|undefined)}\n */\n fromArray(values) {\n return undefined;\n }\n}\nexports.Layout = Layout;\n\n/* Provide text that carries a name (such as for a function that will\n * be throwing an error) annotated with the property of a given layout\n * (such as one for which the value was unacceptable).\n *\n * @ignore */\nfunction nameWithProperty(name, lo) {\n if (lo.property) {\n return name + '[' + lo.property + ']';\n }\n return name;\n}\nexports.nameWithProperty = nameWithProperty;\n\n/**\n * Augment a class so that instances can be encoded/decoded using a\n * given layout.\n *\n * Calling this function couples `Class` with `layout` in several ways:\n *\n * * `Class.layout_` becomes a static member property equal to `layout`;\n * * `layout.boundConstructor_` becomes a static member property equal\n * to `Class`;\n * * The {@link Layout#makeDestinationObject|makeDestinationObject()}\n * property of `layout` is set to a function that returns a `new\n * Class()`;\n * * `Class.decode(b, offset)` becomes a static member function that\n * delegates to {@link Layout#decode|layout.decode}. The\n * synthesized function may be captured and extended.\n * * `Class.prototype.encode(b, offset)` provides an instance member\n * function that delegates to {@link Layout#encode|layout.encode}\n * with `src` set to `this`. The synthesized function may be\n * captured and extended, but when the extension is invoked `this`\n * must be explicitly bound to the instance.\n *\n * @param {class} Class - a JavaScript class with a nullary\n * constructor.\n *\n * @param {Layout} layout - the {@link Layout} instance used to encode\n * instances of `Class`.\n */\nfunction bindConstructorLayout(Class, layout) {\n if ('function' !== typeof Class) {\n throw new TypeError('Class must be constructor');\n }\n if (Class.hasOwnProperty('layout_')) {\n throw new Error('Class is already bound to a layout');\n }\n if (!(layout && (layout instanceof Layout))) {\n throw new TypeError('layout must be a Layout');\n }\n if (layout.hasOwnProperty('boundConstructor_')) {\n throw new Error('layout is already bound to a constructor');\n }\n Class.layout_ = layout;\n layout.boundConstructor_ = Class;\n layout.makeDestinationObject = (() => new Class());\n Object.defineProperty(Class.prototype, 'encode', {\n value: function(b, offset) {\n return layout.encode(this, b, offset);\n },\n writable: true,\n });\n Object.defineProperty(Class, 'decode', {\n value: function(b, offset) {\n return layout.decode(b, offset);\n },\n writable: true,\n });\n}\nexports.bindConstructorLayout = bindConstructorLayout;\n\n/**\n * An object that behaves like a layout but does not consume space\n * within its containing layout.\n *\n * This is primarily used to obtain metadata about a member, such as a\n * {@link OffsetLayout} that can provide data about a {@link\n * Layout#getSpan|value-specific span}.\n *\n * **NOTE** This is an abstract base class; you can create instances\n * if it amuses you, but they won't support {@link\n * ExternalLayout#isCount|isCount} or other {@link Layout} functions.\n *\n * @param {Number} span - initializer for {@link Layout#span|span}.\n * The parameter can range from 1 through 6.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @abstract\n * @augments {Layout}\n */\nclass ExternalLayout extends Layout {\n /**\n * Return `true` iff the external layout decodes to an unsigned\n * integer layout.\n *\n * In that case it can be used as the source of {@link\n * Sequence#count|Sequence counts}, {@link Blob#length|Blob lengths},\n * or as {@link UnionLayoutDiscriminator#layout|external union\n * discriminators}.\n *\n * @abstract\n */\n isCount() {\n throw new Error('ExternalLayout is abstract');\n }\n}\n\n/**\n * An {@link ExternalLayout} that determines its {@link\n * Layout#decode|value} based on offset into and length of the buffer\n * on which it is invoked.\n *\n * *Factory*: {@link module:Layout.greedy|greedy}\n *\n * @param {Number} [elementSpan] - initializer for {@link\n * GreedyCount#elementSpan|elementSpan}.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {ExternalLayout}\n */\nclass GreedyCount extends ExternalLayout {\n constructor(elementSpan, property) {\n if (undefined === elementSpan) {\n elementSpan = 1;\n }\n if ((!Number.isInteger(elementSpan)) || (0 >= elementSpan)) {\n throw new TypeError('elementSpan must be a (positive) integer');\n }\n super(-1, property);\n\n /** The layout for individual elements of the sequence. The value\n * must be a positive integer. If not provided, the value will be\n * 1. */\n this.elementSpan = elementSpan;\n }\n\n /** @override */\n isCount() {\n return true;\n }\n\n /** @override */\n decode(b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n const rem = b.length - offset;\n return Math.floor(rem / this.elementSpan);\n }\n\n /** @override */\n encode(src, b, offset) {\n return 0;\n }\n}\n\n/**\n * An {@link ExternalLayout} that supports accessing a {@link Layout}\n * at a fixed offset from the start of another Layout. The offset may\n * be before, within, or after the base layout.\n *\n * *Factory*: {@link module:Layout.offset|offset}\n *\n * @param {Layout} layout - initializer for {@link\n * OffsetLayout#layout|layout}, modulo `property`.\n *\n * @param {Number} [offset] - Initializes {@link\n * OffsetLayout#offset|offset}. Defaults to zero.\n *\n * @param {string} [property] - Optional new property name for a\n * {@link Layout#replicate| replica} of `layout` to be used as {@link\n * OffsetLayout#layout|layout}. If not provided the `layout` is used\n * unchanged.\n *\n * @augments {Layout}\n */\nclass OffsetLayout extends ExternalLayout {\n constructor(layout, offset, property) {\n if (!(layout instanceof Layout)) {\n throw new TypeError('layout must be a Layout');\n }\n\n if (undefined === offset) {\n offset = 0;\n } else if (!Number.isInteger(offset)) {\n throw new TypeError('offset must be integer or undefined');\n }\n\n super(layout.span, property || layout.property);\n\n /** The subordinated layout. */\n this.layout = layout;\n\n /** The location of {@link OffsetLayout#layout} relative to the\n * start of another layout.\n *\n * The value may be positive or negative, but an error will thrown\n * if at the point of use it goes outside the span of the Buffer\n * being accessed. */\n this.offset = offset;\n }\n\n /** @override */\n isCount() {\n return ((this.layout instanceof UInt)\n || (this.layout instanceof UIntBE));\n }\n\n /** @override */\n decode(b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n return this.layout.decode(b, offset + this.offset);\n }\n\n /** @override */\n encode(src, b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n return this.layout.encode(src, b, offset + this.offset);\n }\n}\n\n/**\n * Represent an unsigned integer in little-endian format.\n *\n * *Factory*: {@link module:Layout.u8|u8}, {@link\n * module:Layout.u16|u16}, {@link module:Layout.u24|u24}, {@link\n * module:Layout.u32|u32}, {@link module:Layout.u40|u40}, {@link\n * module:Layout.u48|u48}\n *\n * @param {Number} span - initializer for {@link Layout#span|span}.\n * The parameter can range from 1 through 6.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass UInt extends Layout {\n constructor(span, property) {\n super(span, property);\n if (6 < this.span) {\n throw new RangeError('span must not exceed 6 bytes');\n }\n }\n\n /** @override */\n decode(b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n return b.readUIntLE(offset, this.span);\n }\n\n /** @override */\n encode(src, b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n b.writeUIntLE(src, offset, this.span);\n return this.span;\n }\n}\n\n/**\n * Represent an unsigned integer in big-endian format.\n *\n * *Factory*: {@link module:Layout.u8be|u8be}, {@link\n * module:Layout.u16be|u16be}, {@link module:Layout.u24be|u24be},\n * {@link module:Layout.u32be|u32be}, {@link\n * module:Layout.u40be|u40be}, {@link module:Layout.u48be|u48be}\n *\n * @param {Number} span - initializer for {@link Layout#span|span}.\n * The parameter can range from 1 through 6.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass UIntBE extends Layout {\n constructor(span, property) {\n super( span, property);\n if (6 < this.span) {\n throw new RangeError('span must not exceed 6 bytes');\n }\n }\n\n /** @override */\n decode(b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n return b.readUIntBE(offset, this.span);\n }\n\n /** @override */\n encode(src, b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n b.writeUIntBE(src, offset, this.span);\n return this.span;\n }\n}\n\n/**\n * Represent a signed integer in little-endian format.\n *\n * *Factory*: {@link module:Layout.s8|s8}, {@link\n * module:Layout.s16|s16}, {@link module:Layout.s24|s24}, {@link\n * module:Layout.s32|s32}, {@link module:Layout.s40|s40}, {@link\n * module:Layout.s48|s48}\n *\n * @param {Number} span - initializer for {@link Layout#span|span}.\n * The parameter can range from 1 through 6.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass Int extends Layout {\n constructor(span, property) {\n super(span, property);\n if (6 < this.span) {\n throw new RangeError('span must not exceed 6 bytes');\n }\n }\n\n /** @override */\n decode(b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n return b.readIntLE(offset, this.span);\n }\n\n /** @override */\n encode(src, b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n b.writeIntLE(src, offset, this.span);\n return this.span;\n }\n}\n\n/**\n * Represent a signed integer in big-endian format.\n *\n * *Factory*: {@link module:Layout.s8be|s8be}, {@link\n * module:Layout.s16be|s16be}, {@link module:Layout.s24be|s24be},\n * {@link module:Layout.s32be|s32be}, {@link\n * module:Layout.s40be|s40be}, {@link module:Layout.s48be|s48be}\n *\n * @param {Number} span - initializer for {@link Layout#span|span}.\n * The parameter can range from 1 through 6.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass IntBE extends Layout {\n constructor(span, property) {\n super(span, property);\n if (6 < this.span) {\n throw new RangeError('span must not exceed 6 bytes');\n }\n }\n\n /** @override */\n decode(b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n return b.readIntBE(offset, this.span);\n }\n\n /** @override */\n encode(src, b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n b.writeIntBE(src, offset, this.span);\n return this.span;\n }\n}\n\nconst V2E32 = Math.pow(2, 32);\n\n/* True modulus high and low 32-bit words, where low word is always\n * non-negative. */\nfunction divmodInt64(src) {\n const hi32 = Math.floor(src / V2E32);\n const lo32 = src - (hi32 * V2E32);\n return {hi32, lo32};\n}\n/* Reconstruct Number from quotient and non-negative remainder */\nfunction roundedInt64(hi32, lo32) {\n return hi32 * V2E32 + lo32;\n}\n\n/**\n * Represent an unsigned 64-bit integer in little-endian format when\n * encoded and as a near integral JavaScript Number when decoded.\n *\n * *Factory*: {@link module:Layout.nu64|nu64}\n *\n * **NOTE** Values with magnitude greater than 2^52 may not decode to\n * the exact value of the encoded representation.\n *\n * @augments {Layout}\n */\nclass NearUInt64 extends Layout {\n constructor(property) {\n super(8, property);\n }\n\n /** @override */\n decode(b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n const lo32 = b.readUInt32LE(offset);\n const hi32 = b.readUInt32LE(offset + 4);\n return roundedInt64(hi32, lo32);\n }\n\n /** @override */\n encode(src, b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n const split = divmodInt64(src);\n b.writeUInt32LE(split.lo32, offset);\n b.writeUInt32LE(split.hi32, offset + 4);\n return 8;\n }\n}\n\n/**\n * Represent an unsigned 64-bit integer in big-endian format when\n * encoded and as a near integral JavaScript Number when decoded.\n *\n * *Factory*: {@link module:Layout.nu64be|nu64be}\n *\n * **NOTE** Values with magnitude greater than 2^52 may not decode to\n * the exact value of the encoded representation.\n *\n * @augments {Layout}\n */\nclass NearUInt64BE extends Layout {\n constructor(property) {\n super(8, property);\n }\n\n /** @override */\n decode(b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n const hi32 = b.readUInt32BE(offset);\n const lo32 = b.readUInt32BE(offset + 4);\n return roundedInt64(hi32, lo32);\n }\n\n /** @override */\n encode(src, b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n const split = divmodInt64(src);\n b.writeUInt32BE(split.hi32, offset);\n b.writeUInt32BE(split.lo32, offset + 4);\n return 8;\n }\n}\n\n/**\n * Represent a signed 64-bit integer in little-endian format when\n * encoded and as a near integral JavaScript Number when decoded.\n *\n * *Factory*: {@link module:Layout.ns64|ns64}\n *\n * **NOTE** Values with magnitude greater than 2^52 may not decode to\n * the exact value of the encoded representation.\n *\n * @augments {Layout}\n */\nclass NearInt64 extends Layout {\n constructor(property) {\n super(8, property);\n }\n\n /** @override */\n decode(b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n const lo32 = b.readUInt32LE(offset);\n const hi32 = b.readInt32LE(offset + 4);\n return roundedInt64(hi32, lo32);\n }\n\n /** @override */\n encode(src, b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n const split = divmodInt64(src);\n b.writeUInt32LE(split.lo32, offset);\n b.writeInt32LE(split.hi32, offset + 4);\n return 8;\n }\n}\n\n/**\n * Represent a signed 64-bit integer in big-endian format when\n * encoded and as a near integral JavaScript Number when decoded.\n *\n * *Factory*: {@link module:Layout.ns64be|ns64be}\n *\n * **NOTE** Values with magnitude greater than 2^52 may not decode to\n * the exact value of the encoded representation.\n *\n * @augments {Layout}\n */\nclass NearInt64BE extends Layout {\n constructor(property) {\n super(8, property);\n }\n\n /** @override */\n decode(b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n const hi32 = b.readInt32BE(offset);\n const lo32 = b.readUInt32BE(offset + 4);\n return roundedInt64(hi32, lo32);\n }\n\n /** @override */\n encode(src, b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n const split = divmodInt64(src);\n b.writeInt32BE(split.hi32, offset);\n b.writeUInt32BE(split.lo32, offset + 4);\n return 8;\n }\n}\n\n/**\n * Represent a 32-bit floating point number in little-endian format.\n *\n * *Factory*: {@link module:Layout.f32|f32}\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass Float extends Layout {\n constructor(property) {\n super(4, property);\n }\n\n /** @override */\n decode(b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n return b.readFloatLE(offset);\n }\n\n /** @override */\n encode(src, b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n b.writeFloatLE(src, offset);\n return 4;\n }\n}\n\n/**\n * Represent a 32-bit floating point number in big-endian format.\n *\n * *Factory*: {@link module:Layout.f32be|f32be}\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass FloatBE extends Layout {\n constructor(property) {\n super(4, property);\n }\n\n /** @override */\n decode(b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n return b.readFloatBE(offset);\n }\n\n /** @override */\n encode(src, b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n b.writeFloatBE(src, offset);\n return 4;\n }\n}\n\n/**\n * Represent a 64-bit floating point number in little-endian format.\n *\n * *Factory*: {@link module:Layout.f64|f64}\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass Double extends Layout {\n constructor(property) {\n super(8, property);\n }\n\n /** @override */\n decode(b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n return b.readDoubleLE(offset);\n }\n\n /** @override */\n encode(src, b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n b.writeDoubleLE(src, offset);\n return 8;\n }\n}\n\n/**\n * Represent a 64-bit floating point number in big-endian format.\n *\n * *Factory*: {@link module:Layout.f64be|f64be}\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass DoubleBE extends Layout {\n constructor(property) {\n super(8, property);\n }\n\n /** @override */\n decode(b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n return b.readDoubleBE(offset);\n }\n\n /** @override */\n encode(src, b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n b.writeDoubleBE(src, offset);\n return 8;\n }\n}\n\n/**\n * Represent a contiguous sequence of a specific layout as an Array.\n *\n * *Factory*: {@link module:Layout.seq|seq}\n *\n * @param {Layout} elementLayout - initializer for {@link\n * Sequence#elementLayout|elementLayout}.\n *\n * @param {(Number|ExternalLayout)} count - initializer for {@link\n * Sequence#count|count}. The parameter must be either a positive\n * integer or an instance of {@link ExternalLayout}.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass Sequence extends Layout {\n constructor(elementLayout, count, property) {\n if (!(elementLayout instanceof Layout)) {\n throw new TypeError('elementLayout must be a Layout');\n }\n if (!(((count instanceof ExternalLayout) && count.isCount())\n || (Number.isInteger(count) && (0 <= count)))) {\n throw new TypeError('count must be non-negative integer '\n + 'or an unsigned integer ExternalLayout');\n }\n let span = -1;\n if ((!(count instanceof ExternalLayout))\n && (0 < elementLayout.span)) {\n span = count * elementLayout.span;\n }\n\n super(span, property);\n\n /** The layout for individual elements of the sequence. */\n this.elementLayout = elementLayout;\n\n /** The number of elements in the sequence.\n *\n * This will be either a non-negative integer or an instance of\n * {@link ExternalLayout} for which {@link\n * ExternalLayout#isCount|isCount()} is `true`. */\n this.count = count;\n }\n\n /** @override */\n getSpan(b, offset) {\n if (0 <= this.span) {\n return this.span;\n }\n if (undefined === offset) {\n offset = 0;\n }\n let span = 0;\n let count = this.count;\n if (count instanceof ExternalLayout) {\n count = count.decode(b, offset);\n }\n if (0 < this.elementLayout.span) {\n span = count * this.elementLayout.span;\n } else {\n let idx = 0;\n while (idx < count) {\n span += this.elementLayout.getSpan(b, offset + span);\n ++idx;\n }\n }\n return span;\n }\n\n /** @override */\n decode(b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n const rv = [];\n let i = 0;\n let count = this.count;\n if (count instanceof ExternalLayout) {\n count = count.decode(b, offset);\n }\n while (i < count) {\n rv.push(this.elementLayout.decode(b, offset));\n offset += this.elementLayout.getSpan(b, offset);\n i += 1;\n }\n return rv;\n }\n\n /** Implement {@link Layout#encode|encode} for {@link Sequence}.\n *\n * **NOTE** If `src` is shorter than {@link Sequence#count|count} then\n * the unused space in the buffer is left unchanged. If `src` is\n * longer than {@link Sequence#count|count} the unneeded elements are\n * ignored.\n *\n * **NOTE** If {@link Layout#count|count} is an instance of {@link\n * ExternalLayout} then the length of `src` will be encoded as the\n * count after `src` is encoded. */\n encode(src, b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n const elo = this.elementLayout;\n const span = src.reduce((span, v) => {\n return span + elo.encode(v, b, offset + span);\n }, 0);\n if (this.count instanceof ExternalLayout) {\n this.count.encode(src.length, b, offset);\n }\n return span;\n }\n}\n\n/**\n * Represent a contiguous sequence of arbitrary layout elements as an\n * Object.\n *\n * *Factory*: {@link module:Layout.struct|struct}\n *\n * **NOTE** The {@link Layout#span|span} of the structure is variable\n * if any layout in {@link Structure#fields|fields} has a variable\n * span. When {@link Layout#encode|encoding} we must have a value for\n * all variable-length fields, or we wouldn't be able to figure out\n * how much space to use for storage. We can only identify the value\n * for a field when it has a {@link Layout#property|property}. As\n * such, although a structure may contain both unnamed fields and\n * variable-length fields, it cannot contain an unnamed\n * variable-length field.\n *\n * @param {Layout[]} fields - initializer for {@link\n * Structure#fields|fields}. An error is raised if this contains a\n * variable-length field for which a {@link Layout#property|property}\n * is not defined.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @param {Boolean} [decodePrefixes] - initializer for {@link\n * Structure#decodePrefixes|property}.\n *\n * @throws {Error} - if `fields` contains an unnamed variable-length\n * layout.\n *\n * @augments {Layout}\n */\nclass Structure extends Layout {\n constructor(fields, property, decodePrefixes) {\n if (!(Array.isArray(fields)\n && fields.reduce((acc, v) => acc && (v instanceof Layout), true))) {\n throw new TypeError('fields must be array of Layout instances');\n }\n if (('boolean' === typeof property)\n && (undefined === decodePrefixes)) {\n decodePrefixes = property;\n property = undefined;\n }\n\n /* Verify absence of unnamed variable-length fields. */\n for (const fd of fields) {\n if ((0 > fd.span)\n && (undefined === fd.property)) {\n throw new Error('fields cannot contain unnamed variable-length layout');\n }\n }\n\n let span = -1;\n try {\n span = fields.reduce((span, fd) => span + fd.getSpan(), 0);\n } catch (e) {\n }\n super(span, property);\n\n /** The sequence of {@link Layout} values that comprise the\n * structure.\n *\n * The individual elements need not be the same type, and may be\n * either scalar or aggregate layouts. If a member layout leaves\n * its {@link Layout#property|property} undefined the\n * corresponding region of the buffer associated with the element\n * will not be mutated.\n *\n * @type {Layout[]} */\n this.fields = fields;\n\n /** Control behavior of {@link Layout#decode|decode()} given short\n * buffers.\n *\n * In some situations a structure many be extended with additional\n * fields over time, with older installations providing only a\n * prefix of the full structure. If this property is `true`\n * decoding will accept those buffers and leave subsequent fields\n * undefined, as long as the buffer ends at a field boundary.\n * Defaults to `false`. */\n this.decodePrefixes = !!decodePrefixes;\n }\n\n /** @override */\n getSpan(b, offset) {\n if (0 <= this.span) {\n return this.span;\n }\n if (undefined === offset) {\n offset = 0;\n }\n let span = 0;\n try {\n span = this.fields.reduce((span, fd) => {\n const fsp = fd.getSpan(b, offset);\n offset += fsp;\n return span + fsp;\n }, 0);\n } catch (e) {\n throw new RangeError('indeterminate span');\n }\n return span;\n }\n\n /** @override */\n decode(b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n const dest = this.makeDestinationObject();\n for (const fd of this.fields) {\n if (undefined !== fd.property) {\n dest[fd.property] = fd.decode(b, offset);\n }\n offset += fd.getSpan(b, offset);\n if (this.decodePrefixes\n && (b.length === offset)) {\n break;\n }\n }\n return dest;\n }\n\n /** Implement {@link Layout#encode|encode} for {@link Structure}.\n *\n * If `src` is missing a property for a member with a defined {@link\n * Layout#property|property} the corresponding region of the buffer is\n * left unmodified. */\n encode(src, b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n const firstOffset = offset;\n let lastOffset = 0;\n let lastWrote = 0;\n for (const fd of this.fields) {\n let span = fd.span;\n lastWrote = (0 < span) ? span : 0;\n if (undefined !== fd.property) {\n const fv = src[fd.property];\n if (undefined !== fv) {\n lastWrote = fd.encode(fv, b, offset);\n if (0 > span) {\n /* Read the as-encoded span, which is not necessarily the\n * same as what we wrote. */\n span = fd.getSpan(b, offset);\n }\n }\n }\n lastOffset = offset;\n offset += span;\n }\n /* Use (lastOffset + lastWrote) instead of offset because the last\n * item may have had a dynamic length and we don't want to include\n * the padding between it and the end of the space reserved for\n * it. */\n return (lastOffset + lastWrote) - firstOffset;\n }\n\n /** @override */\n fromArray(values) {\n const dest = this.makeDestinationObject();\n for (const fd of this.fields) {\n if ((undefined !== fd.property)\n && (0 < values.length)) {\n dest[fd.property] = values.shift();\n }\n }\n return dest;\n }\n\n /**\n * Get access to the layout of a given property.\n *\n * @param {String} property - the structure member of interest.\n *\n * @return {Layout} - the layout associated with `property`, or\n * undefined if there is no such property.\n */\n layoutFor(property) {\n if ('string' !== typeof property) {\n throw new TypeError('property must be string');\n }\n for (const fd of this.fields) {\n if (fd.property === property) {\n return fd;\n }\n }\n }\n\n /**\n * Get the offset of a structure member.\n *\n * @param {String} property - the structure member of interest.\n *\n * @return {Number} - the offset in bytes to the start of `property`\n * within the structure, or undefined if `property` is not a field\n * within the structure. If the property is a member but follows a\n * variable-length structure member a negative number will be\n * returned.\n */\n offsetOf(property) {\n if ('string' !== typeof property) {\n throw new TypeError('property must be string');\n }\n let offset = 0;\n for (const fd of this.fields) {\n if (fd.property === property) {\n return offset;\n }\n if (0 > fd.span) {\n offset = -1;\n } else if (0 <= offset) {\n offset += fd.span;\n }\n }\n }\n}\n\n/**\n * An object that can provide a {@link\n * Union#discriminator|discriminator} API for {@link Union}.\n *\n * **NOTE** This is an abstract base class; you can create instances\n * if it amuses you, but they won't support the {@link\n * UnionDiscriminator#encode|encode} or {@link\n * UnionDiscriminator#decode|decode} functions.\n *\n * @param {string} [property] - Default for {@link\n * UnionDiscriminator#property|property}.\n *\n * @abstract\n */\nclass UnionDiscriminator {\n constructor(property) {\n /** The {@link Layout#property|property} to be used when the\n * discriminator is referenced in isolation (generally when {@link\n * Union#decode|Union decode} cannot delegate to a specific\n * variant). */\n this.property = property;\n }\n\n /** Analog to {@link Layout#decode|Layout decode} for union discriminators.\n *\n * The implementation of this method need not reference the buffer if\n * variant information is available through other means. */\n decode() {\n throw new Error('UnionDiscriminator is abstract');\n }\n\n /** Analog to {@link Layout#decode|Layout encode} for union discriminators.\n *\n * The implementation of this method need not store the value if\n * variant information is maintained through other means. */\n encode() {\n throw new Error('UnionDiscriminator is abstract');\n }\n}\n\n/**\n * An object that can provide a {@link\n * UnionDiscriminator|discriminator API} for {@link Union} using an\n * unsigned integral {@link Layout} instance located either inside or\n * outside the union.\n *\n * @param {ExternalLayout} layout - initializes {@link\n * UnionLayoutDiscriminator#layout|layout}. Must satisfy {@link\n * ExternalLayout#isCount|isCount()}.\n *\n * @param {string} [property] - Default for {@link\n * UnionDiscriminator#property|property}, superseding the property\n * from `layout`, but defaulting to `variant` if neither `property`\n * nor layout provide a property name.\n *\n * @augments {UnionDiscriminator}\n */\nclass UnionLayoutDiscriminator extends UnionDiscriminator {\n constructor(layout, property) {\n if (!((layout instanceof ExternalLayout)\n && layout.isCount())) {\n throw new TypeError('layout must be an unsigned integer ExternalLayout');\n }\n\n super(property || layout.property || 'variant');\n\n /** The {@link ExternalLayout} used to access the discriminator\n * value. */\n this.layout = layout;\n }\n\n /** Delegate decoding to {@link UnionLayoutDiscriminator#layout|layout}. */\n decode(b, offset) {\n return this.layout.decode(b, offset);\n }\n\n /** Delegate encoding to {@link UnionLayoutDiscriminator#layout|layout}. */\n encode(src, b, offset) {\n return this.layout.encode(src, b, offset);\n }\n}\n\n/**\n * Represent any number of span-compatible layouts.\n *\n * *Factory*: {@link module:Layout.union|union}\n *\n * If the union has a {@link Union#defaultLayout|default layout} that\n * layout must have a non-negative {@link Layout#span|span}. The span\n * of a fixed-span union includes its {@link\n * Union#discriminator|discriminator} if the variant is a {@link\n * Union#usesPrefixDiscriminator|prefix of the union}, plus the span\n * of its {@link Union#defaultLayout|default layout}.\n *\n * If the union does not have a default layout then the encoded span\n * of the union depends on the encoded span of its variant (which may\n * be fixed or variable).\n *\n * {@link VariantLayout#layout|Variant layout}s are added through\n * {@link Union#addVariant|addVariant}. If the union has a default\n * layout, the span of the {@link VariantLayout#layout|layout\n * contained by the variant} must not exceed the span of the {@link\n * Union#defaultLayout|default layout} (minus the span of a {@link\n * Union#usesPrefixDiscriminator|prefix disriminator}, if used). The\n * span of the variant will equal the span of the union itself.\n *\n * The variant for a buffer can only be identified from the {@link\n * Union#discriminator|discriminator} {@link\n * UnionDiscriminator#property|property} (in the case of the {@link\n * Union#defaultLayout|default layout}), or by using {@link\n * Union#getVariant|getVariant} and examining the resulting {@link\n * VariantLayout} instance.\n *\n * A variant compatible with a JavaScript object can be identified\n * using {@link Union#getSourceVariant|getSourceVariant}.\n *\n * @param {(UnionDiscriminator|ExternalLayout|Layout)} discr - How to\n * identify the layout used to interpret the union contents. The\n * parameter must be an instance of {@link UnionDiscriminator}, an\n * {@link ExternalLayout} that satisfies {@link\n * ExternalLayout#isCount|isCount()}, or {@link UInt} (or {@link\n * UIntBE}). When a non-external layout element is passed the layout\n * appears at the start of the union. In all cases the (synthesized)\n * {@link UnionDiscriminator} instance is recorded as {@link\n * Union#discriminator|discriminator}.\n *\n * @param {(Layout|null)} defaultLayout - initializer for {@link\n * Union#defaultLayout|defaultLayout}. If absent defaults to `null`.\n * If `null` there is no default layout: the union has data-dependent\n * length and attempts to decode or encode unrecognized variants will\n * throw an exception. A {@link Layout} instance must have a\n * non-negative {@link Layout#span|span}, and if it lacks a {@link\n * Layout#property|property} the {@link\n * Union#defaultLayout|defaultLayout} will be a {@link\n * Layout#replicate|replica} with property `content`.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass Union extends Layout {\n constructor(discr, defaultLayout, property) {\n const upv = ((discr instanceof UInt)\n || (discr instanceof UIntBE));\n if (upv) {\n discr = new UnionLayoutDiscriminator(new OffsetLayout(discr));\n } else if ((discr instanceof ExternalLayout)\n && discr.isCount()) {\n discr = new UnionLayoutDiscriminator(discr);\n } else if (!(discr instanceof UnionDiscriminator)) {\n throw new TypeError('discr must be a UnionDiscriminator '\n + 'or an unsigned integer layout');\n }\n if (undefined === defaultLayout) {\n defaultLayout = null;\n }\n if (!((null === defaultLayout)\n || (defaultLayout instanceof Layout))) {\n throw new TypeError('defaultLayout must be null or a Layout');\n }\n if (null !== defaultLayout) {\n if (0 > defaultLayout.span) {\n throw new Error('defaultLayout must have constant span');\n }\n if (undefined === defaultLayout.property) {\n defaultLayout = defaultLayout.replicate('content');\n }\n }\n\n /* The union span can be estimated only if there's a default\n * layout. The union spans its default layout, plus any prefix\n * variant layout. By construction both layouts, if present, have\n * non-negative span. */\n let span = -1;\n if (defaultLayout) {\n span = defaultLayout.span;\n if ((0 <= span) && upv) {\n span += discr.layout.span;\n }\n }\n super(span, property);\n\n /** The interface for the discriminator value in isolation.\n *\n * This a {@link UnionDiscriminator} either passed to the\n * constructor or synthesized from the `discr` constructor\n * argument. {@link\n * Union#usesPrefixDiscriminator|usesPrefixDiscriminator} will be\n * `true` iff the `discr` parameter was a non-offset {@link\n * Layout} instance. */\n this.discriminator = discr;\n\n /** `true` if the {@link Union#discriminator|discriminator} is the\n * first field in the union.\n *\n * If `false` the discriminator is obtained from somewhere\n * else. */\n this.usesPrefixDiscriminator = upv;\n\n /** The layout for non-discriminator content when the value of the\n * discriminator is not recognized.\n *\n * This is the value passed to the constructor. It is\n * structurally equivalent to the second component of {@link\n * Union#layout|layout} but may have a different property\n * name. */\n this.defaultLayout = defaultLayout;\n\n /** A registry of allowed variants.\n *\n * The keys are unsigned integers which should be compatible with\n * {@link Union.discriminator|discriminator}. The property value\n * is the corresponding {@link VariantLayout} instances assigned\n * to this union by {@link Union#addVariant|addVariant}.\n *\n * **NOTE** The registry remains mutable so that variants can be\n * {@link Union#addVariant|added} at any time. Users should not\n * manipulate the content of this property. */\n this.registry = {};\n\n /* Private variable used when invoking getSourceVariant */\n let boundGetSourceVariant = this.defaultGetSourceVariant.bind(this);\n\n /** Function to infer the variant selected by a source object.\n *\n * Defaults to {@link\n * Union#defaultGetSourceVariant|defaultGetSourceVariant} but may\n * be overridden using {@link\n * Union#configGetSourceVariant|configGetSourceVariant}.\n *\n * @param {Object} src - as with {@link\n * Union#defaultGetSourceVariant|defaultGetSourceVariant}.\n *\n * @returns {(undefined|VariantLayout)} The default variant\n * (`undefined`) or first registered variant that uses a property\n * available in `src`. */\n this.getSourceVariant = function(src) {\n return boundGetSourceVariant(src);\n };\n\n /** Function to override the implementation of {@link\n * Union#getSourceVariant|getSourceVariant}.\n *\n * Use this if the desired variant cannot be identified using the\n * algorithm of {@link\n * Union#defaultGetSourceVariant|defaultGetSourceVariant}.\n *\n * **NOTE** The provided function will be invoked bound to this\n * Union instance, providing local access to {@link\n * Union#registry|registry}.\n *\n * @param {Function} gsv - a function that follows the API of\n * {@link Union#defaultGetSourceVariant|defaultGetSourceVariant}. */\n this.configGetSourceVariant = function(gsv) {\n boundGetSourceVariant = gsv.bind(this);\n };\n }\n\n /** @override */\n getSpan(b, offset) {\n if (0 <= this.span) {\n return this.span;\n }\n if (undefined === offset) {\n offset = 0;\n }\n /* Default layouts always have non-negative span, so we don't have\n * one and we have to recognize the variant which will in turn\n * determine the span. */\n const vlo = this.getVariant(b, offset);\n if (!vlo) {\n throw new Error('unable to determine span for unrecognized variant');\n }\n return vlo.getSpan(b, offset);\n }\n\n /**\n * Method to infer a registered Union variant compatible with `src`.\n *\n * The first satisified rule in the following sequence defines the\n * return value:\n * * If `src` has properties matching the Union discriminator and\n * the default layout, `undefined` is returned regardless of the\n * value of the discriminator property (this ensures the default\n * layout will be used);\n * * If `src` has a property matching the Union discriminator, the\n * value of the discriminator identifies a registered variant, and\n * either (a) the variant has no layout, or (b) `src` has the\n * variant's property, then the variant is returned (because the\n * source satisfies the constraints of the variant it identifies);\n * * If `src` does not have a property matching the Union\n * discriminator, but does have a property matching a registered\n * variant, then the variant is returned (because the source\n * matches a variant without an explicit conflict);\n * * An error is thrown (because we either can't identify a variant,\n * or we were explicitly told the variant but can't satisfy it).\n *\n * @param {Object} src - an object presumed to be compatible with\n * the content of the Union.\n *\n * @return {(undefined|VariantLayout)} - as described above.\n *\n * @throws {Error} - if `src` cannot be associated with a default or\n * registered variant.\n */\n defaultGetSourceVariant(src) {\n if (src.hasOwnProperty(this.discriminator.property)) {\n if (this.defaultLayout\n && src.hasOwnProperty(this.defaultLayout.property)) {\n return undefined;\n }\n const vlo = this.registry[src[this.discriminator.property]];\n if (vlo\n && ((!vlo.layout)\n || src.hasOwnProperty(vlo.property))) {\n return vlo;\n }\n } else {\n for (const tag in this.registry) {\n const vlo = this.registry[tag];\n if (src.hasOwnProperty(vlo.property)) {\n return vlo;\n }\n }\n }\n throw new Error('unable to infer src variant');\n }\n\n /** Implement {@link Layout#decode|decode} for {@link Union}.\n *\n * If the variant is {@link Union#addVariant|registered} the return\n * value is an instance of that variant, with no explicit\n * discriminator. Otherwise the {@link Union#defaultLayout|default\n * layout} is used to decode the content. */\n decode(b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n let dest;\n const dlo = this.discriminator;\n const discr = dlo.decode(b, offset);\n let clo = this.registry[discr];\n if (undefined === clo) {\n let contentOffset = 0;\n clo = this.defaultLayout;\n if (this.usesPrefixDiscriminator) {\n contentOffset = dlo.layout.span;\n }\n dest = this.makeDestinationObject();\n dest[dlo.property] = discr;\n dest[clo.property] = this.defaultLayout.decode(b, offset + contentOffset);\n } else {\n dest = clo.decode(b, offset);\n }\n return dest;\n }\n\n /** Implement {@link Layout#encode|encode} for {@link Union}.\n *\n * This API assumes the `src` object is consistent with the union's\n * {@link Union#defaultLayout|default layout}. To encode variants\n * use the appropriate variant-specific {@link VariantLayout#encode}\n * method. */\n encode(src, b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n const vlo = this.getSourceVariant(src);\n if (undefined === vlo) {\n const dlo = this.discriminator;\n const clo = this.defaultLayout;\n let contentOffset = 0;\n if (this.usesPrefixDiscriminator) {\n contentOffset = dlo.layout.span;\n }\n dlo.encode(src[dlo.property], b, offset);\n return contentOffset + clo.encode(src[clo.property], b,\n offset + contentOffset);\n }\n return vlo.encode(src, b, offset);\n }\n\n /** Register a new variant structure within a union. The newly\n * created variant is returned.\n *\n * @param {Number} variant - initializer for {@link\n * VariantLayout#variant|variant}.\n *\n * @param {Layout} layout - initializer for {@link\n * VariantLayout#layout|layout}.\n *\n * @param {String} property - initializer for {@link\n * Layout#property|property}.\n *\n * @return {VariantLayout} */\n addVariant(variant, layout, property) {\n const rv = new VariantLayout(this, variant, layout, property);\n this.registry[variant] = rv;\n return rv;\n }\n\n /**\n * Get the layout associated with a registered variant.\n *\n * If `vb` does not produce a registered variant the function returns\n * `undefined`.\n *\n * @param {(Number|Buffer)} vb - either the variant number, or a\n * buffer from which the discriminator is to be read.\n *\n * @param {Number} offset - offset into `vb` for the start of the\n * union. Used only when `vb` is an instance of {Buffer}.\n *\n * @return {({VariantLayout}|undefined)}\n */\n getVariant(vb, offset) {\n let variant = vb;\n if (Buffer.isBuffer(vb)) {\n if (undefined === offset) {\n offset = 0;\n }\n variant = this.discriminator.decode(vb, offset);\n }\n return this.registry[variant];\n }\n}\n\n/**\n * Represent a specific variant within a containing union.\n *\n * **NOTE** The {@link Layout#span|span} of the variant may include\n * the span of the {@link Union#discriminator|discriminator} used to\n * identify it, but values read and written using the variant strictly\n * conform to the content of {@link VariantLayout#layout|layout}.\n *\n * **NOTE** User code should not invoke this constructor directly. Use\n * the union {@link Union#addVariant|addVariant} helper method.\n *\n * @param {Union} union - initializer for {@link\n * VariantLayout#union|union}.\n *\n * @param {Number} variant - initializer for {@link\n * VariantLayout#variant|variant}.\n *\n * @param {Layout} [layout] - initializer for {@link\n * VariantLayout#layout|layout}. If absent the variant carries no\n * data.\n *\n * @param {String} [property] - initializer for {@link\n * Layout#property|property}. Unlike many other layouts, variant\n * layouts normally include a property name so they can be identified\n * within their containing {@link Union}. The property identifier may\n * be absent only if `layout` is is absent.\n *\n * @augments {Layout}\n */\nclass VariantLayout extends Layout {\n constructor(union, variant, layout, property) {\n if (!(union instanceof Union)) {\n throw new TypeError('union must be a Union');\n }\n if ((!Number.isInteger(variant)) || (0 > variant)) {\n throw new TypeError('variant must be a (non-negative) integer');\n }\n if (('string' === typeof layout)\n && (undefined === property)) {\n property = layout;\n layout = null;\n }\n if (layout) {\n if (!(layout instanceof Layout)) {\n throw new TypeError('layout must be a Layout');\n }\n if ((null !== union.defaultLayout)\n && (0 <= layout.span)\n && (layout.span > union.defaultLayout.span)) {\n throw new Error('variant span exceeds span of containing union');\n }\n if ('string' !== typeof property) {\n throw new TypeError('variant must have a String property');\n }\n }\n let span = union.span;\n if (0 > union.span) {\n span = layout ? layout.span : 0;\n if ((0 <= span) && union.usesPrefixDiscriminator) {\n span += union.discriminator.layout.span;\n }\n }\n super(span, property);\n\n /** The {@link Union} to which this variant belongs. */\n this.union = union;\n\n /** The unsigned integral value identifying this variant within\n * the {@link Union#discriminator|discriminator} of the containing\n * union. */\n this.variant = variant;\n\n /** The {@link Layout} to be used when reading/writing the\n * non-discriminator part of the {@link\n * VariantLayout#union|union}. If `null` the variant carries no\n * data. */\n this.layout = layout || null;\n }\n\n /** @override */\n getSpan(b, offset) {\n if (0 <= this.span) {\n /* Will be equal to the containing union span if that is not\n * variable. */\n return this.span;\n }\n if (undefined === offset) {\n offset = 0;\n }\n let contentOffset = 0;\n if (this.union.usesPrefixDiscriminator) {\n contentOffset = this.union.discriminator.layout.span;\n }\n /* Span is defined solely by the variant (and prefix discriminator) */\n return contentOffset + this.layout.getSpan(b, offset + contentOffset);\n }\n\n /** @override */\n decode(b, offset) {\n const dest = this.makeDestinationObject();\n if (undefined === offset) {\n offset = 0;\n }\n if (this !== this.union.getVariant(b, offset)) {\n throw new Error('variant mismatch');\n }\n let contentOffset = 0;\n if (this.union.usesPrefixDiscriminator) {\n contentOffset = this.union.discriminator.layout.span;\n }\n if (this.layout) {\n dest[this.property] = this.layout.decode(b, offset + contentOffset);\n } else if (this.property) {\n dest[this.property] = true;\n } else if (this.union.usesPrefixDiscriminator) {\n dest[this.union.discriminator.property] = this.variant;\n }\n return dest;\n }\n\n /** @override */\n encode(src, b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n let contentOffset = 0;\n if (this.union.usesPrefixDiscriminator) {\n contentOffset = this.union.discriminator.layout.span;\n }\n if (this.layout\n && (!src.hasOwnProperty(this.property))) {\n throw new TypeError('variant lacks property ' + this.property);\n }\n this.union.discriminator.encode(this.variant, b, offset);\n let span = contentOffset;\n if (this.layout) {\n this.layout.encode(src[this.property], b, offset + contentOffset);\n span += this.layout.getSpan(b, offset + contentOffset);\n if ((0 <= this.union.span)\n && (span > this.union.span)) {\n throw new Error('encoded variant overruns containing union');\n }\n }\n return span;\n }\n\n /** Delegate {@link Layout#fromArray|fromArray} to {@link\n * VariantLayout#layout|layout}. */\n fromArray(values) {\n if (this.layout) {\n return this.layout.fromArray(values);\n }\n }\n}\n\n/** JavaScript chose to define bitwise operations as operating on\n * signed 32-bit values in 2's complement form, meaning any integer\n * with bit 31 set is going to look negative. For right shifts that's\n * not a problem, because `>>>` is a logical shift, but for every\n * other bitwise operator we have to compensate for possible negative\n * results. */\nfunction fixBitwiseResult(v) {\n if (0 > v) {\n v += 0x100000000;\n }\n return v;\n}\n\n/**\n * Contain a sequence of bit fields as an unsigned integer.\n *\n * *Factory*: {@link module:Layout.bits|bits}\n *\n * This is a container element; within it there are {@link BitField}\n * instances that provide the extracted properties. The container\n * simply defines the aggregate representation and its bit ordering.\n * The representation is an object containing properties with numeric\n * or {@link Boolean} values.\n *\n * {@link BitField}s are added with the {@link\n * BitStructure#addField|addField} and {@link\n * BitStructure#addBoolean|addBoolean} methods.\n\n * @param {Layout} word - initializer for {@link\n * BitStructure#word|word}. The parameter must be an instance of\n * {@link UInt} (or {@link UIntBE}) that is no more than 4 bytes wide.\n *\n * @param {bool} [msb] - `true` if the bit numbering starts at the\n * most significant bit of the containing word; `false` (default) if\n * it starts at the least significant bit of the containing word. If\n * the parameter at this position is a string and `property` is\n * `undefined` the value of this argument will instead be used as the\n * value of `property`.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass BitStructure extends Layout {\n constructor(word, msb, property) {\n if (!((word instanceof UInt)\n || (word instanceof UIntBE))) {\n throw new TypeError('word must be a UInt or UIntBE layout');\n }\n if (('string' === typeof msb)\n && (undefined === property)) {\n property = msb;\n msb = undefined;\n }\n if (4 < word.span) {\n throw new RangeError('word cannot exceed 32 bits');\n }\n super(word.span, property);\n\n /** The layout used for the packed value. {@link BitField}\n * instances are packed sequentially depending on {@link\n * BitStructure#msb|msb}. */\n this.word = word;\n\n /** Whether the bit sequences are packed starting at the most\n * significant bit growing down (`true`), or the least significant\n * bit growing up (`false`).\n *\n * **NOTE** Regardless of this value, the least significant bit of\n * any {@link BitField} value is the least significant bit of the\n * corresponding section of the packed value. */\n this.msb = !!msb;\n\n /** The sequence of {@link BitField} layouts that comprise the\n * packed structure.\n *\n * **NOTE** The array remains mutable to allow fields to be {@link\n * BitStructure#addField|added} after construction. Users should\n * not manipulate the content of this property.*/\n this.fields = [];\n\n /* Storage for the value. Capture a variable instead of using an\n * instance property because we don't want anything to change the\n * value without going through the mutator. */\n let value = 0;\n this._packedSetValue = function(v) {\n value = fixBitwiseResult(v);\n return this;\n };\n this._packedGetValue = function() {\n return value;\n };\n }\n\n /** @override */\n decode(b, offset) {\n const dest = this.makeDestinationObject();\n if (undefined === offset) {\n offset = 0;\n }\n const value = this.word.decode(b, offset);\n this._packedSetValue(value);\n for (const fd of this.fields) {\n if (undefined !== fd.property) {\n dest[fd.property] = fd.decode(value);\n }\n }\n return dest;\n }\n\n /** Implement {@link Layout#encode|encode} for {@link BitStructure}.\n *\n * If `src` is missing a property for a member with a defined {@link\n * Layout#property|property} the corresponding region of the packed\n * value is left unmodified. Unused bits are also left unmodified. */\n encode(src, b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n const value = this.word.decode(b, offset);\n this._packedSetValue(value);\n for (const fd of this.fields) {\n if (undefined !== fd.property) {\n const fv = src[fd.property];\n if (undefined !== fv) {\n fd.encode(fv);\n }\n }\n }\n return this.word.encode(this._packedGetValue(), b, offset);\n }\n\n /** Register a new bitfield with a containing bit structure. The\n * resulting bitfield is returned.\n *\n * @param {Number} bits - initializer for {@link BitField#bits|bits}.\n *\n * @param {string} property - initializer for {@link\n * Layout#property|property}.\n *\n * @return {BitField} */\n addField(bits, property) {\n const bf = new BitField(this, bits, property);\n this.fields.push(bf);\n return bf;\n }\n\n /** As with {@link BitStructure#addField|addField} for single-bit\n * fields with `boolean` value representation.\n *\n * @param {string} property - initializer for {@link\n * Layout#property|property}.\n *\n * @return {Boolean} */\n addBoolean(property) {\n // This is my Boolean, not the Javascript one.\n // eslint-disable-next-line no-new-wrappers\n const bf = new Boolean(this, property);\n this.fields.push(bf);\n return bf;\n }\n\n /**\n * Get access to the bit field for a given property.\n *\n * @param {String} property - the bit field of interest.\n *\n * @return {BitField} - the field associated with `property`, or\n * undefined if there is no such property.\n */\n fieldFor(property) {\n if ('string' !== typeof property) {\n throw new TypeError('property must be string');\n }\n for (const fd of this.fields) {\n if (fd.property === property) {\n return fd;\n }\n }\n }\n}\n\n/**\n * Represent a sequence of bits within a {@link BitStructure}.\n *\n * All bit field values are represented as unsigned integers.\n *\n * **NOTE** User code should not invoke this constructor directly.\n * Use the container {@link BitStructure#addField|addField} helper\n * method.\n *\n * **NOTE** BitField instances are not instances of {@link Layout}\n * since {@link Layout#span|span} measures 8-bit units.\n *\n * @param {BitStructure} container - initializer for {@link\n * BitField#container|container}.\n *\n * @param {Number} bits - initializer for {@link BitField#bits|bits}.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n */\nclass BitField {\n constructor(container, bits, property) {\n if (!(container instanceof BitStructure)) {\n throw new TypeError('container must be a BitStructure');\n }\n if ((!Number.isInteger(bits)) || (0 >= bits)) {\n throw new TypeError('bits must be positive integer');\n }\n const totalBits = 8 * container.span;\n const usedBits = container.fields.reduce((sum, fd) => sum + fd.bits, 0);\n if ((bits + usedBits) > totalBits) {\n throw new Error('bits too long for span remainder ('\n + (totalBits - usedBits) + ' of '\n + totalBits + ' remain)');\n }\n\n /** The {@link BitStructure} instance to which this bit field\n * belongs. */\n this.container = container;\n\n /** The span of this value in bits. */\n this.bits = bits;\n\n /** A mask of {@link BitField#bits|bits} bits isolating value bits\n * that fit within the field.\n *\n * That is, it masks a value that has not yet been shifted into\n * position within its containing packed integer. */\n this.valueMask = (1 << bits) - 1;\n if (32 === bits) { // shifted value out of range\n this.valueMask = 0xFFFFFFFF;\n }\n\n /** The offset of the value within the containing packed unsigned\n * integer. The least significant bit of the packed value is at\n * offset zero, regardless of bit ordering used. */\n this.start = usedBits;\n if (this.container.msb) {\n this.start = totalBits - usedBits - bits;\n }\n\n /** A mask of {@link BitField#bits|bits} isolating the field value\n * within the containing packed unsigned integer. */\n this.wordMask = fixBitwiseResult(this.valueMask << this.start);\n\n /** The property name used when this bitfield is represented in an\n * Object.\n *\n * Intended to be functionally equivalent to {@link\n * Layout#property}.\n *\n * If left undefined the corresponding span of bits will be\n * treated as padding: it will not be mutated by {@link\n * Layout#encode|encode} nor represented as a property in the\n * decoded Object. */\n this.property = property;\n }\n\n /** Store a value into the corresponding subsequence of the containing\n * bit field. */\n decode() {\n const word = this.container._packedGetValue();\n const wordValue = fixBitwiseResult(word & this.wordMask);\n const value = wordValue >>> this.start;\n return value;\n }\n\n /** Store a value into the corresponding subsequence of the containing\n * bit field.\n *\n * **NOTE** This is not a specialization of {@link\n * Layout#encode|Layout.encode} and there is no return value. */\n encode(value) {\n if ((!Number.isInteger(value))\n || (value !== fixBitwiseResult(value & this.valueMask))) {\n throw new TypeError(nameWithProperty('BitField.encode', this)\n + ' value must be integer not exceeding ' + this.valueMask);\n }\n const word = this.container._packedGetValue();\n const wordValue = fixBitwiseResult(value << this.start);\n this.container._packedSetValue(fixBitwiseResult(word & ~this.wordMask)\n | wordValue);\n };\n}\n\n/**\n * Represent a single bit within a {@link BitStructure} as a\n * JavaScript boolean.\n *\n * **NOTE** User code should not invoke this constructor directly.\n * Use the container {@link BitStructure#addBoolean|addBoolean} helper\n * method.\n *\n * @param {BitStructure} container - initializer for {@link\n * BitField#container|container}.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {BitField}\n */\n/* eslint-disable no-extend-native */\nclass Boolean extends BitField {\n constructor(container, property) {\n super(container, 1, property);\n }\n\n /** Override {@link BitField#decode|decode} for {@link Boolean|Boolean}.\n *\n * @returns {boolean} */\n decode(b, offset) {\n return !!BitField.prototype.decode.call(this, b, offset);\n }\n\n /** @override */\n encode(value) {\n if ('boolean' === typeof value) {\n // BitField requires integer values\n value = +value;\n }\n return BitField.prototype.encode.call(this, value);\n }\n}\n/* eslint-enable no-extend-native */\n\n/**\n * Contain a fixed-length block of arbitrary data, represented as a\n * Buffer.\n *\n * *Factory*: {@link module:Layout.blob|blob}\n *\n * @param {(Number|ExternalLayout)} length - initializes {@link\n * Blob#length|length}.\n *\n * @param {String} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass Blob extends Layout {\n constructor(length, property) {\n if (!(((length instanceof ExternalLayout) && length.isCount())\n || (Number.isInteger(length) && (0 <= length)))) {\n throw new TypeError('length must be positive integer '\n + 'or an unsigned integer ExternalLayout');\n }\n\n let span = -1;\n if (!(length instanceof ExternalLayout)) {\n span = length;\n }\n super(span, property);\n\n /** The number of bytes in the blob.\n *\n * This may be a non-negative integer, or an instance of {@link\n * ExternalLayout} that satisfies {@link\n * ExternalLayout#isCount|isCount()}. */\n this.length = length;\n }\n\n /** @override */\n getSpan(b, offset) {\n let span = this.span;\n if (0 > span) {\n span = this.length.decode(b, offset);\n }\n return span;\n }\n\n /** @override */\n decode(b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n let span = this.span;\n if (0 > span) {\n span = this.length.decode(b, offset);\n }\n return b.slice(offset, offset + span);\n }\n\n /** Implement {@link Layout#encode|encode} for {@link Blob}.\n *\n * **NOTE** If {@link Layout#count|count} is an instance of {@link\n * ExternalLayout} then the length of `src` will be encoded as the\n * count after `src` is encoded. */\n encode(src, b, offset) {\n let span = this.length;\n if (this.length instanceof ExternalLayout) {\n span = src.length;\n }\n if (!(Buffer.isBuffer(src)\n && (span === src.length))) {\n throw new TypeError(nameWithProperty('Blob.encode', this)\n + ' requires (length ' + span + ') Buffer as src');\n }\n if ((offset + span) > b.length) {\n throw new RangeError('encoding overruns Buffer');\n }\n b.write(src.toString('hex'), offset, span, 'hex');\n if (this.length instanceof ExternalLayout) {\n this.length.encode(span, b, offset);\n }\n return span;\n }\n}\n\n/**\n * Contain a `NUL`-terminated UTF8 string.\n *\n * *Factory*: {@link module:Layout.cstr|cstr}\n *\n * **NOTE** Any UTF8 string that incorporates a zero-valued byte will\n * not be correctly decoded by this layout.\n *\n * @param {String} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass CString extends Layout {\n constructor(property) {\n super(-1, property);\n }\n\n /** @override */\n getSpan(b, offset) {\n if (!Buffer.isBuffer(b)) {\n throw new TypeError('b must be a Buffer');\n }\n if (undefined === offset) {\n offset = 0;\n }\n let idx = offset;\n while ((idx < b.length) && (0 !== b[idx])) {\n idx += 1;\n }\n return 1 + idx - offset;\n }\n\n /** @override */\n decode(b, offset, dest) {\n if (undefined === offset) {\n offset = 0;\n }\n let span = this.getSpan(b, offset);\n return b.slice(offset, offset + span - 1).toString('utf-8');\n }\n\n /** @override */\n encode(src, b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n /* Must force this to a string, lest it be a number and the\n * \"utf8-encoding\" below actually allocate a buffer of length\n * src */\n if ('string' !== typeof src) {\n src = src.toString();\n }\n const srcb = new Buffer(src, 'utf8');\n const span = srcb.length;\n if ((offset + span) > b.length) {\n throw new RangeError('encoding overruns Buffer');\n }\n srcb.copy(b, offset);\n b[offset + span] = 0;\n return span + 1;\n }\n}\n\n/**\n * Contain a UTF8 string with implicit length.\n *\n * *Factory*: {@link module:Layout.utf8|utf8}\n *\n * **NOTE** Because the length is implicit in the size of the buffer\n * this layout should be used only in isolation, or in a situation\n * where the length can be expressed by operating on a slice of the\n * containing buffer.\n *\n * @param {Number} [maxSpan] - the maximum length allowed for encoded\n * string content. If not provided there is no bound on the allowed\n * content.\n *\n * @param {String} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass UTF8 extends Layout {\n constructor(maxSpan, property) {\n if (('string' === typeof maxSpan)\n && (undefined === property)) {\n property = maxSpan;\n maxSpan = undefined;\n }\n if (undefined === maxSpan) {\n maxSpan = -1;\n } else if (!Number.isInteger(maxSpan)) {\n throw new TypeError('maxSpan must be an integer');\n }\n\n super(-1, property);\n\n /** The maximum span of the layout in bytes.\n *\n * Positive values are generally expected. Zero is abnormal.\n * Attempts to encode or decode a value that exceeds this length\n * will throw a `RangeError`.\n *\n * A negative value indicates that there is no bound on the length\n * of the content. */\n this.maxSpan = maxSpan;\n }\n\n /** @override */\n getSpan(b, offset) {\n if (!Buffer.isBuffer(b)) {\n throw new TypeError('b must be a Buffer');\n }\n if (undefined === offset) {\n offset = 0;\n }\n return b.length - offset;\n }\n\n /** @override */\n decode(b, offset, dest) {\n if (undefined === offset) {\n offset = 0;\n }\n let span = this.getSpan(b, offset);\n if ((0 <= this.maxSpan)\n && (this.maxSpan < span)) {\n throw new RangeError('text length exceeds maxSpan');\n }\n return b.slice(offset, offset + span).toString('utf-8');\n }\n\n /** @override */\n encode(src, b, offset) {\n if (undefined === offset) {\n offset = 0;\n }\n /* Must force this to a string, lest it be a number and the\n * \"utf8-encoding\" below actually allocate a buffer of length\n * src */\n if ('string' !== typeof src) {\n src = src.toString();\n }\n const srcb = new Buffer(src, 'utf8');\n const span = srcb.length;\n if ((0 <= this.maxSpan)\n && (this.maxSpan < span)) {\n throw new RangeError('text length exceeds maxSpan');\n }\n if ((offset + span) > b.length) {\n throw new RangeError('encoding overruns Buffer');\n }\n srcb.copy(b, offset);\n return span;\n }\n}\n\n/**\n * Contain a constant value.\n *\n * This layout may be used in cases where a JavaScript value can be\n * inferred without an expression in the binary encoding. An example\n * would be a {@link VariantLayout|variant layout} where the content\n * is implied by the union {@link Union#discriminator|discriminator}.\n *\n * @param {Object|Number|String} value - initializer for {@link\n * Constant#value|value}. If the value is an object (or array) and\n * the application intends the object to remain unchanged regardless\n * of what is done to values decoded by this layout, the value should\n * be frozen prior passing it to this constructor.\n *\n * @param {String} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass Constant extends Layout {\n constructor(value, property) {\n super(0, property);\n\n /** The value produced by this constant when the layout is {@link\n * Constant#decode|decoded}.\n *\n * Any JavaScript value including `null` and `undefined` is\n * permitted.\n *\n * **WARNING** If `value` passed in the constructor was not\n * frozen, it is possible for users of decoded values to change\n * the content of the value. */\n this.value = value;\n }\n\n /** @override */\n decode(b, offset, dest) {\n return this.value;\n }\n\n /** @override */\n encode(src, b, offset) {\n /* Constants take no space */\n return 0;\n }\n}\n\nexports.ExternalLayout = ExternalLayout;\nexports.GreedyCount = GreedyCount;\nexports.OffsetLayout = OffsetLayout;\nexports.UInt = UInt;\nexports.UIntBE = UIntBE;\nexports.Int = Int;\nexports.IntBE = IntBE;\nexports.Float = Float;\nexports.FloatBE = FloatBE;\nexports.Double = Double;\nexports.DoubleBE = DoubleBE;\nexports.Sequence = Sequence;\nexports.Structure = Structure;\nexports.UnionDiscriminator = UnionDiscriminator;\nexports.UnionLayoutDiscriminator = UnionLayoutDiscriminator;\nexports.Union = Union;\nexports.VariantLayout = VariantLayout;\nexports.BitStructure = BitStructure;\nexports.BitField = BitField;\nexports.Boolean = Boolean;\nexports.Blob = Blob;\nexports.CString = CString;\nexports.UTF8 = UTF8;\nexports.Constant = Constant;\n\n/** Factory for {@link GreedyCount}. */\nexports.greedy = ((elementSpan, property) => new GreedyCount(elementSpan, property));\n\n/** Factory for {@link OffsetLayout}. */\nexports.offset = ((layout, offset, property) => new OffsetLayout(layout, offset, property));\n\n/** Factory for {@link UInt|unsigned int layouts} spanning one\n * byte. */\nexports.u8 = (property => new UInt(1, property));\n\n/** Factory for {@link UInt|little-endian unsigned int layouts}\n * spanning two bytes. */\nexports.u16 = (property => new UInt(2, property));\n\n/** Factory for {@link UInt|little-endian unsigned int layouts}\n * spanning three bytes. */\nexports.u24 = (property => new UInt(3, property));\n\n/** Factory for {@link UInt|little-endian unsigned int layouts}\n * spanning four bytes. */\nexports.u32 = (property => new UInt(4, property));\n\n/** Factory for {@link UInt|little-endian unsigned int layouts}\n * spanning five bytes. */\nexports.u40 = (property => new UInt(5, property));\n\n/** Factory for {@link UInt|little-endian unsigned int layouts}\n * spanning six bytes. */\nexports.u48 = (property => new UInt(6, property));\n\n/** Factory for {@link NearUInt64|little-endian unsigned int\n * layouts} interpreted as Numbers. */\nexports.nu64 = (property => new NearUInt64(property));\n\n/** Factory for {@link UInt|big-endian unsigned int layouts}\n * spanning two bytes. */\nexports.u16be = (property => new UIntBE(2, property));\n\n/** Factory for {@link UInt|big-endian unsigned int layouts}\n * spanning three bytes. */\nexports.u24be = (property => new UIntBE(3, property));\n\n/** Factory for {@link UInt|big-endian unsigned int layouts}\n * spanning four bytes. */\nexports.u32be = (property => new UIntBE(4, property));\n\n/** Factory for {@link UInt|big-endian unsigned int layouts}\n * spanning five bytes. */\nexports.u40be = (property => new UIntBE(5, property));\n\n/** Factory for {@link UInt|big-endian unsigned int layouts}\n * spanning six bytes. */\nexports.u48be = (property => new UIntBE(6, property));\n\n/** Factory for {@link NearUInt64BE|big-endian unsigned int\n * layouts} interpreted as Numbers. */\nexports.nu64be = (property => new NearUInt64BE(property));\n\n/** Factory for {@link Int|signed int layouts} spanning one\n * byte. */\nexports.s8 = (property => new Int(1, property));\n\n/** Factory for {@link Int|little-endian signed int layouts}\n * spanning two bytes. */\nexports.s16 = (property => new Int(2, property));\n\n/** Factory for {@link Int|little-endian signed int layouts}\n * spanning three bytes. */\nexports.s24 = (property => new Int(3, property));\n\n/** Factory for {@link Int|little-endian signed int layouts}\n * spanning four bytes. */\nexports.s32 = (property => new Int(4, property));\n\n/** Factory for {@link Int|little-endian signed int layouts}\n * spanning five bytes. */\nexports.s40 = (property => new Int(5, property));\n\n/** Factory for {@link Int|little-endian signed int layouts}\n * spanning six bytes. */\nexports.s48 = (property => new Int(6, property));\n\n/** Factory for {@link NearInt64|little-endian signed int layouts}\n * interpreted as Numbers. */\nexports.ns64 = (property => new NearInt64(property));\n\n/** Factory for {@link Int|big-endian signed int layouts}\n * spanning two bytes. */\nexports.s16be = (property => new IntBE(2, property));\n\n/** Factory for {@link Int|big-endian signed int layouts}\n * spanning three bytes. */\nexports.s24be = (property => new IntBE(3, property));\n\n/** Factory for {@link Int|big-endian signed int layouts}\n * spanning four bytes. */\nexports.s32be = (property => new IntBE(4, property));\n\n/** Factory for {@link Int|big-endian signed int layouts}\n * spanning five bytes. */\nexports.s40be = (property => new IntBE(5, property));\n\n/** Factory for {@link Int|big-endian signed int layouts}\n * spanning six bytes. */\nexports.s48be = (property => new IntBE(6, property));\n\n/** Factory for {@link NearInt64BE|big-endian signed int layouts}\n * interpreted as Numbers. */\nexports.ns64be = (property => new NearInt64BE(property));\n\n/** Factory for {@link Float|little-endian 32-bit floating point} values. */\nexports.f32 = (property => new Float(property));\n\n/** Factory for {@link FloatBE|big-endian 32-bit floating point} values. */\nexports.f32be = (property => new FloatBE(property));\n\n/** Factory for {@link Double|little-endian 64-bit floating point} values. */\nexports.f64 = (property => new Double(property));\n\n/** Factory for {@link DoubleBE|big-endian 64-bit floating point} values. */\nexports.f64be = (property => new DoubleBE(property));\n\n/** Factory for {@link Structure} values. */\nexports.struct = ((fields, property, decodePrefixes) => new Structure(fields, property, decodePrefixes));\n\n/** Factory for {@link BitStructure} values. */\nexports.bits = ((word, msb, property) => new BitStructure(word, msb, property));\n\n/** Factory for {@link Sequence} values. */\nexports.seq = ((elementLayout, count, property) => new Sequence(elementLayout, count, property));\n\n/** Factory for {@link Union} values. */\nexports.union = ((discr, defaultLayout, property) => new Union(discr, defaultLayout, property));\n\n/** Factory for {@link UnionLayoutDiscriminator} values. */\nexports.unionLayoutDiscriminator = ((layout, property) => new UnionLayoutDiscriminator(layout, property));\n\n/** Factory for {@link Blob} values. */\nexports.blob = ((length, property) => new Blob(length, property));\n\n/** Factory for {@link CString} values. */\nexports.cstr = (property => new CString(property));\n\n/** Factory for {@link UTF8} values. */\nexports.utf8 = ((maxSpan, property) => new UTF8(maxSpan, property));\n\n/** Factory for {@link Constant} values. */\nexports.const = ((value, property) => new Constant(value, property));\n","(function (module, exports) {\n 'use strict';\n\n // Utils\n function assert (val, msg) {\n if (!val) throw new Error(msg || 'Assertion failed');\n }\n\n // Could use `inherits` module, but don't want to move from single file\n // architecture yet.\n function inherits (ctor, superCtor) {\n ctor.super_ = superCtor;\n var TempCtor = function () {};\n TempCtor.prototype = superCtor.prototype;\n ctor.prototype = new TempCtor();\n ctor.prototype.constructor = ctor;\n }\n\n // BN\n\n function BN (number, base, endian) {\n if (BN.isBN(number)) {\n return number;\n }\n\n this.negative = 0;\n this.words = null;\n this.length = 0;\n\n // Reduction context\n this.red = null;\n\n if (number !== null) {\n if (base === 'le' || base === 'be') {\n endian = base;\n base = 10;\n }\n\n this._init(number || 0, base || 10, endian || 'be');\n }\n }\n if (typeof module === 'object') {\n module.exports = BN;\n } else {\n exports.BN = BN;\n }\n\n BN.BN = BN;\n BN.wordSize = 26;\n\n var Buffer;\n try {\n if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') {\n Buffer = window.Buffer;\n } else {\n Buffer = require('buffer').Buffer;\n }\n } catch (e) {\n }\n\n BN.isBN = function isBN (num) {\n if (num instanceof BN) {\n return true;\n }\n\n return num !== null && typeof num === 'object' &&\n num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);\n };\n\n BN.max = function max (left, right) {\n if (left.cmp(right) > 0) return left;\n return right;\n };\n\n BN.min = function min (left, right) {\n if (left.cmp(right) < 0) return left;\n return right;\n };\n\n BN.prototype._init = function init (number, base, endian) {\n if (typeof number === 'number') {\n return this._initNumber(number, base, endian);\n }\n\n if (typeof number === 'object') {\n return this._initArray(number, base, endian);\n }\n\n if (base === 'hex') {\n base = 16;\n }\n assert(base === (base | 0) && base >= 2 && base <= 36);\n\n number = number.toString().replace(/\\s+/g, '');\n var start = 0;\n if (number[0] === '-') {\n start++;\n this.negative = 1;\n }\n\n if (start < number.length) {\n if (base === 16) {\n this._parseHex(number, start, endian);\n } else {\n\n this._parseBase(number, base, start);\n if (endian === 'le') {\n this._initArray(this.toArray(), base, endian);\n }\n }\n }\n };\n\n BN.prototype._initNumber = function _initNumber (number, base, endian) {\n if (number < 0) {\n this.negative = 1;\n number = -number;\n }\n if (number < 0x4000000) {\n this.words = [number & 0x3ffffff];\n this.length = 1;\n } else if (number < 0x10000000000000) {\n this.words = [\n number & 0x3ffffff,\n (number / 0x4000000) & 0x3ffffff\n ];\n this.length = 2;\n } else {\n assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)\n this.words = [\n number & 0x3ffffff,\n (number / 0x4000000) & 0x3ffffff,\n 1\n ];\n this.length = 3;\n }\n\n if (endian !== 'le') return;\n\n // Reverse the bytes\n this._initArray(this.toArray(), base, endian);\n };\n\n BN.prototype._initArray = function _initArray (number, base, endian) {\n // Perhaps a Uint8Array\n assert(typeof number.length === 'number');\n if (number.length <= 0) {\n this.words = [0];\n this.length = 1;\n return this;\n }\n\n this.length = Math.ceil(number.length / 3);\n this.words = new Array(this.length);\n for (var i = 0; i < this.length; i++) {\n this.words[i] = 0;\n }\n\n var j, w;\n var off = 0;\n if (endian === 'be') {\n for (i = number.length - 1, j = 0; i >= 0; i -= 3) {\n w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);\n this.words[j] |= (w << off) & 0x3ffffff;\n this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;\n off += 24;\n if (off >= 26) {\n off -= 26;\n j++;\n }\n }\n } else if (endian === 'le') {\n for (i = 0, j = 0; i < number.length; i += 3) {\n w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);\n this.words[j] |= (w << off) & 0x3ffffff;\n this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;\n off += 24;\n if (off >= 26) {\n off -= 26;\n j++;\n }\n }\n }\n return this._strip();\n };\n\n function parseHex4Bits (string, index) {\n var c = string.charCodeAt(index);\n // '0' - '9'\n if (c >= 48 && c <= 57) {\n return c - 48;\n // 'A' - 'F'\n } else if (c >= 65 && c <= 70) {\n return c - 55;\n // 'a' - 'f'\n } else if (c >= 97 && c <= 102) {\n return c - 87;\n } else {\n assert(false, 'Invalid character in ' + string);\n }\n }\n\n function parseHexByte (string, lowerBound, index) {\n var r = parseHex4Bits(string, index);\n if (index - 1 >= lowerBound) {\n r |= parseHex4Bits(string, index - 1) << 4;\n }\n return r;\n }\n\n BN.prototype._parseHex = function _parseHex (number, start, endian) {\n // Create possibly bigger array to ensure that it fits the number\n this.length = Math.ceil((number.length - start) / 6);\n this.words = new Array(this.length);\n for (var i = 0; i < this.length; i++) {\n this.words[i] = 0;\n }\n\n // 24-bits chunks\n var off = 0;\n var j = 0;\n\n var w;\n if (endian === 'be') {\n for (i = number.length - 1; i >= start; i -= 2) {\n w = parseHexByte(number, start, i) << off;\n this.words[j] |= w & 0x3ffffff;\n if (off >= 18) {\n off -= 18;\n j += 1;\n this.words[j] |= w >>> 26;\n } else {\n off += 8;\n }\n }\n } else {\n var parseLength = number.length - start;\n for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) {\n w = parseHexByte(number, start, i) << off;\n this.words[j] |= w & 0x3ffffff;\n if (off >= 18) {\n off -= 18;\n j += 1;\n this.words[j] |= w >>> 26;\n } else {\n off += 8;\n }\n }\n }\n\n this._strip();\n };\n\n function parseBase (str, start, end, mul) {\n var r = 0;\n var b = 0;\n var len = Math.min(str.length, end);\n for (var i = start; i < len; i++) {\n var c = str.charCodeAt(i) - 48;\n\n r *= mul;\n\n // 'a'\n if (c >= 49) {\n b = c - 49 + 0xa;\n\n // 'A'\n } else if (c >= 17) {\n b = c - 17 + 0xa;\n\n // '0' - '9'\n } else {\n b = c;\n }\n assert(c >= 0 && b < mul, 'Invalid character');\n r += b;\n }\n return r;\n }\n\n BN.prototype._parseBase = function _parseBase (number, base, start) {\n // Initialize as zero\n this.words = [0];\n this.length = 1;\n\n // Find length of limb in base\n for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {\n limbLen++;\n }\n limbLen--;\n limbPow = (limbPow / base) | 0;\n\n var total = number.length - start;\n var mod = total % limbLen;\n var end = Math.min(total, total - mod) + start;\n\n var word = 0;\n for (var i = start; i < end; i += limbLen) {\n word = parseBase(number, i, i + limbLen, base);\n\n this.imuln(limbPow);\n if (this.words[0] + word < 0x4000000) {\n this.words[0] += word;\n } else {\n this._iaddn(word);\n }\n }\n\n if (mod !== 0) {\n var pow = 1;\n word = parseBase(number, i, number.length, base);\n\n for (i = 0; i < mod; i++) {\n pow *= base;\n }\n\n this.imuln(pow);\n if (this.words[0] + word < 0x4000000) {\n this.words[0] += word;\n } else {\n this._iaddn(word);\n }\n }\n\n this._strip();\n };\n\n BN.prototype.copy = function copy (dest) {\n dest.words = new Array(this.length);\n for (var i = 0; i < this.length; i++) {\n dest.words[i] = this.words[i];\n }\n dest.length = this.length;\n dest.negative = this.negative;\n dest.red = this.red;\n };\n\n function move (dest, src) {\n dest.words = src.words;\n dest.length = src.length;\n dest.negative = src.negative;\n dest.red = src.red;\n }\n\n BN.prototype._move = function _move (dest) {\n move(dest, this);\n };\n\n BN.prototype.clone = function clone () {\n var r = new BN(null);\n this.copy(r);\n return r;\n };\n\n BN.prototype._expand = function _expand (size) {\n while (this.length < size) {\n this.words[this.length++] = 0;\n }\n return this;\n };\n\n // Remove leading `0` from `this`\n BN.prototype._strip = function strip () {\n while (this.length > 1 && this.words[this.length - 1] === 0) {\n this.length--;\n }\n return this._normSign();\n };\n\n BN.prototype._normSign = function _normSign () {\n // -0 = 0\n if (this.length === 1 && this.words[0] === 0) {\n this.negative = 0;\n }\n return this;\n };\n\n // Check Symbol.for because not everywhere where Symbol defined\n // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Browser_compatibility\n if (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') {\n try {\n BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect;\n } catch (e) {\n BN.prototype.inspect = inspect;\n }\n } else {\n BN.prototype.inspect = inspect;\n }\n\n function inspect () {\n return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';\n }\n\n /*\n\n var zeros = [];\n var groupSizes = [];\n var groupBases = [];\n\n var s = '';\n var i = -1;\n while (++i < BN.wordSize) {\n zeros[i] = s;\n s += '0';\n }\n groupSizes[0] = 0;\n groupSizes[1] = 0;\n groupBases[0] = 0;\n groupBases[1] = 0;\n var base = 2 - 1;\n while (++base < 36 + 1) {\n var groupSize = 0;\n var groupBase = 1;\n while (groupBase < (1 << BN.wordSize) / base) {\n groupBase *= base;\n groupSize += 1;\n }\n groupSizes[base] = groupSize;\n groupBases[base] = groupBase;\n }\n\n */\n\n var zeros = [\n '',\n '0',\n '00',\n '000',\n '0000',\n '00000',\n '000000',\n '0000000',\n '00000000',\n '000000000',\n '0000000000',\n '00000000000',\n '000000000000',\n '0000000000000',\n '00000000000000',\n '000000000000000',\n '0000000000000000',\n '00000000000000000',\n '000000000000000000',\n '0000000000000000000',\n '00000000000000000000',\n '000000000000000000000',\n '0000000000000000000000',\n '00000000000000000000000',\n '000000000000000000000000',\n '0000000000000000000000000'\n ];\n\n var groupSizes = [\n 0, 0,\n 25, 16, 12, 11, 10, 9, 8,\n 8, 7, 7, 7, 7, 6, 6,\n 6, 6, 6, 6, 6, 5, 5,\n 5, 5, 5, 5, 5, 5, 5,\n 5, 5, 5, 5, 5, 5, 5\n ];\n\n var groupBases = [\n 0, 0,\n 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,\n 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,\n 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,\n 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,\n 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176\n ];\n\n BN.prototype.toString = function toString (base, padding) {\n base = base || 10;\n padding = padding | 0 || 1;\n\n var out;\n if (base === 16 || base === 'hex') {\n out = '';\n var off = 0;\n var carry = 0;\n for (var i = 0; i < this.length; i++) {\n var w = this.words[i];\n var word = (((w << off) | carry) & 0xffffff).toString(16);\n carry = (w >>> (24 - off)) & 0xffffff;\n off += 2;\n if (off >= 26) {\n off -= 26;\n i--;\n }\n if (carry !== 0 || i !== this.length - 1) {\n out = zeros[6 - word.length] + word + out;\n } else {\n out = word + out;\n }\n }\n if (carry !== 0) {\n out = carry.toString(16) + out;\n }\n while (out.length % padding !== 0) {\n out = '0' + out;\n }\n if (this.negative !== 0) {\n out = '-' + out;\n }\n return out;\n }\n\n if (base === (base | 0) && base >= 2 && base <= 36) {\n // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));\n var groupSize = groupSizes[base];\n // var groupBase = Math.pow(base, groupSize);\n var groupBase = groupBases[base];\n out = '';\n var c = this.clone();\n c.negative = 0;\n while (!c.isZero()) {\n var r = c.modrn(groupBase).toString(base);\n c = c.idivn(groupBase);\n\n if (!c.isZero()) {\n out = zeros[groupSize - r.length] + r + out;\n } else {\n out = r + out;\n }\n }\n if (this.isZero()) {\n out = '0' + out;\n }\n while (out.length % padding !== 0) {\n out = '0' + out;\n }\n if (this.negative !== 0) {\n out = '-' + out;\n }\n return out;\n }\n\n assert(false, 'Base should be between 2 and 36');\n };\n\n BN.prototype.toNumber = function toNumber () {\n var ret = this.words[0];\n if (this.length === 2) {\n ret += this.words[1] * 0x4000000;\n } else if (this.length === 3 && this.words[2] === 0x01) {\n // NOTE: at this stage it is known that the top bit is set\n ret += 0x10000000000000 + (this.words[1] * 0x4000000);\n } else if (this.length > 2) {\n assert(false, 'Number can only safely store up to 53 bits');\n }\n return (this.negative !== 0) ? -ret : ret;\n };\n\n BN.prototype.toJSON = function toJSON () {\n return this.toString(16, 2);\n };\n\n if (Buffer) {\n BN.prototype.toBuffer = function toBuffer (endian, length) {\n return this.toArrayLike(Buffer, endian, length);\n };\n }\n\n BN.prototype.toArray = function toArray (endian, length) {\n return this.toArrayLike(Array, endian, length);\n };\n\n var allocate = function allocate (ArrayType, size) {\n if (ArrayType.allocUnsafe) {\n return ArrayType.allocUnsafe(size);\n }\n return new ArrayType(size);\n };\n\n BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {\n this._strip();\n\n var byteLength = this.byteLength();\n var reqLength = length || Math.max(1, byteLength);\n assert(byteLength <= reqLength, 'byte array longer than desired length');\n assert(reqLength > 0, 'Requested array length <= 0');\n\n var res = allocate(ArrayType, reqLength);\n var postfix = endian === 'le' ? 'LE' : 'BE';\n this['_toArrayLike' + postfix](res, byteLength);\n return res;\n };\n\n BN.prototype._toArrayLikeLE = function _toArrayLikeLE (res, byteLength) {\n var position = 0;\n var carry = 0;\n\n for (var i = 0, shift = 0; i < this.length; i++) {\n var word = (this.words[i] << shift) | carry;\n\n res[position++] = word & 0xff;\n if (position < res.length) {\n res[position++] = (word >> 8) & 0xff;\n }\n if (position < res.length) {\n res[position++] = (word >> 16) & 0xff;\n }\n\n if (shift === 6) {\n if (position < res.length) {\n res[position++] = (word >> 24) & 0xff;\n }\n carry = 0;\n shift = 0;\n } else {\n carry = word >>> 24;\n shift += 2;\n }\n }\n\n if (position < res.length) {\n res[position++] = carry;\n\n while (position < res.length) {\n res[position++] = 0;\n }\n }\n };\n\n BN.prototype._toArrayLikeBE = function _toArrayLikeBE (res, byteLength) {\n var position = res.length - 1;\n var carry = 0;\n\n for (var i = 0, shift = 0; i < this.length; i++) {\n var word = (this.words[i] << shift) | carry;\n\n res[position--] = word & 0xff;\n if (position >= 0) {\n res[position--] = (word >> 8) & 0xff;\n }\n if (position >= 0) {\n res[position--] = (word >> 16) & 0xff;\n }\n\n if (shift === 6) {\n if (position >= 0) {\n res[position--] = (word >> 24) & 0xff;\n }\n carry = 0;\n shift = 0;\n } else {\n carry = word >>> 24;\n shift += 2;\n }\n }\n\n if (position >= 0) {\n res[position--] = carry;\n\n while (position >= 0) {\n res[position--] = 0;\n }\n }\n };\n\n if (Math.clz32) {\n BN.prototype._countBits = function _countBits (w) {\n return 32 - Math.clz32(w);\n };\n } else {\n BN.prototype._countBits = function _countBits (w) {\n var t = w;\n var r = 0;\n if (t >= 0x1000) {\n r += 13;\n t >>>= 13;\n }\n if (t >= 0x40) {\n r += 7;\n t >>>= 7;\n }\n if (t >= 0x8) {\n r += 4;\n t >>>= 4;\n }\n if (t >= 0x02) {\n r += 2;\n t >>>= 2;\n }\n return r + t;\n };\n }\n\n BN.prototype._zeroBits = function _zeroBits (w) {\n // Short-cut\n if (w === 0) return 26;\n\n var t = w;\n var r = 0;\n if ((t & 0x1fff) === 0) {\n r += 13;\n t >>>= 13;\n }\n if ((t & 0x7f) === 0) {\n r += 7;\n t >>>= 7;\n }\n if ((t & 0xf) === 0) {\n r += 4;\n t >>>= 4;\n }\n if ((t & 0x3) === 0) {\n r += 2;\n t >>>= 2;\n }\n if ((t & 0x1) === 0) {\n r++;\n }\n return r;\n };\n\n // Return number of used bits in a BN\n BN.prototype.bitLength = function bitLength () {\n var w = this.words[this.length - 1];\n var hi = this._countBits(w);\n return (this.length - 1) * 26 + hi;\n };\n\n function toBitArray (num) {\n var w = new Array(num.bitLength());\n\n for (var bit = 0; bit < w.length; bit++) {\n var off = (bit / 26) | 0;\n var wbit = bit % 26;\n\n w[bit] = (num.words[off] >>> wbit) & 0x01;\n }\n\n return w;\n }\n\n // Number of trailing zero bits\n BN.prototype.zeroBits = function zeroBits () {\n if (this.isZero()) return 0;\n\n var r = 0;\n for (var i = 0; i < this.length; i++) {\n var b = this._zeroBits(this.words[i]);\n r += b;\n if (b !== 26) break;\n }\n return r;\n };\n\n BN.prototype.byteLength = function byteLength () {\n return Math.ceil(this.bitLength() / 8);\n };\n\n BN.prototype.toTwos = function toTwos (width) {\n if (this.negative !== 0) {\n return this.abs().inotn(width).iaddn(1);\n }\n return this.clone();\n };\n\n BN.prototype.fromTwos = function fromTwos (width) {\n if (this.testn(width - 1)) {\n return this.notn(width).iaddn(1).ineg();\n }\n return this.clone();\n };\n\n BN.prototype.isNeg = function isNeg () {\n return this.negative !== 0;\n };\n\n // Return negative clone of `this`\n BN.prototype.neg = function neg () {\n return this.clone().ineg();\n };\n\n BN.prototype.ineg = function ineg () {\n if (!this.isZero()) {\n this.negative ^= 1;\n }\n\n return this;\n };\n\n // Or `num` with `this` in-place\n BN.prototype.iuor = function iuor (num) {\n while (this.length < num.length) {\n this.words[this.length++] = 0;\n }\n\n for (var i = 0; i < num.length; i++) {\n this.words[i] = this.words[i] | num.words[i];\n }\n\n return this._strip();\n };\n\n BN.prototype.ior = function ior (num) {\n assert((this.negative | num.negative) === 0);\n return this.iuor(num);\n };\n\n // Or `num` with `this`\n BN.prototype.or = function or (num) {\n if (this.length > num.length) return this.clone().ior(num);\n return num.clone().ior(this);\n };\n\n BN.prototype.uor = function uor (num) {\n if (this.length > num.length) return this.clone().iuor(num);\n return num.clone().iuor(this);\n };\n\n // And `num` with `this` in-place\n BN.prototype.iuand = function iuand (num) {\n // b = min-length(num, this)\n var b;\n if (this.length > num.length) {\n b = num;\n } else {\n b = this;\n }\n\n for (var i = 0; i < b.length; i++) {\n this.words[i] = this.words[i] & num.words[i];\n }\n\n this.length = b.length;\n\n return this._strip();\n };\n\n BN.prototype.iand = function iand (num) {\n assert((this.negative | num.negative) === 0);\n return this.iuand(num);\n };\n\n // And `num` with `this`\n BN.prototype.and = function and (num) {\n if (this.length > num.length) return this.clone().iand(num);\n return num.clone().iand(this);\n };\n\n BN.prototype.uand = function uand (num) {\n if (this.length > num.length) return this.clone().iuand(num);\n return num.clone().iuand(this);\n };\n\n // Xor `num` with `this` in-place\n BN.prototype.iuxor = function iuxor (num) {\n // a.length > b.length\n var a;\n var b;\n if (this.length > num.length) {\n a = this;\n b = num;\n } else {\n a = num;\n b = this;\n }\n\n for (var i = 0; i < b.length; i++) {\n this.words[i] = a.words[i] ^ b.words[i];\n }\n\n if (this !== a) {\n for (; i < a.length; i++) {\n this.words[i] = a.words[i];\n }\n }\n\n this.length = a.length;\n\n return this._strip();\n };\n\n BN.prototype.ixor = function ixor (num) {\n assert((this.negative | num.negative) === 0);\n return this.iuxor(num);\n };\n\n // Xor `num` with `this`\n BN.prototype.xor = function xor (num) {\n if (this.length > num.length) return this.clone().ixor(num);\n return num.clone().ixor(this);\n };\n\n BN.prototype.uxor = function uxor (num) {\n if (this.length > num.length) return this.clone().iuxor(num);\n return num.clone().iuxor(this);\n };\n\n // Not ``this`` with ``width`` bitwidth\n BN.prototype.inotn = function inotn (width) {\n assert(typeof width === 'number' && width >= 0);\n\n var bytesNeeded = Math.ceil(width / 26) | 0;\n var bitsLeft = width % 26;\n\n // Extend the buffer with leading zeroes\n this._expand(bytesNeeded);\n\n if (bitsLeft > 0) {\n bytesNeeded--;\n }\n\n // Handle complete words\n for (var i = 0; i < bytesNeeded; i++) {\n this.words[i] = ~this.words[i] & 0x3ffffff;\n }\n\n // Handle the residue\n if (bitsLeft > 0) {\n this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));\n }\n\n // And remove leading zeroes\n return this._strip();\n };\n\n BN.prototype.notn = function notn (width) {\n return this.clone().inotn(width);\n };\n\n // Set `bit` of `this`\n BN.prototype.setn = function setn (bit, val) {\n assert(typeof bit === 'number' && bit >= 0);\n\n var off = (bit / 26) | 0;\n var wbit = bit % 26;\n\n this._expand(off + 1);\n\n if (val) {\n this.words[off] = this.words[off] | (1 << wbit);\n } else {\n this.words[off] = this.words[off] & ~(1 << wbit);\n }\n\n return this._strip();\n };\n\n // Add `num` to `this` in-place\n BN.prototype.iadd = function iadd (num) {\n var r;\n\n // negative + positive\n if (this.negative !== 0 && num.negative === 0) {\n this.negative = 0;\n r = this.isub(num);\n this.negative ^= 1;\n return this._normSign();\n\n // positive + negative\n } else if (this.negative === 0 && num.negative !== 0) {\n num.negative = 0;\n r = this.isub(num);\n num.negative = 1;\n return r._normSign();\n }\n\n // a.length > b.length\n var a, b;\n if (this.length > num.length) {\n a = this;\n b = num;\n } else {\n a = num;\n b = this;\n }\n\n var carry = 0;\n for (var i = 0; i < b.length; i++) {\n r = (a.words[i] | 0) + (b.words[i] | 0) + carry;\n this.words[i] = r & 0x3ffffff;\n carry = r >>> 26;\n }\n for (; carry !== 0 && i < a.length; i++) {\n r = (a.words[i] | 0) + carry;\n this.words[i] = r & 0x3ffffff;\n carry = r >>> 26;\n }\n\n this.length = a.length;\n if (carry !== 0) {\n this.words[this.length] = carry;\n this.length++;\n // Copy the rest of the words\n } else if (a !== this) {\n for (; i < a.length; i++) {\n this.words[i] = a.words[i];\n }\n }\n\n return this;\n };\n\n // Add `num` to `this`\n BN.prototype.add = function add (num) {\n var res;\n if (num.negative !== 0 && this.negative === 0) {\n num.negative = 0;\n res = this.sub(num);\n num.negative ^= 1;\n return res;\n } else if (num.negative === 0 && this.negative !== 0) {\n this.negative = 0;\n res = num.sub(this);\n this.negative = 1;\n return res;\n }\n\n if (this.length > num.length) return this.clone().iadd(num);\n\n return num.clone().iadd(this);\n };\n\n // Subtract `num` from `this` in-place\n BN.prototype.isub = function isub (num) {\n // this - (-num) = this + num\n if (num.negative !== 0) {\n num.negative = 0;\n var r = this.iadd(num);\n num.negative = 1;\n return r._normSign();\n\n // -this - num = -(this + num)\n } else if (this.negative !== 0) {\n this.negative = 0;\n this.iadd(num);\n this.negative = 1;\n return this._normSign();\n }\n\n // At this point both numbers are positive\n var cmp = this.cmp(num);\n\n // Optimization - zeroify\n if (cmp === 0) {\n this.negative = 0;\n this.length = 1;\n this.words[0] = 0;\n return this;\n }\n\n // a > b\n var a, b;\n if (cmp > 0) {\n a = this;\n b = num;\n } else {\n a = num;\n b = this;\n }\n\n var carry = 0;\n for (var i = 0; i < b.length; i++) {\n r = (a.words[i] | 0) - (b.words[i] | 0) + carry;\n carry = r >> 26;\n this.words[i] = r & 0x3ffffff;\n }\n for (; carry !== 0 && i < a.length; i++) {\n r = (a.words[i] | 0) + carry;\n carry = r >> 26;\n this.words[i] = r & 0x3ffffff;\n }\n\n // Copy rest of the words\n if (carry === 0 && i < a.length && a !== this) {\n for (; i < a.length; i++) {\n this.words[i] = a.words[i];\n }\n }\n\n this.length = Math.max(this.length, i);\n\n if (a !== this) {\n this.negative = 1;\n }\n\n return this._strip();\n };\n\n // Subtract `num` from `this`\n BN.prototype.sub = function sub (num) {\n return this.clone().isub(num);\n };\n\n function smallMulTo (self, num, out) {\n out.negative = num.negative ^ self.negative;\n var len = (self.length + num.length) | 0;\n out.length = len;\n len = (len - 1) | 0;\n\n // Peel one iteration (compiler can't do it, because of code complexity)\n var a = self.words[0] | 0;\n var b = num.words[0] | 0;\n var r = a * b;\n\n var lo = r & 0x3ffffff;\n var carry = (r / 0x4000000) | 0;\n out.words[0] = lo;\n\n for (var k = 1; k < len; k++) {\n // Sum all words with the same `i + j = k` and accumulate `ncarry`,\n // note that ncarry could be >= 0x3ffffff\n var ncarry = carry >>> 26;\n var rword = carry & 0x3ffffff;\n var maxJ = Math.min(k, num.length - 1);\n for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {\n var i = (k - j) | 0;\n a = self.words[i] | 0;\n b = num.words[j] | 0;\n r = a * b + rword;\n ncarry += (r / 0x4000000) | 0;\n rword = r & 0x3ffffff;\n }\n out.words[k] = rword | 0;\n carry = ncarry | 0;\n }\n if (carry !== 0) {\n out.words[k] = carry | 0;\n } else {\n out.length--;\n }\n\n return out._strip();\n }\n\n // TODO(indutny): it may be reasonable to omit it for users who don't need\n // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit\n // multiplication (like elliptic secp256k1).\n var comb10MulTo = function comb10MulTo (self, num, out) {\n var a = self.words;\n var b = num.words;\n var o = out.words;\n var c = 0;\n var lo;\n var mid;\n var hi;\n var a0 = a[0] | 0;\n var al0 = a0 & 0x1fff;\n var ah0 = a0 >>> 13;\n var a1 = a[1] | 0;\n var al1 = a1 & 0x1fff;\n var ah1 = a1 >>> 13;\n var a2 = a[2] | 0;\n var al2 = a2 & 0x1fff;\n var ah2 = a2 >>> 13;\n var a3 = a[3] | 0;\n var al3 = a3 & 0x1fff;\n var ah3 = a3 >>> 13;\n var a4 = a[4] | 0;\n var al4 = a4 & 0x1fff;\n var ah4 = a4 >>> 13;\n var a5 = a[5] | 0;\n var al5 = a5 & 0x1fff;\n var ah5 = a5 >>> 13;\n var a6 = a[6] | 0;\n var al6 = a6 & 0x1fff;\n var ah6 = a6 >>> 13;\n var a7 = a[7] | 0;\n var al7 = a7 & 0x1fff;\n var ah7 = a7 >>> 13;\n var a8 = a[8] | 0;\n var al8 = a8 & 0x1fff;\n var ah8 = a8 >>> 13;\n var a9 = a[9] | 0;\n var al9 = a9 & 0x1fff;\n var ah9 = a9 >>> 13;\n var b0 = b[0] | 0;\n var bl0 = b0 & 0x1fff;\n var bh0 = b0 >>> 13;\n var b1 = b[1] | 0;\n var bl1 = b1 & 0x1fff;\n var bh1 = b1 >>> 13;\n var b2 = b[2] | 0;\n var bl2 = b2 & 0x1fff;\n var bh2 = b2 >>> 13;\n var b3 = b[3] | 0;\n var bl3 = b3 & 0x1fff;\n var bh3 = b3 >>> 13;\n var b4 = b[4] | 0;\n var bl4 = b4 & 0x1fff;\n var bh4 = b4 >>> 13;\n var b5 = b[5] | 0;\n var bl5 = b5 & 0x1fff;\n var bh5 = b5 >>> 13;\n var b6 = b[6] | 0;\n var bl6 = b6 & 0x1fff;\n var bh6 = b6 >>> 13;\n var b7 = b[7] | 0;\n var bl7 = b7 & 0x1fff;\n var bh7 = b7 >>> 13;\n var b8 = b[8] | 0;\n var bl8 = b8 & 0x1fff;\n var bh8 = b8 >>> 13;\n var b9 = b[9] | 0;\n var bl9 = b9 & 0x1fff;\n var bh9 = b9 >>> 13;\n\n out.negative = self.negative ^ num.negative;\n out.length = 19;\n /* k = 0 */\n lo = Math.imul(al0, bl0);\n mid = Math.imul(al0, bh0);\n mid = (mid + Math.imul(ah0, bl0)) | 0;\n hi = Math.imul(ah0, bh0);\n var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;\n w0 &= 0x3ffffff;\n /* k = 1 */\n lo = Math.imul(al1, bl0);\n mid = Math.imul(al1, bh0);\n mid = (mid + Math.imul(ah1, bl0)) | 0;\n hi = Math.imul(ah1, bh0);\n lo = (lo + Math.imul(al0, bl1)) | 0;\n mid = (mid + Math.imul(al0, bh1)) | 0;\n mid = (mid + Math.imul(ah0, bl1)) | 0;\n hi = (hi + Math.imul(ah0, bh1)) | 0;\n var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;\n w1 &= 0x3ffffff;\n /* k = 2 */\n lo = Math.imul(al2, bl0);\n mid = Math.imul(al2, bh0);\n mid = (mid + Math.imul(ah2, bl0)) | 0;\n hi = Math.imul(ah2, bh0);\n lo = (lo + Math.imul(al1, bl1)) | 0;\n mid = (mid + Math.imul(al1, bh1)) | 0;\n mid = (mid + Math.imul(ah1, bl1)) | 0;\n hi = (hi + Math.imul(ah1, bh1)) | 0;\n lo = (lo + Math.imul(al0, bl2)) | 0;\n mid = (mid + Math.imul(al0, bh2)) | 0;\n mid = (mid + Math.imul(ah0, bl2)) | 0;\n hi = (hi + Math.imul(ah0, bh2)) | 0;\n var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;\n w2 &= 0x3ffffff;\n /* k = 3 */\n lo = Math.imul(al3, bl0);\n mid = Math.imul(al3, bh0);\n mid = (mid + Math.imul(ah3, bl0)) | 0;\n hi = Math.imul(ah3, bh0);\n lo = (lo + Math.imul(al2, bl1)) | 0;\n mid = (mid + Math.imul(al2, bh1)) | 0;\n mid = (mid + Math.imul(ah2, bl1)) | 0;\n hi = (hi + Math.imul(ah2, bh1)) | 0;\n lo = (lo + Math.imul(al1, bl2)) | 0;\n mid = (mid + Math.imul(al1, bh2)) | 0;\n mid = (mid + Math.imul(ah1, bl2)) | 0;\n hi = (hi + Math.imul(ah1, bh2)) | 0;\n lo = (lo + Math.imul(al0, bl3)) | 0;\n mid = (mid + Math.imul(al0, bh3)) | 0;\n mid = (mid + Math.imul(ah0, bl3)) | 0;\n hi = (hi + Math.imul(ah0, bh3)) | 0;\n var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;\n w3 &= 0x3ffffff;\n /* k = 4 */\n lo = Math.imul(al4, bl0);\n mid = Math.imul(al4, bh0);\n mid = (mid + Math.imul(ah4, bl0)) | 0;\n hi = Math.imul(ah4, bh0);\n lo = (lo + Math.imul(al3, bl1)) | 0;\n mid = (mid + Math.imul(al3, bh1)) | 0;\n mid = (mid + Math.imul(ah3, bl1)) | 0;\n hi = (hi + Math.imul(ah3, bh1)) | 0;\n lo = (lo + Math.imul(al2, bl2)) | 0;\n mid = (mid + Math.imul(al2, bh2)) | 0;\n mid = (mid + Math.imul(ah2, bl2)) | 0;\n hi = (hi + Math.imul(ah2, bh2)) | 0;\n lo = (lo + Math.imul(al1, bl3)) | 0;\n mid = (mid + Math.imul(al1, bh3)) | 0;\n mid = (mid + Math.imul(ah1, bl3)) | 0;\n hi = (hi + Math.imul(ah1, bh3)) | 0;\n lo = (lo + Math.imul(al0, bl4)) | 0;\n mid = (mid + Math.imul(al0, bh4)) | 0;\n mid = (mid + Math.imul(ah0, bl4)) | 0;\n hi = (hi + Math.imul(ah0, bh4)) | 0;\n var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;\n w4 &= 0x3ffffff;\n /* k = 5 */\n lo = Math.imul(al5, bl0);\n mid = Math.imul(al5, bh0);\n mid = (mid + Math.imul(ah5, bl0)) | 0;\n hi = Math.imul(ah5, bh0);\n lo = (lo + Math.imul(al4, bl1)) | 0;\n mid = (mid + Math.imul(al4, bh1)) | 0;\n mid = (mid + Math.imul(ah4, bl1)) | 0;\n hi = (hi + Math.imul(ah4, bh1)) | 0;\n lo = (lo + Math.imul(al3, bl2)) | 0;\n mid = (mid + Math.imul(al3, bh2)) | 0;\n mid = (mid + Math.imul(ah3, bl2)) | 0;\n hi = (hi + Math.imul(ah3, bh2)) | 0;\n lo = (lo + Math.imul(al2, bl3)) | 0;\n mid = (mid + Math.imul(al2, bh3)) | 0;\n mid = (mid + Math.imul(ah2, bl3)) | 0;\n hi = (hi + Math.imul(ah2, bh3)) | 0;\n lo = (lo + Math.imul(al1, bl4)) | 0;\n mid = (mid + Math.imul(al1, bh4)) | 0;\n mid = (mid + Math.imul(ah1, bl4)) | 0;\n hi = (hi + Math.imul(ah1, bh4)) | 0;\n lo = (lo + Math.imul(al0, bl5)) | 0;\n mid = (mid + Math.imul(al0, bh5)) | 0;\n mid = (mid + Math.imul(ah0, bl5)) | 0;\n hi = (hi + Math.imul(ah0, bh5)) | 0;\n var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;\n w5 &= 0x3ffffff;\n /* k = 6 */\n lo = Math.imul(al6, bl0);\n mid = Math.imul(al6, bh0);\n mid = (mid + Math.imul(ah6, bl0)) | 0;\n hi = Math.imul(ah6, bh0);\n lo = (lo + Math.imul(al5, bl1)) | 0;\n mid = (mid + Math.imul(al5, bh1)) | 0;\n mid = (mid + Math.imul(ah5, bl1)) | 0;\n hi = (hi + Math.imul(ah5, bh1)) | 0;\n lo = (lo + Math.imul(al4, bl2)) | 0;\n mid = (mid + Math.imul(al4, bh2)) | 0;\n mid = (mid + Math.imul(ah4, bl2)) | 0;\n hi = (hi + Math.imul(ah4, bh2)) | 0;\n lo = (lo + Math.imul(al3, bl3)) | 0;\n mid = (mid + Math.imul(al3, bh3)) | 0;\n mid = (mid + Math.imul(ah3, bl3)) | 0;\n hi = (hi + Math.imul(ah3, bh3)) | 0;\n lo = (lo + Math.imul(al2, bl4)) | 0;\n mid = (mid + Math.imul(al2, bh4)) | 0;\n mid = (mid + Math.imul(ah2, bl4)) | 0;\n hi = (hi + Math.imul(ah2, bh4)) | 0;\n lo = (lo + Math.imul(al1, bl5)) | 0;\n mid = (mid + Math.imul(al1, bh5)) | 0;\n mid = (mid + Math.imul(ah1, bl5)) | 0;\n hi = (hi + Math.imul(ah1, bh5)) | 0;\n lo = (lo + Math.imul(al0, bl6)) | 0;\n mid = (mid + Math.imul(al0, bh6)) | 0;\n mid = (mid + Math.imul(ah0, bl6)) | 0;\n hi = (hi + Math.imul(ah0, bh6)) | 0;\n var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;\n w6 &= 0x3ffffff;\n /* k = 7 */\n lo = Math.imul(al7, bl0);\n mid = Math.imul(al7, bh0);\n mid = (mid + Math.imul(ah7, bl0)) | 0;\n hi = Math.imul(ah7, bh0);\n lo = (lo + Math.imul(al6, bl1)) | 0;\n mid = (mid + Math.imul(al6, bh1)) | 0;\n mid = (mid + Math.imul(ah6, bl1)) | 0;\n hi = (hi + Math.imul(ah6, bh1)) | 0;\n lo = (lo + Math.imul(al5, bl2)) | 0;\n mid = (mid + Math.imul(al5, bh2)) | 0;\n mid = (mid + Math.imul(ah5, bl2)) | 0;\n hi = (hi + Math.imul(ah5, bh2)) | 0;\n lo = (lo + Math.imul(al4, bl3)) | 0;\n mid = (mid + Math.imul(al4, bh3)) | 0;\n mid = (mid + Math.imul(ah4, bl3)) | 0;\n hi = (hi + Math.imul(ah4, bh3)) | 0;\n lo = (lo + Math.imul(al3, bl4)) | 0;\n mid = (mid + Math.imul(al3, bh4)) | 0;\n mid = (mid + Math.imul(ah3, bl4)) | 0;\n hi = (hi + Math.imul(ah3, bh4)) | 0;\n lo = (lo + Math.imul(al2, bl5)) | 0;\n mid = (mid + Math.imul(al2, bh5)) | 0;\n mid = (mid + Math.imul(ah2, bl5)) | 0;\n hi = (hi + Math.imul(ah2, bh5)) | 0;\n lo = (lo + Math.imul(al1, bl6)) | 0;\n mid = (mid + Math.imul(al1, bh6)) | 0;\n mid = (mid + Math.imul(ah1, bl6)) | 0;\n hi = (hi + Math.imul(ah1, bh6)) | 0;\n lo = (lo + Math.imul(al0, bl7)) | 0;\n mid = (mid + Math.imul(al0, bh7)) | 0;\n mid = (mid + Math.imul(ah0, bl7)) | 0;\n hi = (hi + Math.imul(ah0, bh7)) | 0;\n var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;\n w7 &= 0x3ffffff;\n /* k = 8 */\n lo = Math.imul(al8, bl0);\n mid = Math.imul(al8, bh0);\n mid = (mid + Math.imul(ah8, bl0)) | 0;\n hi = Math.imul(ah8, bh0);\n lo = (lo + Math.imul(al7, bl1)) | 0;\n mid = (mid + Math.imul(al7, bh1)) | 0;\n mid = (mid + Math.imul(ah7, bl1)) | 0;\n hi = (hi + Math.imul(ah7, bh1)) | 0;\n lo = (lo + Math.imul(al6, bl2)) | 0;\n mid = (mid + Math.imul(al6, bh2)) | 0;\n mid = (mid + Math.imul(ah6, bl2)) | 0;\n hi = (hi + Math.imul(ah6, bh2)) | 0;\n lo = (lo + Math.imul(al5, bl3)) | 0;\n mid = (mid + Math.imul(al5, bh3)) | 0;\n mid = (mid + Math.imul(ah5, bl3)) | 0;\n hi = (hi + Math.imul(ah5, bh3)) | 0;\n lo = (lo + Math.imul(al4, bl4)) | 0;\n mid = (mid + Math.imul(al4, bh4)) | 0;\n mid = (mid + Math.imul(ah4, bl4)) | 0;\n hi = (hi + Math.imul(ah4, bh4)) | 0;\n lo = (lo + Math.imul(al3, bl5)) | 0;\n mid = (mid + Math.imul(al3, bh5)) | 0;\n mid = (mid + Math.imul(ah3, bl5)) | 0;\n hi = (hi + Math.imul(ah3, bh5)) | 0;\n lo = (lo + Math.imul(al2, bl6)) | 0;\n mid = (mid + Math.imul(al2, bh6)) | 0;\n mid = (mid + Math.imul(ah2, bl6)) | 0;\n hi = (hi + Math.imul(ah2, bh6)) | 0;\n lo = (lo + Math.imul(al1, bl7)) | 0;\n mid = (mid + Math.imul(al1, bh7)) | 0;\n mid = (mid + Math.imul(ah1, bl7)) | 0;\n hi = (hi + Math.imul(ah1, bh7)) | 0;\n lo = (lo + Math.imul(al0, bl8)) | 0;\n mid = (mid + Math.imul(al0, bh8)) | 0;\n mid = (mid + Math.imul(ah0, bl8)) | 0;\n hi = (hi + Math.imul(ah0, bh8)) | 0;\n var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;\n w8 &= 0x3ffffff;\n /* k = 9 */\n lo = Math.imul(al9, bl0);\n mid = Math.imul(al9, bh0);\n mid = (mid + Math.imul(ah9, bl0)) | 0;\n hi = Math.imul(ah9, bh0);\n lo = (lo + Math.imul(al8, bl1)) | 0;\n mid = (mid + Math.imul(al8, bh1)) | 0;\n mid = (mid + Math.imul(ah8, bl1)) | 0;\n hi = (hi + Math.imul(ah8, bh1)) | 0;\n lo = (lo + Math.imul(al7, bl2)) | 0;\n mid = (mid + Math.imul(al7, bh2)) | 0;\n mid = (mid + Math.imul(ah7, bl2)) | 0;\n hi = (hi + Math.imul(ah7, bh2)) | 0;\n lo = (lo + Math.imul(al6, bl3)) | 0;\n mid = (mid + Math.imul(al6, bh3)) | 0;\n mid = (mid + Math.imul(ah6, bl3)) | 0;\n hi = (hi + Math.imul(ah6, bh3)) | 0;\n lo = (lo + Math.imul(al5, bl4)) | 0;\n mid = (mid + Math.imul(al5, bh4)) | 0;\n mid = (mid + Math.imul(ah5, bl4)) | 0;\n hi = (hi + Math.imul(ah5, bh4)) | 0;\n lo = (lo + Math.imul(al4, bl5)) | 0;\n mid = (mid + Math.imul(al4, bh5)) | 0;\n mid = (mid + Math.imul(ah4, bl5)) | 0;\n hi = (hi + Math.imul(ah4, bh5)) | 0;\n lo = (lo + Math.imul(al3, bl6)) | 0;\n mid = (mid + Math.imul(al3, bh6)) | 0;\n mid = (mid + Math.imul(ah3, bl6)) | 0;\n hi = (hi + Math.imul(ah3, bh6)) | 0;\n lo = (lo + Math.imul(al2, bl7)) | 0;\n mid = (mid + Math.imul(al2, bh7)) | 0;\n mid = (mid + Math.imul(ah2, bl7)) | 0;\n hi = (hi + Math.imul(ah2, bh7)) | 0;\n lo = (lo + Math.imul(al1, bl8)) | 0;\n mid = (mid + Math.imul(al1, bh8)) | 0;\n mid = (mid + Math.imul(ah1, bl8)) | 0;\n hi = (hi + Math.imul(ah1, bh8)) | 0;\n lo = (lo + Math.imul(al0, bl9)) | 0;\n mid = (mid + Math.imul(al0, bh9)) | 0;\n mid = (mid + Math.imul(ah0, bl9)) | 0;\n hi = (hi + Math.imul(ah0, bh9)) | 0;\n var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;\n w9 &= 0x3ffffff;\n /* k = 10 */\n lo = Math.imul(al9, bl1);\n mid = Math.imul(al9, bh1);\n mid = (mid + Math.imul(ah9, bl1)) | 0;\n hi = Math.imul(ah9, bh1);\n lo = (lo + Math.imul(al8, bl2)) | 0;\n mid = (mid + Math.imul(al8, bh2)) | 0;\n mid = (mid + Math.imul(ah8, bl2)) | 0;\n hi = (hi + Math.imul(ah8, bh2)) | 0;\n lo = (lo + Math.imul(al7, bl3)) | 0;\n mid = (mid + Math.imul(al7, bh3)) | 0;\n mid = (mid + Math.imul(ah7, bl3)) | 0;\n hi = (hi + Math.imul(ah7, bh3)) | 0;\n lo = (lo + Math.imul(al6, bl4)) | 0;\n mid = (mid + Math.imul(al6, bh4)) | 0;\n mid = (mid + Math.imul(ah6, bl4)) | 0;\n hi = (hi + Math.imul(ah6, bh4)) | 0;\n lo = (lo + Math.imul(al5, bl5)) | 0;\n mid = (mid + Math.imul(al5, bh5)) | 0;\n mid = (mid + Math.imul(ah5, bl5)) | 0;\n hi = (hi + Math.imul(ah5, bh5)) | 0;\n lo = (lo + Math.imul(al4, bl6)) | 0;\n mid = (mid + Math.imul(al4, bh6)) | 0;\n mid = (mid + Math.imul(ah4, bl6)) | 0;\n hi = (hi + Math.imul(ah4, bh6)) | 0;\n lo = (lo + Math.imul(al3, bl7)) | 0;\n mid = (mid + Math.imul(al3, bh7)) | 0;\n mid = (mid + Math.imul(ah3, bl7)) | 0;\n hi = (hi + Math.imul(ah3, bh7)) | 0;\n lo = (lo + Math.imul(al2, bl8)) | 0;\n mid = (mid + Math.imul(al2, bh8)) | 0;\n mid = (mid + Math.imul(ah2, bl8)) | 0;\n hi = (hi + Math.imul(ah2, bh8)) | 0;\n lo = (lo + Math.imul(al1, bl9)) | 0;\n mid = (mid + Math.imul(al1, bh9)) | 0;\n mid = (mid + Math.imul(ah1, bl9)) | 0;\n hi = (hi + Math.imul(ah1, bh9)) | 0;\n var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;\n w10 &= 0x3ffffff;\n /* k = 11 */\n lo = Math.imul(al9, bl2);\n mid = Math.imul(al9, bh2);\n mid = (mid + Math.imul(ah9, bl2)) | 0;\n hi = Math.imul(ah9, bh2);\n lo = (lo + Math.imul(al8, bl3)) | 0;\n mid = (mid + Math.imul(al8, bh3)) | 0;\n mid = (mid + Math.imul(ah8, bl3)) | 0;\n hi = (hi + Math.imul(ah8, bh3)) | 0;\n lo = (lo + Math.imul(al7, bl4)) | 0;\n mid = (mid + Math.imul(al7, bh4)) | 0;\n mid = (mid + Math.imul(ah7, bl4)) | 0;\n hi = (hi + Math.imul(ah7, bh4)) | 0;\n lo = (lo + Math.imul(al6, bl5)) | 0;\n mid = (mid + Math.imul(al6, bh5)) | 0;\n mid = (mid + Math.imul(ah6, bl5)) | 0;\n hi = (hi + Math.imul(ah6, bh5)) | 0;\n lo = (lo + Math.imul(al5, bl6)) | 0;\n mid = (mid + Math.imul(al5, bh6)) | 0;\n mid = (mid + Math.imul(ah5, bl6)) | 0;\n hi = (hi + Math.imul(ah5, bh6)) | 0;\n lo = (lo + Math.imul(al4, bl7)) | 0;\n mid = (mid + Math.imul(al4, bh7)) | 0;\n mid = (mid + Math.imul(ah4, bl7)) | 0;\n hi = (hi + Math.imul(ah4, bh7)) | 0;\n lo = (lo + Math.imul(al3, bl8)) | 0;\n mid = (mid + Math.imul(al3, bh8)) | 0;\n mid = (mid + Math.imul(ah3, bl8)) | 0;\n hi = (hi + Math.imul(ah3, bh8)) | 0;\n lo = (lo + Math.imul(al2, bl9)) | 0;\n mid = (mid + Math.imul(al2, bh9)) | 0;\n mid = (mid + Math.imul(ah2, bl9)) | 0;\n hi = (hi + Math.imul(ah2, bh9)) | 0;\n var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;\n w11 &= 0x3ffffff;\n /* k = 12 */\n lo = Math.imul(al9, bl3);\n mid = Math.imul(al9, bh3);\n mid = (mid + Math.imul(ah9, bl3)) | 0;\n hi = Math.imul(ah9, bh3);\n lo = (lo + Math.imul(al8, bl4)) | 0;\n mid = (mid + Math.imul(al8, bh4)) | 0;\n mid = (mid + Math.imul(ah8, bl4)) | 0;\n hi = (hi + Math.imul(ah8, bh4)) | 0;\n lo = (lo + Math.imul(al7, bl5)) | 0;\n mid = (mid + Math.imul(al7, bh5)) | 0;\n mid = (mid + Math.imul(ah7, bl5)) | 0;\n hi = (hi + Math.imul(ah7, bh5)) | 0;\n lo = (lo + Math.imul(al6, bl6)) | 0;\n mid = (mid + Math.imul(al6, bh6)) | 0;\n mid = (mid + Math.imul(ah6, bl6)) | 0;\n hi = (hi + Math.imul(ah6, bh6)) | 0;\n lo = (lo + Math.imul(al5, bl7)) | 0;\n mid = (mid + Math.imul(al5, bh7)) | 0;\n mid = (mid + Math.imul(ah5, bl7)) | 0;\n hi = (hi + Math.imul(ah5, bh7)) | 0;\n lo = (lo + Math.imul(al4, bl8)) | 0;\n mid = (mid + Math.imul(al4, bh8)) | 0;\n mid = (mid + Math.imul(ah4, bl8)) | 0;\n hi = (hi + Math.imul(ah4, bh8)) | 0;\n lo = (lo + Math.imul(al3, bl9)) | 0;\n mid = (mid + Math.imul(al3, bh9)) | 0;\n mid = (mid + Math.imul(ah3, bl9)) | 0;\n hi = (hi + Math.imul(ah3, bh9)) | 0;\n var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;\n w12 &= 0x3ffffff;\n /* k = 13 */\n lo = Math.imul(al9, bl4);\n mid = Math.imul(al9, bh4);\n mid = (mid + Math.imul(ah9, bl4)) | 0;\n hi = Math.imul(ah9, bh4);\n lo = (lo + Math.imul(al8, bl5)) | 0;\n mid = (mid + Math.imul(al8, bh5)) | 0;\n mid = (mid + Math.imul(ah8, bl5)) | 0;\n hi = (hi + Math.imul(ah8, bh5)) | 0;\n lo = (lo + Math.imul(al7, bl6)) | 0;\n mid = (mid + Math.imul(al7, bh6)) | 0;\n mid = (mid + Math.imul(ah7, bl6)) | 0;\n hi = (hi + Math.imul(ah7, bh6)) | 0;\n lo = (lo + Math.imul(al6, bl7)) | 0;\n mid = (mid + Math.imul(al6, bh7)) | 0;\n mid = (mid + Math.imul(ah6, bl7)) | 0;\n hi = (hi + Math.imul(ah6, bh7)) | 0;\n lo = (lo + Math.imul(al5, bl8)) | 0;\n mid = (mid + Math.imul(al5, bh8)) | 0;\n mid = (mid + Math.imul(ah5, bl8)) | 0;\n hi = (hi + Math.imul(ah5, bh8)) | 0;\n lo = (lo + Math.imul(al4, bl9)) | 0;\n mid = (mid + Math.imul(al4, bh9)) | 0;\n mid = (mid + Math.imul(ah4, bl9)) | 0;\n hi = (hi + Math.imul(ah4, bh9)) | 0;\n var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;\n w13 &= 0x3ffffff;\n /* k = 14 */\n lo = Math.imul(al9, bl5);\n mid = Math.imul(al9, bh5);\n mid = (mid + Math.imul(ah9, bl5)) | 0;\n hi = Math.imul(ah9, bh5);\n lo = (lo + Math.imul(al8, bl6)) | 0;\n mid = (mid + Math.imul(al8, bh6)) | 0;\n mid = (mid + Math.imul(ah8, bl6)) | 0;\n hi = (hi + Math.imul(ah8, bh6)) | 0;\n lo = (lo + Math.imul(al7, bl7)) | 0;\n mid = (mid + Math.imul(al7, bh7)) | 0;\n mid = (mid + Math.imul(ah7, bl7)) | 0;\n hi = (hi + Math.imul(ah7, bh7)) | 0;\n lo = (lo + Math.imul(al6, bl8)) | 0;\n mid = (mid + Math.imul(al6, bh8)) | 0;\n mid = (mid + Math.imul(ah6, bl8)) | 0;\n hi = (hi + Math.imul(ah6, bh8)) | 0;\n lo = (lo + Math.imul(al5, bl9)) | 0;\n mid = (mid + Math.imul(al5, bh9)) | 0;\n mid = (mid + Math.imul(ah5, bl9)) | 0;\n hi = (hi + Math.imul(ah5, bh9)) | 0;\n var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;\n w14 &= 0x3ffffff;\n /* k = 15 */\n lo = Math.imul(al9, bl6);\n mid = Math.imul(al9, bh6);\n mid = (mid + Math.imul(ah9, bl6)) | 0;\n hi = Math.imul(ah9, bh6);\n lo = (lo + Math.imul(al8, bl7)) | 0;\n mid = (mid + Math.imul(al8, bh7)) | 0;\n mid = (mid + Math.imul(ah8, bl7)) | 0;\n hi = (hi + Math.imul(ah8, bh7)) | 0;\n lo = (lo + Math.imul(al7, bl8)) | 0;\n mid = (mid + Math.imul(al7, bh8)) | 0;\n mid = (mid + Math.imul(ah7, bl8)) | 0;\n hi = (hi + Math.imul(ah7, bh8)) | 0;\n lo = (lo + Math.imul(al6, bl9)) | 0;\n mid = (mid + Math.imul(al6, bh9)) | 0;\n mid = (mid + Math.imul(ah6, bl9)) | 0;\n hi = (hi + Math.imul(ah6, bh9)) | 0;\n var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;\n w15 &= 0x3ffffff;\n /* k = 16 */\n lo = Math.imul(al9, bl7);\n mid = Math.imul(al9, bh7);\n mid = (mid + Math.imul(ah9, bl7)) | 0;\n hi = Math.imul(ah9, bh7);\n lo = (lo + Math.imul(al8, bl8)) | 0;\n mid = (mid + Math.imul(al8, bh8)) | 0;\n mid = (mid + Math.imul(ah8, bl8)) | 0;\n hi = (hi + Math.imul(ah8, bh8)) | 0;\n lo = (lo + Math.imul(al7, bl9)) | 0;\n mid = (mid + Math.imul(al7, bh9)) | 0;\n mid = (mid + Math.imul(ah7, bl9)) | 0;\n hi = (hi + Math.imul(ah7, bh9)) | 0;\n var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;\n w16 &= 0x3ffffff;\n /* k = 17 */\n lo = Math.imul(al9, bl8);\n mid = Math.imul(al9, bh8);\n mid = (mid + Math.imul(ah9, bl8)) | 0;\n hi = Math.imul(ah9, bh8);\n lo = (lo + Math.imul(al8, bl9)) | 0;\n mid = (mid + Math.imul(al8, bh9)) | 0;\n mid = (mid + Math.imul(ah8, bl9)) | 0;\n hi = (hi + Math.imul(ah8, bh9)) | 0;\n var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;\n w17 &= 0x3ffffff;\n /* k = 18 */\n lo = Math.imul(al9, bl9);\n mid = Math.imul(al9, bh9);\n mid = (mid + Math.imul(ah9, bl9)) | 0;\n hi = Math.imul(ah9, bh9);\n var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;\n w18 &= 0x3ffffff;\n o[0] = w0;\n o[1] = w1;\n o[2] = w2;\n o[3] = w3;\n o[4] = w4;\n o[5] = w5;\n o[6] = w6;\n o[7] = w7;\n o[8] = w8;\n o[9] = w9;\n o[10] = w10;\n o[11] = w11;\n o[12] = w12;\n o[13] = w13;\n o[14] = w14;\n o[15] = w15;\n o[16] = w16;\n o[17] = w17;\n o[18] = w18;\n if (c !== 0) {\n o[19] = c;\n out.length++;\n }\n return out;\n };\n\n // Polyfill comb\n if (!Math.imul) {\n comb10MulTo = smallMulTo;\n }\n\n function bigMulTo (self, num, out) {\n out.negative = num.negative ^ self.negative;\n out.length = self.length + num.length;\n\n var carry = 0;\n var hncarry = 0;\n for (var k = 0; k < out.length - 1; k++) {\n // Sum all words with the same `i + j = k` and accumulate `ncarry`,\n // note that ncarry could be >= 0x3ffffff\n var ncarry = hncarry;\n hncarry = 0;\n var rword = carry & 0x3ffffff;\n var maxJ = Math.min(k, num.length - 1);\n for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {\n var i = k - j;\n var a = self.words[i] | 0;\n var b = num.words[j] | 0;\n var r = a * b;\n\n var lo = r & 0x3ffffff;\n ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;\n lo = (lo + rword) | 0;\n rword = lo & 0x3ffffff;\n ncarry = (ncarry + (lo >>> 26)) | 0;\n\n hncarry += ncarry >>> 26;\n ncarry &= 0x3ffffff;\n }\n out.words[k] = rword;\n carry = ncarry;\n ncarry = hncarry;\n }\n if (carry !== 0) {\n out.words[k] = carry;\n } else {\n out.length--;\n }\n\n return out._strip();\n }\n\n function jumboMulTo (self, num, out) {\n // Temporary disable, see https://github.com/indutny/bn.js/issues/211\n // var fftm = new FFTM();\n // return fftm.mulp(self, num, out);\n return bigMulTo(self, num, out);\n }\n\n BN.prototype.mulTo = function mulTo (num, out) {\n var res;\n var len = this.length + num.length;\n if (this.length === 10 && num.length === 10) {\n res = comb10MulTo(this, num, out);\n } else if (len < 63) {\n res = smallMulTo(this, num, out);\n } else if (len < 1024) {\n res = bigMulTo(this, num, out);\n } else {\n res = jumboMulTo(this, num, out);\n }\n\n return res;\n };\n\n // Cooley-Tukey algorithm for FFT\n // slightly revisited to rely on looping instead of recursion\n\n function FFTM (x, y) {\n this.x = x;\n this.y = y;\n }\n\n FFTM.prototype.makeRBT = function makeRBT (N) {\n var t = new Array(N);\n var l = BN.prototype._countBits(N) - 1;\n for (var i = 0; i < N; i++) {\n t[i] = this.revBin(i, l, N);\n }\n\n return t;\n };\n\n // Returns binary-reversed representation of `x`\n FFTM.prototype.revBin = function revBin (x, l, N) {\n if (x === 0 || x === N - 1) return x;\n\n var rb = 0;\n for (var i = 0; i < l; i++) {\n rb |= (x & 1) << (l - i - 1);\n x >>= 1;\n }\n\n return rb;\n };\n\n // Performs \"tweedling\" phase, therefore 'emulating'\n // behaviour of the recursive algorithm\n FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {\n for (var i = 0; i < N; i++) {\n rtws[i] = rws[rbt[i]];\n itws[i] = iws[rbt[i]];\n }\n };\n\n FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {\n this.permute(rbt, rws, iws, rtws, itws, N);\n\n for (var s = 1; s < N; s <<= 1) {\n var l = s << 1;\n\n var rtwdf = Math.cos(2 * Math.PI / l);\n var itwdf = Math.sin(2 * Math.PI / l);\n\n for (var p = 0; p < N; p += l) {\n var rtwdf_ = rtwdf;\n var itwdf_ = itwdf;\n\n for (var j = 0; j < s; j++) {\n var re = rtws[p + j];\n var ie = itws[p + j];\n\n var ro = rtws[p + j + s];\n var io = itws[p + j + s];\n\n var rx = rtwdf_ * ro - itwdf_ * io;\n\n io = rtwdf_ * io + itwdf_ * ro;\n ro = rx;\n\n rtws[p + j] = re + ro;\n itws[p + j] = ie + io;\n\n rtws[p + j + s] = re - ro;\n itws[p + j + s] = ie - io;\n\n /* jshint maxdepth : false */\n if (j !== l) {\n rx = rtwdf * rtwdf_ - itwdf * itwdf_;\n\n itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;\n rtwdf_ = rx;\n }\n }\n }\n }\n };\n\n FFTM.prototype.guessLen13b = function guessLen13b (n, m) {\n var N = Math.max(m, n) | 1;\n var odd = N & 1;\n var i = 0;\n for (N = N / 2 | 0; N; N = N >>> 1) {\n i++;\n }\n\n return 1 << i + 1 + odd;\n };\n\n FFTM.prototype.conjugate = function conjugate (rws, iws, N) {\n if (N <= 1) return;\n\n for (var i = 0; i < N / 2; i++) {\n var t = rws[i];\n\n rws[i] = rws[N - i - 1];\n rws[N - i - 1] = t;\n\n t = iws[i];\n\n iws[i] = -iws[N - i - 1];\n iws[N - i - 1] = -t;\n }\n };\n\n FFTM.prototype.normalize13b = function normalize13b (ws, N) {\n var carry = 0;\n for (var i = 0; i < N / 2; i++) {\n var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +\n Math.round(ws[2 * i] / N) +\n carry;\n\n ws[i] = w & 0x3ffffff;\n\n if (w < 0x4000000) {\n carry = 0;\n } else {\n carry = w / 0x4000000 | 0;\n }\n }\n\n return ws;\n };\n\n FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {\n var carry = 0;\n for (var i = 0; i < len; i++) {\n carry = carry + (ws[i] | 0);\n\n rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;\n rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;\n }\n\n // Pad with zeroes\n for (i = 2 * len; i < N; ++i) {\n rws[i] = 0;\n }\n\n assert(carry === 0);\n assert((carry & ~0x1fff) === 0);\n };\n\n FFTM.prototype.stub = function stub (N) {\n var ph = new Array(N);\n for (var i = 0; i < N; i++) {\n ph[i] = 0;\n }\n\n return ph;\n };\n\n FFTM.prototype.mulp = function mulp (x, y, out) {\n var N = 2 * this.guessLen13b(x.length, y.length);\n\n var rbt = this.makeRBT(N);\n\n var _ = this.stub(N);\n\n var rws = new Array(N);\n var rwst = new Array(N);\n var iwst = new Array(N);\n\n var nrws = new Array(N);\n var nrwst = new Array(N);\n var niwst = new Array(N);\n\n var rmws = out.words;\n rmws.length = N;\n\n this.convert13b(x.words, x.length, rws, N);\n this.convert13b(y.words, y.length, nrws, N);\n\n this.transform(rws, _, rwst, iwst, N, rbt);\n this.transform(nrws, _, nrwst, niwst, N, rbt);\n\n for (var i = 0; i < N; i++) {\n var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];\n iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];\n rwst[i] = rx;\n }\n\n this.conjugate(rwst, iwst, N);\n this.transform(rwst, iwst, rmws, _, N, rbt);\n this.conjugate(rmws, _, N);\n this.normalize13b(rmws, N);\n\n out.negative = x.negative ^ y.negative;\n out.length = x.length + y.length;\n return out._strip();\n };\n\n // Multiply `this` by `num`\n BN.prototype.mul = function mul (num) {\n var out = new BN(null);\n out.words = new Array(this.length + num.length);\n return this.mulTo(num, out);\n };\n\n // Multiply employing FFT\n BN.prototype.mulf = function mulf (num) {\n var out = new BN(null);\n out.words = new Array(this.length + num.length);\n return jumboMulTo(this, num, out);\n };\n\n // In-place Multiplication\n BN.prototype.imul = function imul (num) {\n return this.clone().mulTo(num, this);\n };\n\n BN.prototype.imuln = function imuln (num) {\n var isNegNum = num < 0;\n if (isNegNum) num = -num;\n\n assert(typeof num === 'number');\n assert(num < 0x4000000);\n\n // Carry\n var carry = 0;\n for (var i = 0; i < this.length; i++) {\n var w = (this.words[i] | 0) * num;\n var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);\n carry >>= 26;\n carry += (w / 0x4000000) | 0;\n // NOTE: lo is 27bit maximum\n carry += lo >>> 26;\n this.words[i] = lo & 0x3ffffff;\n }\n\n if (carry !== 0) {\n this.words[i] = carry;\n this.length++;\n }\n\n return isNegNum ? this.ineg() : this;\n };\n\n BN.prototype.muln = function muln (num) {\n return this.clone().imuln(num);\n };\n\n // `this` * `this`\n BN.prototype.sqr = function sqr () {\n return this.mul(this);\n };\n\n // `this` * `this` in-place\n BN.prototype.isqr = function isqr () {\n return this.imul(this.clone());\n };\n\n // Math.pow(`this`, `num`)\n BN.prototype.pow = function pow (num) {\n var w = toBitArray(num);\n if (w.length === 0) return new BN(1);\n\n // Skip leading zeroes\n var res = this;\n for (var i = 0; i < w.length; i++, res = res.sqr()) {\n if (w[i] !== 0) break;\n }\n\n if (++i < w.length) {\n for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {\n if (w[i] === 0) continue;\n\n res = res.mul(q);\n }\n }\n\n return res;\n };\n\n // Shift-left in-place\n BN.prototype.iushln = function iushln (bits) {\n assert(typeof bits === 'number' && bits >= 0);\n var r = bits % 26;\n var s = (bits - r) / 26;\n var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);\n var i;\n\n if (r !== 0) {\n var carry = 0;\n\n for (i = 0; i < this.length; i++) {\n var newCarry = this.words[i] & carryMask;\n var c = ((this.words[i] | 0) - newCarry) << r;\n this.words[i] = c | carry;\n carry = newCarry >>> (26 - r);\n }\n\n if (carry) {\n this.words[i] = carry;\n this.length++;\n }\n }\n\n if (s !== 0) {\n for (i = this.length - 1; i >= 0; i--) {\n this.words[i + s] = this.words[i];\n }\n\n for (i = 0; i < s; i++) {\n this.words[i] = 0;\n }\n\n this.length += s;\n }\n\n return this._strip();\n };\n\n BN.prototype.ishln = function ishln (bits) {\n // TODO(indutny): implement me\n assert(this.negative === 0);\n return this.iushln(bits);\n };\n\n // Shift-right in-place\n // NOTE: `hint` is a lowest bit before trailing zeroes\n // NOTE: if `extended` is present - it will be filled with destroyed bits\n BN.prototype.iushrn = function iushrn (bits, hint, extended) {\n assert(typeof bits === 'number' && bits >= 0);\n var h;\n if (hint) {\n h = (hint - (hint % 26)) / 26;\n } else {\n h = 0;\n }\n\n var r = bits % 26;\n var s = Math.min((bits - r) / 26, this.length);\n var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);\n var maskedWords = extended;\n\n h -= s;\n h = Math.max(0, h);\n\n // Extended mode, copy masked part\n if (maskedWords) {\n for (var i = 0; i < s; i++) {\n maskedWords.words[i] = this.words[i];\n }\n maskedWords.length = s;\n }\n\n if (s === 0) {\n // No-op, we should not move anything at all\n } else if (this.length > s) {\n this.length -= s;\n for (i = 0; i < this.length; i++) {\n this.words[i] = this.words[i + s];\n }\n } else {\n this.words[0] = 0;\n this.length = 1;\n }\n\n var carry = 0;\n for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {\n var word = this.words[i] | 0;\n this.words[i] = (carry << (26 - r)) | (word >>> r);\n carry = word & mask;\n }\n\n // Push carried bits as a mask\n if (maskedWords && carry !== 0) {\n maskedWords.words[maskedWords.length++] = carry;\n }\n\n if (this.length === 0) {\n this.words[0] = 0;\n this.length = 1;\n }\n\n return this._strip();\n };\n\n BN.prototype.ishrn = function ishrn (bits, hint, extended) {\n // TODO(indutny): implement me\n assert(this.negative === 0);\n return this.iushrn(bits, hint, extended);\n };\n\n // Shift-left\n BN.prototype.shln = function shln (bits) {\n return this.clone().ishln(bits);\n };\n\n BN.prototype.ushln = function ushln (bits) {\n return this.clone().iushln(bits);\n };\n\n // Shift-right\n BN.prototype.shrn = function shrn (bits) {\n return this.clone().ishrn(bits);\n };\n\n BN.prototype.ushrn = function ushrn (bits) {\n return this.clone().iushrn(bits);\n };\n\n // Test if n bit is set\n BN.prototype.testn = function testn (bit) {\n assert(typeof bit === 'number' && bit >= 0);\n var r = bit % 26;\n var s = (bit - r) / 26;\n var q = 1 << r;\n\n // Fast case: bit is much higher than all existing words\n if (this.length <= s) return false;\n\n // Check bit and return\n var w = this.words[s];\n\n return !!(w & q);\n };\n\n // Return only lowers bits of number (in-place)\n BN.prototype.imaskn = function imaskn (bits) {\n assert(typeof bits === 'number' && bits >= 0);\n var r = bits % 26;\n var s = (bits - r) / 26;\n\n assert(this.negative === 0, 'imaskn works only with positive numbers');\n\n if (this.length <= s) {\n return this;\n }\n\n if (r !== 0) {\n s++;\n }\n this.length = Math.min(s, this.length);\n\n if (r !== 0) {\n var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);\n this.words[this.length - 1] &= mask;\n }\n\n return this._strip();\n };\n\n // Return only lowers bits of number\n BN.prototype.maskn = function maskn (bits) {\n return this.clone().imaskn(bits);\n };\n\n // Add plain number `num` to `this`\n BN.prototype.iaddn = function iaddn (num) {\n assert(typeof num === 'number');\n assert(num < 0x4000000);\n if (num < 0) return this.isubn(-num);\n\n // Possible sign change\n if (this.negative !== 0) {\n if (this.length === 1 && (this.words[0] | 0) <= num) {\n this.words[0] = num - (this.words[0] | 0);\n this.negative = 0;\n return this;\n }\n\n this.negative = 0;\n this.isubn(num);\n this.negative = 1;\n return this;\n }\n\n // Add without checks\n return this._iaddn(num);\n };\n\n BN.prototype._iaddn = function _iaddn (num) {\n this.words[0] += num;\n\n // Carry\n for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {\n this.words[i] -= 0x4000000;\n if (i === this.length - 1) {\n this.words[i + 1] = 1;\n } else {\n this.words[i + 1]++;\n }\n }\n this.length = Math.max(this.length, i + 1);\n\n return this;\n };\n\n // Subtract plain number `num` from `this`\n BN.prototype.isubn = function isubn (num) {\n assert(typeof num === 'number');\n assert(num < 0x4000000);\n if (num < 0) return this.iaddn(-num);\n\n if (this.negative !== 0) {\n this.negative = 0;\n this.iaddn(num);\n this.negative = 1;\n return this;\n }\n\n this.words[0] -= num;\n\n if (this.length === 1 && this.words[0] < 0) {\n this.words[0] = -this.words[0];\n this.negative = 1;\n } else {\n // Carry\n for (var i = 0; i < this.length && this.words[i] < 0; i++) {\n this.words[i] += 0x4000000;\n this.words[i + 1] -= 1;\n }\n }\n\n return this._strip();\n };\n\n BN.prototype.addn = function addn (num) {\n return this.clone().iaddn(num);\n };\n\n BN.prototype.subn = function subn (num) {\n return this.clone().isubn(num);\n };\n\n BN.prototype.iabs = function iabs () {\n this.negative = 0;\n\n return this;\n };\n\n BN.prototype.abs = function abs () {\n return this.clone().iabs();\n };\n\n BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {\n var len = num.length + shift;\n var i;\n\n this._expand(len);\n\n var w;\n var carry = 0;\n for (i = 0; i < num.length; i++) {\n w = (this.words[i + shift] | 0) + carry;\n var right = (num.words[i] | 0) * mul;\n w -= right & 0x3ffffff;\n carry = (w >> 26) - ((right / 0x4000000) | 0);\n this.words[i + shift] = w & 0x3ffffff;\n }\n for (; i < this.length - shift; i++) {\n w = (this.words[i + shift] | 0) + carry;\n carry = w >> 26;\n this.words[i + shift] = w & 0x3ffffff;\n }\n\n if (carry === 0) return this._strip();\n\n // Subtraction overflow\n assert(carry === -1);\n carry = 0;\n for (i = 0; i < this.length; i++) {\n w = -(this.words[i] | 0) + carry;\n carry = w >> 26;\n this.words[i] = w & 0x3ffffff;\n }\n this.negative = 1;\n\n return this._strip();\n };\n\n BN.prototype._wordDiv = function _wordDiv (num, mode) {\n var shift = this.length - num.length;\n\n var a = this.clone();\n var b = num;\n\n // Normalize\n var bhi = b.words[b.length - 1] | 0;\n var bhiBits = this._countBits(bhi);\n shift = 26 - bhiBits;\n if (shift !== 0) {\n b = b.ushln(shift);\n a.iushln(shift);\n bhi = b.words[b.length - 1] | 0;\n }\n\n // Initialize quotient\n var m = a.length - b.length;\n var q;\n\n if (mode !== 'mod') {\n q = new BN(null);\n q.length = m + 1;\n q.words = new Array(q.length);\n for (var i = 0; i < q.length; i++) {\n q.words[i] = 0;\n }\n }\n\n var diff = a.clone()._ishlnsubmul(b, 1, m);\n if (diff.negative === 0) {\n a = diff;\n if (q) {\n q.words[m] = 1;\n }\n }\n\n for (var j = m - 1; j >= 0; j--) {\n var qj = (a.words[b.length + j] | 0) * 0x4000000 +\n (a.words[b.length + j - 1] | 0);\n\n // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max\n // (0x7ffffff)\n qj = Math.min((qj / bhi) | 0, 0x3ffffff);\n\n a._ishlnsubmul(b, qj, j);\n while (a.negative !== 0) {\n qj--;\n a.negative = 0;\n a._ishlnsubmul(b, 1, j);\n if (!a.isZero()) {\n a.negative ^= 1;\n }\n }\n if (q) {\n q.words[j] = qj;\n }\n }\n if (q) {\n q._strip();\n }\n a._strip();\n\n // Denormalize\n if (mode !== 'div' && shift !== 0) {\n a.iushrn(shift);\n }\n\n return {\n div: q || null,\n mod: a\n };\n };\n\n // NOTE: 1) `mode` can be set to `mod` to request mod only,\n // to `div` to request div only, or be absent to\n // request both div & mod\n // 2) `positive` is true if unsigned mod is requested\n BN.prototype.divmod = function divmod (num, mode, positive) {\n assert(!num.isZero());\n\n if (this.isZero()) {\n return {\n div: new BN(0),\n mod: new BN(0)\n };\n }\n\n var div, mod, res;\n if (this.negative !== 0 && num.negative === 0) {\n res = this.neg().divmod(num, mode);\n\n if (mode !== 'mod') {\n div = res.div.neg();\n }\n\n if (mode !== 'div') {\n mod = res.mod.neg();\n if (positive && mod.negative !== 0) {\n mod.iadd(num);\n }\n }\n\n return {\n div: div,\n mod: mod\n };\n }\n\n if (this.negative === 0 && num.negative !== 0) {\n res = this.divmod(num.neg(), mode);\n\n if (mode !== 'mod') {\n div = res.div.neg();\n }\n\n return {\n div: div,\n mod: res.mod\n };\n }\n\n if ((this.negative & num.negative) !== 0) {\n res = this.neg().divmod(num.neg(), mode);\n\n if (mode !== 'div') {\n mod = res.mod.neg();\n if (positive && mod.negative !== 0) {\n mod.isub(num);\n }\n }\n\n return {\n div: res.div,\n mod: mod\n };\n }\n\n // Both numbers are positive at this point\n\n // Strip both numbers to approximate shift value\n if (num.length > this.length || this.cmp(num) < 0) {\n return {\n div: new BN(0),\n mod: this\n };\n }\n\n // Very short reduction\n if (num.length === 1) {\n if (mode === 'div') {\n return {\n div: this.divn(num.words[0]),\n mod: null\n };\n }\n\n if (mode === 'mod') {\n return {\n div: null,\n mod: new BN(this.modrn(num.words[0]))\n };\n }\n\n return {\n div: this.divn(num.words[0]),\n mod: new BN(this.modrn(num.words[0]))\n };\n }\n\n return this._wordDiv(num, mode);\n };\n\n // Find `this` / `num`\n BN.prototype.div = function div (num) {\n return this.divmod(num, 'div', false).div;\n };\n\n // Find `this` % `num`\n BN.prototype.mod = function mod (num) {\n return this.divmod(num, 'mod', false).mod;\n };\n\n BN.prototype.umod = function umod (num) {\n return this.divmod(num, 'mod', true).mod;\n };\n\n // Find Round(`this` / `num`)\n BN.prototype.divRound = function divRound (num) {\n var dm = this.divmod(num);\n\n // Fast case - exact division\n if (dm.mod.isZero()) return dm.div;\n\n var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;\n\n var half = num.ushrn(1);\n var r2 = num.andln(1);\n var cmp = mod.cmp(half);\n\n // Round down\n if (cmp < 0 || (r2 === 1 && cmp === 0)) return dm.div;\n\n // Round up\n return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);\n };\n\n BN.prototype.modrn = function modrn (num) {\n var isNegNum = num < 0;\n if (isNegNum) num = -num;\n\n assert(num <= 0x3ffffff);\n var p = (1 << 26) % num;\n\n var acc = 0;\n for (var i = this.length - 1; i >= 0; i--) {\n acc = (p * acc + (this.words[i] | 0)) % num;\n }\n\n return isNegNum ? -acc : acc;\n };\n\n // WARNING: DEPRECATED\n BN.prototype.modn = function modn (num) {\n return this.modrn(num);\n };\n\n // In-place division by number\n BN.prototype.idivn = function idivn (num) {\n var isNegNum = num < 0;\n if (isNegNum) num = -num;\n\n assert(num <= 0x3ffffff);\n\n var carry = 0;\n for (var i = this.length - 1; i >= 0; i--) {\n var w = (this.words[i] | 0) + carry * 0x4000000;\n this.words[i] = (w / num) | 0;\n carry = w % num;\n }\n\n this._strip();\n return isNegNum ? this.ineg() : this;\n };\n\n BN.prototype.divn = function divn (num) {\n return this.clone().idivn(num);\n };\n\n BN.prototype.egcd = function egcd (p) {\n assert(p.negative === 0);\n assert(!p.isZero());\n\n var x = this;\n var y = p.clone();\n\n if (x.negative !== 0) {\n x = x.umod(p);\n } else {\n x = x.clone();\n }\n\n // A * x + B * y = x\n var A = new BN(1);\n var B = new BN(0);\n\n // C * x + D * y = y\n var C = new BN(0);\n var D = new BN(1);\n\n var g = 0;\n\n while (x.isEven() && y.isEven()) {\n x.iushrn(1);\n y.iushrn(1);\n ++g;\n }\n\n var yp = y.clone();\n var xp = x.clone();\n\n while (!x.isZero()) {\n for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);\n if (i > 0) {\n x.iushrn(i);\n while (i-- > 0) {\n if (A.isOdd() || B.isOdd()) {\n A.iadd(yp);\n B.isub(xp);\n }\n\n A.iushrn(1);\n B.iushrn(1);\n }\n }\n\n for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);\n if (j > 0) {\n y.iushrn(j);\n while (j-- > 0) {\n if (C.isOdd() || D.isOdd()) {\n C.iadd(yp);\n D.isub(xp);\n }\n\n C.iushrn(1);\n D.iushrn(1);\n }\n }\n\n if (x.cmp(y) >= 0) {\n x.isub(y);\n A.isub(C);\n B.isub(D);\n } else {\n y.isub(x);\n C.isub(A);\n D.isub(B);\n }\n }\n\n return {\n a: C,\n b: D,\n gcd: y.iushln(g)\n };\n };\n\n // This is reduced incarnation of the binary EEA\n // above, designated to invert members of the\n // _prime_ fields F(p) at a maximal speed\n BN.prototype._invmp = function _invmp (p) {\n assert(p.negative === 0);\n assert(!p.isZero());\n\n var a = this;\n var b = p.clone();\n\n if (a.negative !== 0) {\n a = a.umod(p);\n } else {\n a = a.clone();\n }\n\n var x1 = new BN(1);\n var x2 = new BN(0);\n\n var delta = b.clone();\n\n while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {\n for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);\n if (i > 0) {\n a.iushrn(i);\n while (i-- > 0) {\n if (x1.isOdd()) {\n x1.iadd(delta);\n }\n\n x1.iushrn(1);\n }\n }\n\n for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);\n if (j > 0) {\n b.iushrn(j);\n while (j-- > 0) {\n if (x2.isOdd()) {\n x2.iadd(delta);\n }\n\n x2.iushrn(1);\n }\n }\n\n if (a.cmp(b) >= 0) {\n a.isub(b);\n x1.isub(x2);\n } else {\n b.isub(a);\n x2.isub(x1);\n }\n }\n\n var res;\n if (a.cmpn(1) === 0) {\n res = x1;\n } else {\n res = x2;\n }\n\n if (res.cmpn(0) < 0) {\n res.iadd(p);\n }\n\n return res;\n };\n\n BN.prototype.gcd = function gcd (num) {\n if (this.isZero()) return num.abs();\n if (num.isZero()) return this.abs();\n\n var a = this.clone();\n var b = num.clone();\n a.negative = 0;\n b.negative = 0;\n\n // Remove common factor of two\n for (var shift = 0; a.isEven() && b.isEven(); shift++) {\n a.iushrn(1);\n b.iushrn(1);\n }\n\n do {\n while (a.isEven()) {\n a.iushrn(1);\n }\n while (b.isEven()) {\n b.iushrn(1);\n }\n\n var r = a.cmp(b);\n if (r < 0) {\n // Swap `a` and `b` to make `a` always bigger than `b`\n var t = a;\n a = b;\n b = t;\n } else if (r === 0 || b.cmpn(1) === 0) {\n break;\n }\n\n a.isub(b);\n } while (true);\n\n return b.iushln(shift);\n };\n\n // Invert number in the field F(num)\n BN.prototype.invm = function invm (num) {\n return this.egcd(num).a.umod(num);\n };\n\n BN.prototype.isEven = function isEven () {\n return (this.words[0] & 1) === 0;\n };\n\n BN.prototype.isOdd = function isOdd () {\n return (this.words[0] & 1) === 1;\n };\n\n // And first word and num\n BN.prototype.andln = function andln (num) {\n return this.words[0] & num;\n };\n\n // Increment at the bit position in-line\n BN.prototype.bincn = function bincn (bit) {\n assert(typeof bit === 'number');\n var r = bit % 26;\n var s = (bit - r) / 26;\n var q = 1 << r;\n\n // Fast case: bit is much higher than all existing words\n if (this.length <= s) {\n this._expand(s + 1);\n this.words[s] |= q;\n return this;\n }\n\n // Add bit and propagate, if needed\n var carry = q;\n for (var i = s; carry !== 0 && i < this.length; i++) {\n var w = this.words[i] | 0;\n w += carry;\n carry = w >>> 26;\n w &= 0x3ffffff;\n this.words[i] = w;\n }\n if (carry !== 0) {\n this.words[i] = carry;\n this.length++;\n }\n return this;\n };\n\n BN.prototype.isZero = function isZero () {\n return this.length === 1 && this.words[0] === 0;\n };\n\n BN.prototype.cmpn = function cmpn (num) {\n var negative = num < 0;\n\n if (this.negative !== 0 && !negative) return -1;\n if (this.negative === 0 && negative) return 1;\n\n this._strip();\n\n var res;\n if (this.length > 1) {\n res = 1;\n } else {\n if (negative) {\n num = -num;\n }\n\n assert(num <= 0x3ffffff, 'Number is too big');\n\n var w = this.words[0] | 0;\n res = w === num ? 0 : w < num ? -1 : 1;\n }\n if (this.negative !== 0) return -res | 0;\n return res;\n };\n\n // Compare two numbers and return:\n // 1 - if `this` > `num`\n // 0 - if `this` == `num`\n // -1 - if `this` < `num`\n BN.prototype.cmp = function cmp (num) {\n if (this.negative !== 0 && num.negative === 0) return -1;\n if (this.negative === 0 && num.negative !== 0) return 1;\n\n var res = this.ucmp(num);\n if (this.negative !== 0) return -res | 0;\n return res;\n };\n\n // Unsigned comparison\n BN.prototype.ucmp = function ucmp (num) {\n // At this point both numbers have the same sign\n if (this.length > num.length) return 1;\n if (this.length < num.length) return -1;\n\n var res = 0;\n for (var i = this.length - 1; i >= 0; i--) {\n var a = this.words[i] | 0;\n var b = num.words[i] | 0;\n\n if (a === b) continue;\n if (a < b) {\n res = -1;\n } else if (a > b) {\n res = 1;\n }\n break;\n }\n return res;\n };\n\n BN.prototype.gtn = function gtn (num) {\n return this.cmpn(num) === 1;\n };\n\n BN.prototype.gt = function gt (num) {\n return this.cmp(num) === 1;\n };\n\n BN.prototype.gten = function gten (num) {\n return this.cmpn(num) >= 0;\n };\n\n BN.prototype.gte = function gte (num) {\n return this.cmp(num) >= 0;\n };\n\n BN.prototype.ltn = function ltn (num) {\n return this.cmpn(num) === -1;\n };\n\n BN.prototype.lt = function lt (num) {\n return this.cmp(num) === -1;\n };\n\n BN.prototype.lten = function lten (num) {\n return this.cmpn(num) <= 0;\n };\n\n BN.prototype.lte = function lte (num) {\n return this.cmp(num) <= 0;\n };\n\n BN.prototype.eqn = function eqn (num) {\n return this.cmpn(num) === 0;\n };\n\n BN.prototype.eq = function eq (num) {\n return this.cmp(num) === 0;\n };\n\n //\n // A reduce context, could be using montgomery or something better, depending\n // on the `m` itself.\n //\n BN.red = function red (num) {\n return new Red(num);\n };\n\n BN.prototype.toRed = function toRed (ctx) {\n assert(!this.red, 'Already a number in reduction context');\n assert(this.negative === 0, 'red works only with positives');\n return ctx.convertTo(this)._forceRed(ctx);\n };\n\n BN.prototype.fromRed = function fromRed () {\n assert(this.red, 'fromRed works only with numbers in reduction context');\n return this.red.convertFrom(this);\n };\n\n BN.prototype._forceRed = function _forceRed (ctx) {\n this.red = ctx;\n return this;\n };\n\n BN.prototype.forceRed = function forceRed (ctx) {\n assert(!this.red, 'Already a number in reduction context');\n return this._forceRed(ctx);\n };\n\n BN.prototype.redAdd = function redAdd (num) {\n assert(this.red, 'redAdd works only with red numbers');\n return this.red.add(this, num);\n };\n\n BN.prototype.redIAdd = function redIAdd (num) {\n assert(this.red, 'redIAdd works only with red numbers');\n return this.red.iadd(this, num);\n };\n\n BN.prototype.redSub = function redSub (num) {\n assert(this.red, 'redSub works only with red numbers');\n return this.red.sub(this, num);\n };\n\n BN.prototype.redISub = function redISub (num) {\n assert(this.red, 'redISub works only with red numbers');\n return this.red.isub(this, num);\n };\n\n BN.prototype.redShl = function redShl (num) {\n assert(this.red, 'redShl works only with red numbers');\n return this.red.shl(this, num);\n };\n\n BN.prototype.redMul = function redMul (num) {\n assert(this.red, 'redMul works only with red numbers');\n this.red._verify2(this, num);\n return this.red.mul(this, num);\n };\n\n BN.prototype.redIMul = function redIMul (num) {\n assert(this.red, 'redMul works only with red numbers');\n this.red._verify2(this, num);\n return this.red.imul(this, num);\n };\n\n BN.prototype.redSqr = function redSqr () {\n assert(this.red, 'redSqr works only with red numbers');\n this.red._verify1(this);\n return this.red.sqr(this);\n };\n\n BN.prototype.redISqr = function redISqr () {\n assert(this.red, 'redISqr works only with red numbers');\n this.red._verify1(this);\n return this.red.isqr(this);\n };\n\n // Square root over p\n BN.prototype.redSqrt = function redSqrt () {\n assert(this.red, 'redSqrt works only with red numbers');\n this.red._verify1(this);\n return this.red.sqrt(this);\n };\n\n BN.prototype.redInvm = function redInvm () {\n assert(this.red, 'redInvm works only with red numbers');\n this.red._verify1(this);\n return this.red.invm(this);\n };\n\n // Return negative clone of `this` % `red modulo`\n BN.prototype.redNeg = function redNeg () {\n assert(this.red, 'redNeg works only with red numbers');\n this.red._verify1(this);\n return this.red.neg(this);\n };\n\n BN.prototype.redPow = function redPow (num) {\n assert(this.red && !num.red, 'redPow(normalNum)');\n this.red._verify1(this);\n return this.red.pow(this, num);\n };\n\n // Prime numbers with efficient reduction\n var primes = {\n k256: null,\n p224: null,\n p192: null,\n p25519: null\n };\n\n // Pseudo-Mersenne prime\n function MPrime (name, p) {\n // P = 2 ^ N - K\n this.name = name;\n this.p = new BN(p, 16);\n this.n = this.p.bitLength();\n this.k = new BN(1).iushln(this.n).isub(this.p);\n\n this.tmp = this._tmp();\n }\n\n MPrime.prototype._tmp = function _tmp () {\n var tmp = new BN(null);\n tmp.words = new Array(Math.ceil(this.n / 13));\n return tmp;\n };\n\n MPrime.prototype.ireduce = function ireduce (num) {\n // Assumes that `num` is less than `P^2`\n // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)\n var r = num;\n var rlen;\n\n do {\n this.split(r, this.tmp);\n r = this.imulK(r);\n r = r.iadd(this.tmp);\n rlen = r.bitLength();\n } while (rlen > this.n);\n\n var cmp = rlen < this.n ? -1 : r.ucmp(this.p);\n if (cmp === 0) {\n r.words[0] = 0;\n r.length = 1;\n } else if (cmp > 0) {\n r.isub(this.p);\n } else {\n if (r.strip !== undefined) {\n // r is a BN v4 instance\n r.strip();\n } else {\n // r is a BN v5 instance\n r._strip();\n }\n }\n\n return r;\n };\n\n MPrime.prototype.split = function split (input, out) {\n input.iushrn(this.n, 0, out);\n };\n\n MPrime.prototype.imulK = function imulK (num) {\n return num.imul(this.k);\n };\n\n function K256 () {\n MPrime.call(\n this,\n 'k256',\n 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');\n }\n inherits(K256, MPrime);\n\n K256.prototype.split = function split (input, output) {\n // 256 = 9 * 26 + 22\n var mask = 0x3fffff;\n\n var outLen = Math.min(input.length, 9);\n for (var i = 0; i < outLen; i++) {\n output.words[i] = input.words[i];\n }\n output.length = outLen;\n\n if (input.length <= 9) {\n input.words[0] = 0;\n input.length = 1;\n return;\n }\n\n // Shift by 9 limbs\n var prev = input.words[9];\n output.words[output.length++] = prev & mask;\n\n for (i = 10; i < input.length; i++) {\n var next = input.words[i] | 0;\n input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);\n prev = next;\n }\n prev >>>= 22;\n input.words[i - 10] = prev;\n if (prev === 0 && input.length > 10) {\n input.length -= 10;\n } else {\n input.length -= 9;\n }\n };\n\n K256.prototype.imulK = function imulK (num) {\n // K = 0x1000003d1 = [ 0x40, 0x3d1 ]\n num.words[num.length] = 0;\n num.words[num.length + 1] = 0;\n num.length += 2;\n\n // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390\n var lo = 0;\n for (var i = 0; i < num.length; i++) {\n var w = num.words[i] | 0;\n lo += w * 0x3d1;\n num.words[i] = lo & 0x3ffffff;\n lo = w * 0x40 + ((lo / 0x4000000) | 0);\n }\n\n // Fast length reduction\n if (num.words[num.length - 1] === 0) {\n num.length--;\n if (num.words[num.length - 1] === 0) {\n num.length--;\n }\n }\n return num;\n };\n\n function P224 () {\n MPrime.call(\n this,\n 'p224',\n 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');\n }\n inherits(P224, MPrime);\n\n function P192 () {\n MPrime.call(\n this,\n 'p192',\n 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');\n }\n inherits(P192, MPrime);\n\n function P25519 () {\n // 2 ^ 255 - 19\n MPrime.call(\n this,\n '25519',\n '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');\n }\n inherits(P25519, MPrime);\n\n P25519.prototype.imulK = function imulK (num) {\n // K = 0x13\n var carry = 0;\n for (var i = 0; i < num.length; i++) {\n var hi = (num.words[i] | 0) * 0x13 + carry;\n var lo = hi & 0x3ffffff;\n hi >>>= 26;\n\n num.words[i] = lo;\n carry = hi;\n }\n if (carry !== 0) {\n num.words[num.length++] = carry;\n }\n return num;\n };\n\n // Exported mostly for testing purposes, use plain name instead\n BN._prime = function prime (name) {\n // Cached version of prime\n if (primes[name]) return primes[name];\n\n var prime;\n if (name === 'k256') {\n prime = new K256();\n } else if (name === 'p224') {\n prime = new P224();\n } else if (name === 'p192') {\n prime = new P192();\n } else if (name === 'p25519') {\n prime = new P25519();\n } else {\n throw new Error('Unknown prime ' + name);\n }\n primes[name] = prime;\n\n return prime;\n };\n\n //\n // Base reduction engine\n //\n function Red (m) {\n if (typeof m === 'string') {\n var prime = BN._prime(m);\n this.m = prime.p;\n this.prime = prime;\n } else {\n assert(m.gtn(1), 'modulus must be greater than 1');\n this.m = m;\n this.prime = null;\n }\n }\n\n Red.prototype._verify1 = function _verify1 (a) {\n assert(a.negative === 0, 'red works only with positives');\n assert(a.red, 'red works only with red numbers');\n };\n\n Red.prototype._verify2 = function _verify2 (a, b) {\n assert((a.negative | b.negative) === 0, 'red works only with positives');\n assert(a.red && a.red === b.red,\n 'red works only with red numbers');\n };\n\n Red.prototype.imod = function imod (a) {\n if (this.prime) return this.prime.ireduce(a)._forceRed(this);\n\n move(a, a.umod(this.m)._forceRed(this));\n return a;\n };\n\n Red.prototype.neg = function neg (a) {\n if (a.isZero()) {\n return a.clone();\n }\n\n return this.m.sub(a)._forceRed(this);\n };\n\n Red.prototype.add = function add (a, b) {\n this._verify2(a, b);\n\n var res = a.add(b);\n if (res.cmp(this.m) >= 0) {\n res.isub(this.m);\n }\n return res._forceRed(this);\n };\n\n Red.prototype.iadd = function iadd (a, b) {\n this._verify2(a, b);\n\n var res = a.iadd(b);\n if (res.cmp(this.m) >= 0) {\n res.isub(this.m);\n }\n return res;\n };\n\n Red.prototype.sub = function sub (a, b) {\n this._verify2(a, b);\n\n var res = a.sub(b);\n if (res.cmpn(0) < 0) {\n res.iadd(this.m);\n }\n return res._forceRed(this);\n };\n\n Red.prototype.isub = function isub (a, b) {\n this._verify2(a, b);\n\n var res = a.isub(b);\n if (res.cmpn(0) < 0) {\n res.iadd(this.m);\n }\n return res;\n };\n\n Red.prototype.shl = function shl (a, num) {\n this._verify1(a);\n return this.imod(a.ushln(num));\n };\n\n Red.prototype.imul = function imul (a, b) {\n this._verify2(a, b);\n return this.imod(a.imul(b));\n };\n\n Red.prototype.mul = function mul (a, b) {\n this._verify2(a, b);\n return this.imod(a.mul(b));\n };\n\n Red.prototype.isqr = function isqr (a) {\n return this.imul(a, a.clone());\n };\n\n Red.prototype.sqr = function sqr (a) {\n return this.mul(a, a);\n };\n\n Red.prototype.sqrt = function sqrt (a) {\n if (a.isZero()) return a.clone();\n\n var mod3 = this.m.andln(3);\n assert(mod3 % 2 === 1);\n\n // Fast case\n if (mod3 === 3) {\n var pow = this.m.add(new BN(1)).iushrn(2);\n return this.pow(a, pow);\n }\n\n // Tonelli-Shanks algorithm (Totally unoptimized and slow)\n //\n // Find Q and S, that Q * 2 ^ S = (P - 1)\n var q = this.m.subn(1);\n var s = 0;\n while (!q.isZero() && q.andln(1) === 0) {\n s++;\n q.iushrn(1);\n }\n assert(!q.isZero());\n\n var one = new BN(1).toRed(this);\n var nOne = one.redNeg();\n\n // Find quadratic non-residue\n // NOTE: Max is such because of generalized Riemann hypothesis.\n var lpow = this.m.subn(1).iushrn(1);\n var z = this.m.bitLength();\n z = new BN(2 * z * z).toRed(this);\n\n while (this.pow(z, lpow).cmp(nOne) !== 0) {\n z.redIAdd(nOne);\n }\n\n var c = this.pow(z, q);\n var r = this.pow(a, q.addn(1).iushrn(1));\n var t = this.pow(a, q);\n var m = s;\n while (t.cmp(one) !== 0) {\n var tmp = t;\n for (var i = 0; tmp.cmp(one) !== 0; i++) {\n tmp = tmp.redSqr();\n }\n assert(i < m);\n var b = this.pow(c, new BN(1).iushln(m - i - 1));\n\n r = r.redMul(b);\n c = b.redSqr();\n t = t.redMul(c);\n m = i;\n }\n\n return r;\n };\n\n Red.prototype.invm = function invm (a) {\n var inv = a._invmp(this.m);\n if (inv.negative !== 0) {\n inv.negative = 0;\n return this.imod(inv).redNeg();\n } else {\n return this.imod(inv);\n }\n };\n\n Red.prototype.pow = function pow (a, num) {\n if (num.isZero()) return new BN(1).toRed(this);\n if (num.cmpn(1) === 0) return a.clone();\n\n var windowSize = 4;\n var wnd = new Array(1 << windowSize);\n wnd[0] = new BN(1).toRed(this);\n wnd[1] = a;\n for (var i = 2; i < wnd.length; i++) {\n wnd[i] = this.mul(wnd[i - 1], a);\n }\n\n var res = wnd[0];\n var current = 0;\n var currentLen = 0;\n var start = num.bitLength() % 26;\n if (start === 0) {\n start = 26;\n }\n\n for (i = num.length - 1; i >= 0; i--) {\n var word = num.words[i];\n for (var j = start - 1; j >= 0; j--) {\n var bit = (word >> j) & 1;\n if (res !== wnd[0]) {\n res = this.sqr(res);\n }\n\n if (bit === 0 && current === 0) {\n currentLen = 0;\n continue;\n }\n\n current <<= 1;\n current |= bit;\n currentLen++;\n if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;\n\n res = this.mul(res, wnd[current]);\n currentLen = 0;\n current = 0;\n }\n start = 26;\n }\n\n return res;\n };\n\n Red.prototype.convertTo = function convertTo (num) {\n var r = num.umod(this.m);\n\n return r === num ? r.clone() : r;\n };\n\n Red.prototype.convertFrom = function convertFrom (num) {\n var res = num.clone();\n res.red = null;\n return res;\n };\n\n //\n // Montgomery method engine\n //\n\n BN.mont = function mont (num) {\n return new Mont(num);\n };\n\n function Mont (m) {\n Red.call(this, m);\n\n this.shift = this.m.bitLength();\n if (this.shift % 26 !== 0) {\n this.shift += 26 - (this.shift % 26);\n }\n\n this.r = new BN(1).iushln(this.shift);\n this.r2 = this.imod(this.r.sqr());\n this.rinv = this.r._invmp(this.m);\n\n this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);\n this.minv = this.minv.umod(this.r);\n this.minv = this.r.sub(this.minv);\n }\n inherits(Mont, Red);\n\n Mont.prototype.convertTo = function convertTo (num) {\n return this.imod(num.ushln(this.shift));\n };\n\n Mont.prototype.convertFrom = function convertFrom (num) {\n var r = this.imod(num.mul(this.rinv));\n r.red = null;\n return r;\n };\n\n Mont.prototype.imul = function imul (a, b) {\n if (a.isZero() || b.isZero()) {\n a.words[0] = 0;\n a.length = 1;\n return a;\n }\n\n var t = a.imul(b);\n var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);\n var u = t.isub(c).iushrn(this.shift);\n var res = u;\n\n if (u.cmp(this.m) >= 0) {\n res = u.isub(this.m);\n } else if (u.cmpn(0) < 0) {\n res = u.iadd(this.m);\n }\n\n return res._forceRed(this);\n };\n\n Mont.prototype.mul = function mul (a, b) {\n if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);\n\n var t = a.mul(b);\n var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);\n var u = t.isub(c).iushrn(this.shift);\n var res = u;\n if (u.cmp(this.m) >= 0) {\n res = u.isub(this.m);\n } else if (u.cmpn(0) < 0) {\n res = u.iadd(this.m);\n }\n\n return res._forceRed(this);\n };\n\n Mont.prototype.invm = function invm (a) {\n // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R\n var res = this.imod(a._invmp(this.m).mul(this.r2));\n return res._forceRed(this);\n };\n})(typeof module === 'undefined' || module, this);\n","\"use strict\";\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.map = exports.array = exports.rustEnum = exports.str = exports.vecU8 = exports.tagged = exports.vec = exports.bool = exports.option = exports.publicKey = exports.i256 = exports.u256 = exports.i128 = exports.u128 = exports.i64 = exports.u64 = exports.struct = exports.f64 = exports.f32 = exports.i32 = exports.u32 = exports.i16 = exports.u16 = exports.i8 = exports.u8 = void 0;\nconst buffer_layout_1 = require(\"buffer-layout\");\nconst web3_js_1 = require(\"@solana/web3.js\");\nconst bn_js_1 = __importDefault(require(\"bn.js\"));\nvar buffer_layout_2 = require(\"buffer-layout\");\nObject.defineProperty(exports, \"u8\", { enumerable: true, get: function () { return buffer_layout_2.u8; } });\nObject.defineProperty(exports, \"i8\", { enumerable: true, get: function () { return buffer_layout_2.s8; } });\nObject.defineProperty(exports, \"u16\", { enumerable: true, get: function () { return buffer_layout_2.u16; } });\nObject.defineProperty(exports, \"i16\", { enumerable: true, get: function () { return buffer_layout_2.s16; } });\nObject.defineProperty(exports, \"u32\", { enumerable: true, get: function () { return buffer_layout_2.u32; } });\nObject.defineProperty(exports, \"i32\", { enumerable: true, get: function () { return buffer_layout_2.s32; } });\nObject.defineProperty(exports, \"f32\", { enumerable: true, get: function () { return buffer_layout_2.f32; } });\nObject.defineProperty(exports, \"f64\", { enumerable: true, get: function () { return buffer_layout_2.f64; } });\nObject.defineProperty(exports, \"struct\", { enumerable: true, get: function () { return buffer_layout_2.struct; } });\nclass BNLayout extends buffer_layout_1.Layout {\n constructor(span, signed, property) {\n super(span, property);\n this.blob = (0, buffer_layout_1.blob)(span);\n this.signed = signed;\n }\n decode(b, offset = 0) {\n const num = new bn_js_1.default(this.blob.decode(b, offset), 10, \"le\");\n if (this.signed) {\n return num.fromTwos(this.span * 8).clone();\n }\n return num;\n }\n encode(src, b, offset = 0) {\n if (this.signed) {\n src = src.toTwos(this.span * 8);\n }\n return this.blob.encode(src.toArrayLike(Buffer, \"le\", this.span), b, offset);\n }\n}\nfunction u64(property) {\n return new BNLayout(8, false, property);\n}\nexports.u64 = u64;\nfunction i64(property) {\n return new BNLayout(8, true, property);\n}\nexports.i64 = i64;\nfunction u128(property) {\n return new BNLayout(16, false, property);\n}\nexports.u128 = u128;\nfunction i128(property) {\n return new BNLayout(16, true, property);\n}\nexports.i128 = i128;\nfunction u256(property) {\n return new BNLayout(32, false, property);\n}\nexports.u256 = u256;\nfunction i256(property) {\n return new BNLayout(32, true, property);\n}\nexports.i256 = i256;\nclass WrappedLayout extends buffer_layout_1.Layout {\n constructor(layout, decoder, encoder, property) {\n super(layout.span, property);\n this.layout = layout;\n this.decoder = decoder;\n this.encoder = encoder;\n }\n decode(b, offset) {\n return this.decoder(this.layout.decode(b, offset));\n }\n encode(src, b, offset) {\n return this.layout.encode(this.encoder(src), b, offset);\n }\n getSpan(b, offset) {\n return this.layout.getSpan(b, offset);\n }\n}\nfunction publicKey(property) {\n return new WrappedLayout((0, buffer_layout_1.blob)(32), (b) => new web3_js_1.PublicKey(b), (key) => key.toBuffer(), property);\n}\nexports.publicKey = publicKey;\nclass OptionLayout extends buffer_layout_1.Layout {\n constructor(layout, property) {\n super(-1, property);\n this.layout = layout;\n this.discriminator = (0, buffer_layout_1.u8)();\n }\n encode(src, b, offset = 0) {\n if (src === null || src === undefined) {\n return this.discriminator.encode(0, b, offset);\n }\n this.discriminator.encode(1, b, offset);\n return this.layout.encode(src, b, offset + 1) + 1;\n }\n decode(b, offset = 0) {\n const discriminator = this.discriminator.decode(b, offset);\n if (discriminator === 0) {\n return null;\n }\n else if (discriminator === 1) {\n return this.layout.decode(b, offset + 1);\n }\n throw new Error(\"Invalid option \" + this.property);\n }\n getSpan(b, offset = 0) {\n const discriminator = this.discriminator.decode(b, offset);\n if (discriminator === 0) {\n return 1;\n }\n else if (discriminator === 1) {\n return this.layout.getSpan(b, offset + 1) + 1;\n }\n throw new Error(\"Invalid option \" + this.property);\n }\n}\nfunction option(layout, property) {\n return new OptionLayout(layout, property);\n}\nexports.option = option;\nfunction bool(property) {\n return new WrappedLayout((0, buffer_layout_1.u8)(), decodeBool, encodeBool, property);\n}\nexports.bool = bool;\nfunction decodeBool(value) {\n if (value === 0) {\n return false;\n }\n else if (value === 1) {\n return true;\n }\n throw new Error(\"Invalid bool: \" + value);\n}\nfunction encodeBool(value) {\n return value ? 1 : 0;\n}\nfunction vec(elementLayout, property) {\n const length = (0, buffer_layout_1.u32)(\"length\");\n const layout = (0, buffer_layout_1.struct)([\n length,\n (0, buffer_layout_1.seq)(elementLayout, (0, buffer_layout_1.offset)(length, -length.span), \"values\"),\n ]);\n return new WrappedLayout(layout, ({ values }) => values, (values) => ({ values }), property);\n}\nexports.vec = vec;\nfunction tagged(tag, layout, property) {\n const wrappedLayout = (0, buffer_layout_1.struct)([\n u64(\"tag\"),\n layout.replicate(\"data\"),\n ]);\n function decodeTag({ tag: receivedTag, data }) {\n if (!receivedTag.eq(tag)) {\n throw new Error(\"Invalid tag, expected: \" +\n tag.toString(\"hex\") +\n \", got: \" +\n receivedTag.toString(\"hex\"));\n }\n return data;\n }\n return new WrappedLayout(wrappedLayout, decodeTag, (data) => ({ tag, data }), property);\n}\nexports.tagged = tagged;\nfunction vecU8(property) {\n const length = (0, buffer_layout_1.u32)(\"length\");\n const layout = (0, buffer_layout_1.struct)([\n length,\n (0, buffer_layout_1.blob)((0, buffer_layout_1.offset)(length, -length.span), \"data\"),\n ]);\n return new WrappedLayout(layout, ({ data }) => data, (data) => ({ data }), property);\n}\nexports.vecU8 = vecU8;\nfunction str(property) {\n return new WrappedLayout(vecU8(), (data) => data.toString(\"utf-8\"), (s) => Buffer.from(s, \"utf-8\"), property);\n}\nexports.str = str;\nfunction rustEnum(variants, property, discriminant) {\n const unionLayout = (0, buffer_layout_1.union)(discriminant !== null && discriminant !== void 0 ? discriminant : (0, buffer_layout_1.u8)(), property);\n variants.forEach((variant, index) => unionLayout.addVariant(index, variant, variant.property));\n return unionLayout;\n}\nexports.rustEnum = rustEnum;\nfunction array(elementLayout, length, property) {\n const layout = (0, buffer_layout_1.struct)([\n (0, buffer_layout_1.seq)(elementLayout, length, \"values\"),\n ]);\n return new WrappedLayout(layout, ({ values }) => values, (values) => ({ values }), property);\n}\nexports.array = array;\nclass MapEntryLayout extends buffer_layout_1.Layout {\n constructor(keyLayout, valueLayout, property) {\n super(keyLayout.span + valueLayout.span, property);\n this.keyLayout = keyLayout;\n this.valueLayout = valueLayout;\n }\n decode(b, offset) {\n offset = offset || 0;\n const key = this.keyLayout.decode(b, offset);\n const value = this.valueLayout.decode(b, offset + this.keyLayout.getSpan(b, offset));\n return [key, value];\n }\n encode(src, b, offset) {\n offset = offset || 0;\n const keyBytes = this.keyLayout.encode(src[0], b, offset);\n const valueBytes = this.valueLayout.encode(src[1], b, offset + keyBytes);\n return keyBytes + valueBytes;\n }\n getSpan(b, offset) {\n return (this.keyLayout.getSpan(b, offset) + this.valueLayout.getSpan(b, offset));\n }\n}\nfunction map(keyLayout, valueLayout, property) {\n const length = (0, buffer_layout_1.u32)(\"length\");\n const layout = (0, buffer_layout_1.struct)([\n length,\n (0, buffer_layout_1.seq)(new MapEntryLayout(keyLayout, valueLayout), (0, buffer_layout_1.offset)(length, -length.span), \"values\"),\n ]);\n return new WrappedLayout(layout, ({ values }) => new Map(values), (values) => ({ values: Array.from(values.entries()) }), property);\n}\nexports.map = map;\n//# sourceMappingURL=index.js.map","import {\n struct,\n option,\n vec,\n bool,\n u64,\n u8,\n publicKey,\n array,\n u32,\n u16,\n vecU8,\n} from '@coral-xyz/borsh';\nimport { AccountMeta, PublicKey } from '@solana/web3.js';\nimport { CompressedTokenProgram } from './program';\nimport {\n BatchCompressInstructionData,\n CompressedTokenInstructionDataApprove,\n CompressedTokenInstructionDataRevoke,\n CompressedTokenInstructionDataTransfer,\n CompressSplTokenAccountInstructionData,\n MintToInstructionData,\n} from './types';\nimport {\n APPROVE_DISCRIMINATOR,\n BATCH_COMPRESS_DISCRIMINATOR,\n COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR,\n MINT_TO_DISCRIMINATOR,\n REVOKE_DISCRIMINATOR,\n TRANSFER_DISCRIMINATOR,\n} from './constants';\nimport { Buffer } from 'buffer';\nimport { ValidityProof } from '@lightprotocol/stateless.js';\n\nconst CompressedProofLayout = struct([\n array(u8(), 32, 'a'),\n array(u8(), 64, 'b'),\n array(u8(), 32, 'c'),\n]);\n\nconst PackedTokenTransferOutputDataLayout = struct([\n publicKey('owner'),\n u64('amount'),\n option(u64(), 'lamports'),\n u8('merkleTreeIndex'),\n option(vecU8(), 'tlv'),\n]);\n\nconst InputTokenDataWithContextLayout = struct([\n u64('amount'),\n option(u8(), 'delegateIndex'),\n struct(\n [\n u8('merkleTreePubkeyIndex'),\n u8('queuePubkeyIndex'),\n u32('leafIndex'),\n bool('proveByIndex'),\n ],\n 'merkleContext',\n ),\n u16('rootIndex'),\n option(u64(), 'lamports'),\n option(vecU8(), 'tlv'),\n]);\n\nexport const DelegatedTransferLayout = struct([\n publicKey('owner'),\n option(u8(), 'delegateChangeAccountIndex'),\n]);\n\nexport const CpiContextLayout = struct([\n bool('setContext'),\n bool('firstSetContext'),\n u8('cpiContextAccountIndex'),\n]);\n\nexport const CompressedTokenInstructionDataTransferLayout = struct([\n option(CompressedProofLayout, 'proof'),\n publicKey('mint'),\n option(DelegatedTransferLayout, 'delegatedTransfer'),\n vec(InputTokenDataWithContextLayout, 'inputTokenDataWithContext'),\n vec(PackedTokenTransferOutputDataLayout, 'outputCompressedAccounts'),\n bool('isCompress'),\n option(u64(), 'compressOrDecompressAmount'),\n option(CpiContextLayout, 'cpiContext'),\n option(u8(), 'lamportsChangeAccountMerkleTreeIndex'),\n]);\n\nexport const mintToLayout = struct([\n vec(publicKey(), 'recipients'),\n vec(u64(), 'amounts'),\n option(u64(), 'lamports'),\n]);\n\nexport const batchCompressLayout = struct([\n vec(publicKey(), 'pubkeys'),\n option(vec(u64(), 'amounts'), 'amounts'),\n option(u64(), 'lamports'),\n option(u64(), 'amount'),\n u8('index'),\n u8('bump'),\n]);\n\nexport const compressSplTokenAccountInstructionDataLayout = struct([\n publicKey('owner'),\n option(u64(), 'remainingAmount'),\n option(CpiContextLayout, 'cpiContext'),\n]);\n\nexport function encodeMintToInstructionData(\n data: MintToInstructionData,\n): Buffer {\n const buffer = Buffer.alloc(1000);\n const len = mintToLayout.encode(\n {\n recipients: data.recipients,\n amounts: data.amounts,\n lamports: data.lamports,\n },\n buffer,\n );\n\n return Buffer.concat([\n new Uint8Array(MINT_TO_DISCRIMINATOR),\n new Uint8Array(buffer.subarray(0, len)),\n ]);\n}\n\nexport function decodeMintToInstructionData(\n buffer: Buffer,\n): MintToInstructionData {\n return mintToLayout.decode(\n buffer.subarray(MINT_TO_DISCRIMINATOR.length),\n ) as MintToInstructionData;\n}\n\nexport function encodeBatchCompressInstructionData(\n data: BatchCompressInstructionData,\n): Buffer {\n const buffer = Buffer.alloc(1000);\n const len = batchCompressLayout.encode(data, buffer);\n\n const lengthBuffer = Buffer.alloc(4);\n lengthBuffer.writeUInt32LE(len, 0);\n\n const dataBuffer = buffer.subarray(0, len);\n return Buffer.concat([\n new Uint8Array(BATCH_COMPRESS_DISCRIMINATOR),\n new Uint8Array(lengthBuffer),\n new Uint8Array(dataBuffer),\n ]);\n}\n\nexport function decodeBatchCompressInstructionData(\n buffer: Buffer,\n): BatchCompressInstructionData {\n return batchCompressLayout.decode(\n buffer.subarray(BATCH_COMPRESS_DISCRIMINATOR.length + 4),\n ) as BatchCompressInstructionData;\n}\n\nexport function encodeCompressSplTokenAccountInstructionData(\n data: CompressSplTokenAccountInstructionData,\n): Buffer {\n const buffer = Buffer.alloc(1000);\n const len = compressSplTokenAccountInstructionDataLayout.encode(\n {\n owner: data.owner,\n remainingAmount: data.remainingAmount,\n cpiContext: data.cpiContext,\n },\n buffer,\n );\n\n return Buffer.concat([\n new Uint8Array(COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR),\n new Uint8Array(buffer.subarray(0, len)),\n ]);\n}\n\nexport function decodeCompressSplTokenAccountInstructionData(\n buffer: Buffer,\n): CompressSplTokenAccountInstructionData {\n const data = compressSplTokenAccountInstructionDataLayout.decode(\n buffer.subarray(COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR.length),\n ) as CompressSplTokenAccountInstructionData;\n return {\n owner: data.owner,\n remainingAmount: data.remainingAmount,\n cpiContext: data.cpiContext,\n };\n}\nexport function encodeTransferInstructionData(\n data: CompressedTokenInstructionDataTransfer,\n): Buffer {\n const buffer = Buffer.alloc(1000);\n\n const len = CompressedTokenInstructionDataTransferLayout.encode(\n data,\n buffer,\n );\n\n const lengthBuffer = Buffer.alloc(4);\n lengthBuffer.writeUInt32LE(len, 0);\n\n const dataBuffer = buffer.subarray(0, len);\n\n return Buffer.concat([\n new Uint8Array(TRANSFER_DISCRIMINATOR),\n new Uint8Array(lengthBuffer),\n new Uint8Array(dataBuffer),\n ]);\n}\n\nexport function decodeTransferInstructionData(\n buffer: Buffer,\n): CompressedTokenInstructionDataTransfer {\n return CompressedTokenInstructionDataTransferLayout.decode(\n buffer.slice(TRANSFER_DISCRIMINATOR.length + 4),\n ) as CompressedTokenInstructionDataTransfer;\n}\n\ninterface BaseAccountsLayoutParams {\n feePayer: PublicKey;\n authority: PublicKey;\n cpiAuthorityPda: PublicKey;\n lightSystemProgram: PublicKey;\n registeredProgramPda: PublicKey;\n noopProgram: PublicKey;\n accountCompressionAuthority: PublicKey;\n accountCompressionProgram: PublicKey;\n selfProgram: PublicKey;\n systemProgram: PublicKey;\n}\nexport type createTokenPoolAccountsLayoutParams = {\n feePayer: PublicKey;\n tokenPoolPda: PublicKey;\n systemProgram: PublicKey;\n mint: PublicKey;\n tokenProgram: PublicKey;\n cpiAuthorityPda: PublicKey;\n};\n\nexport type addTokenPoolAccountsLayoutParams =\n createTokenPoolAccountsLayoutParams & {\n existingTokenPoolPda: PublicKey;\n };\n\nexport type mintToAccountsLayoutParams = BaseAccountsLayoutParams & {\n mint: PublicKey;\n tokenPoolPda: PublicKey;\n tokenProgram: PublicKey;\n merkleTree: PublicKey;\n solPoolPda: PublicKey | null;\n};\nexport type transferAccountsLayoutParams = BaseAccountsLayoutParams & {\n tokenPoolPda?: PublicKey;\n compressOrDecompressTokenAccount?: PublicKey;\n tokenProgram?: PublicKey;\n};\nexport type approveAccountsLayoutParams = BaseAccountsLayoutParams;\nexport type revokeAccountsLayoutParams = approveAccountsLayoutParams;\nexport type freezeAccountsLayoutParams = BaseAccountsLayoutParams & {\n mint: PublicKey;\n};\nexport type thawAccountsLayoutParams = freezeAccountsLayoutParams;\n\nexport const createTokenPoolAccountsLayout = (\n accounts: createTokenPoolAccountsLayoutParams,\n): AccountMeta[] => {\n const {\n feePayer,\n tokenPoolPda,\n systemProgram,\n mint,\n tokenProgram,\n cpiAuthorityPda,\n } = accounts;\n return [\n { pubkey: feePayer, isSigner: true, isWritable: true },\n { pubkey: tokenPoolPda, isSigner: false, isWritable: true },\n { pubkey: systemProgram, isSigner: false, isWritable: false },\n { pubkey: mint, isSigner: false, isWritable: true },\n { pubkey: tokenProgram, isSigner: false, isWritable: false },\n { pubkey: cpiAuthorityPda, isSigner: false, isWritable: false },\n ];\n};\n\nexport const addTokenPoolAccountsLayout = (\n accounts: addTokenPoolAccountsLayoutParams,\n): AccountMeta[] => {\n const {\n feePayer,\n tokenPoolPda,\n systemProgram,\n mint,\n tokenProgram,\n cpiAuthorityPda,\n existingTokenPoolPda,\n } = accounts;\n return [\n { pubkey: feePayer, isSigner: true, isWritable: true },\n { pubkey: tokenPoolPda, isSigner: false, isWritable: true },\n { pubkey: existingTokenPoolPda, isSigner: false, isWritable: false },\n { pubkey: systemProgram, isSigner: false, isWritable: false },\n { pubkey: mint, isSigner: false, isWritable: true },\n { pubkey: tokenProgram, isSigner: false, isWritable: false },\n { pubkey: cpiAuthorityPda, isSigner: false, isWritable: false },\n ];\n};\n\nexport const mintToAccountsLayout = (\n accounts: mintToAccountsLayoutParams,\n): AccountMeta[] => {\n const defaultPubkey = CompressedTokenProgram.programId;\n const {\n feePayer,\n authority,\n cpiAuthorityPda,\n mint,\n tokenPoolPda,\n tokenProgram,\n lightSystemProgram,\n registeredProgramPda,\n noopProgram,\n accountCompressionAuthority,\n accountCompressionProgram,\n merkleTree,\n selfProgram,\n systemProgram,\n solPoolPda,\n } = accounts;\n\n const accountsList: AccountMeta[] = [\n { pubkey: feePayer, isSigner: true, isWritable: true },\n { pubkey: authority, isSigner: true, isWritable: false },\n { pubkey: cpiAuthorityPda, isSigner: false, isWritable: false },\n { pubkey: mint, isSigner: false, isWritable: true },\n { pubkey: tokenPoolPda, isSigner: false, isWritable: true },\n { pubkey: tokenProgram, isSigner: false, isWritable: false },\n { pubkey: lightSystemProgram, isSigner: false, isWritable: false },\n { pubkey: registeredProgramPda, isSigner: false, isWritable: false },\n { pubkey: noopProgram, isSigner: false, isWritable: false },\n {\n pubkey: accountCompressionAuthority,\n isSigner: false,\n isWritable: false,\n },\n {\n pubkey: accountCompressionProgram,\n isSigner: false,\n isWritable: false,\n },\n { pubkey: merkleTree, isSigner: false, isWritable: true },\n { pubkey: selfProgram, isSigner: false, isWritable: false },\n { pubkey: systemProgram, isSigner: false, isWritable: false },\n {\n pubkey: solPoolPda ?? defaultPubkey,\n isSigner: false,\n isWritable: true,\n },\n ];\n\n return accountsList;\n};\n\nexport const transferAccountsLayout = (\n accounts: transferAccountsLayoutParams,\n): AccountMeta[] => {\n const defaultPubkey = CompressedTokenProgram.programId;\n const {\n feePayer,\n authority,\n cpiAuthorityPda,\n lightSystemProgram,\n registeredProgramPda,\n noopProgram,\n accountCompressionAuthority,\n accountCompressionProgram,\n selfProgram,\n tokenPoolPda,\n compressOrDecompressTokenAccount,\n tokenProgram,\n systemProgram,\n } = accounts;\n\n const accountsList: AccountMeta[] = [\n { pubkey: feePayer, isSigner: true, isWritable: true },\n { pubkey: authority, isSigner: true, isWritable: false },\n { pubkey: cpiAuthorityPda, isSigner: false, isWritable: false },\n { pubkey: lightSystemProgram, isSigner: false, isWritable: false },\n { pubkey: registeredProgramPda, isSigner: false, isWritable: false },\n { pubkey: noopProgram, isSigner: false, isWritable: false },\n {\n pubkey: accountCompressionAuthority,\n isSigner: false,\n isWritable: false,\n },\n {\n pubkey: accountCompressionProgram,\n isSigner: false,\n isWritable: false,\n },\n { pubkey: selfProgram, isSigner: false, isWritable: false },\n {\n pubkey: tokenPoolPda ?? defaultPubkey,\n isSigner: false,\n isWritable: true,\n },\n {\n pubkey: compressOrDecompressTokenAccount ?? defaultPubkey,\n isSigner: false,\n isWritable: true,\n },\n {\n pubkey: tokenProgram ?? defaultPubkey,\n isSigner: false,\n isWritable: false,\n },\n { pubkey: systemProgram, isSigner: false, isWritable: false },\n ];\n\n return accountsList;\n};\n\nexport const approveAccountsLayout = (\n accounts: approveAccountsLayoutParams,\n): AccountMeta[] => {\n const {\n feePayer,\n authority,\n cpiAuthorityPda,\n lightSystemProgram,\n registeredProgramPda,\n noopProgram,\n accountCompressionAuthority,\n accountCompressionProgram,\n selfProgram,\n systemProgram,\n } = accounts;\n\n return [\n { pubkey: feePayer, isSigner: true, isWritable: true },\n { pubkey: authority, isSigner: true, isWritable: false },\n { pubkey: cpiAuthorityPda, isSigner: false, isWritable: false },\n { pubkey: lightSystemProgram, isSigner: false, isWritable: false },\n { pubkey: registeredProgramPda, isSigner: false, isWritable: false },\n { pubkey: noopProgram, isSigner: false, isWritable: false },\n {\n pubkey: accountCompressionAuthority,\n isSigner: false,\n isWritable: false,\n },\n {\n pubkey: accountCompressionProgram,\n isSigner: false,\n isWritable: false,\n },\n { pubkey: selfProgram, isSigner: false, isWritable: false },\n { pubkey: systemProgram, isSigner: false, isWritable: false },\n ];\n};\n\nexport const revokeAccountsLayout = approveAccountsLayout;\n\nexport const freezeAccountsLayout = (\n accounts: freezeAccountsLayoutParams,\n): AccountMeta[] => {\n const {\n feePayer,\n authority,\n cpiAuthorityPda,\n lightSystemProgram,\n registeredProgramPda,\n noopProgram,\n accountCompressionAuthority,\n accountCompressionProgram,\n selfProgram,\n systemProgram,\n mint,\n } = accounts;\n\n return [\n { pubkey: feePayer, isSigner: true, isWritable: true },\n { pubkey: authority, isSigner: true, isWritable: false },\n { pubkey: cpiAuthorityPda, isSigner: false, isWritable: false },\n { pubkey: lightSystemProgram, isSigner: false, isWritable: false },\n { pubkey: registeredProgramPda, isSigner: false, isWritable: false },\n { pubkey: noopProgram, isSigner: false, isWritable: false },\n {\n pubkey: accountCompressionAuthority,\n isSigner: false,\n isWritable: false,\n },\n {\n pubkey: accountCompressionProgram,\n isSigner: false,\n isWritable: false,\n },\n { pubkey: selfProgram, isSigner: false, isWritable: false },\n { pubkey: systemProgram, isSigner: false, isWritable: false },\n { pubkey: mint, isSigner: false, isWritable: false },\n ];\n};\n\nexport const thawAccountsLayout = freezeAccountsLayout;\n\nexport const CompressedTokenInstructionDataApproveLayout = struct([\n struct(\n [array(u8(), 32, 'a'), array(u8(), 64, 'b'), array(u8(), 32, 'c')],\n 'proof',\n ),\n publicKey('mint'),\n vec(InputTokenDataWithContextLayout, 'inputTokenDataWithContext'),\n option(CpiContextLayout, 'cpiContext'),\n publicKey('delegate'),\n u64('delegatedAmount'),\n u8('delegateMerkleTreeIndex'),\n u8('changeAccountMerkleTreeIndex'),\n option(u64(), 'delegateLamports'),\n]);\n\nexport const CompressedTokenInstructionDataRevokeLayout = struct([\n struct(\n [array(u8(), 32, 'a'), array(u8(), 64, 'b'), array(u8(), 32, 'c')],\n 'proof',\n ),\n publicKey('mint'),\n vec(InputTokenDataWithContextLayout, 'inputTokenDataWithContext'),\n option(CpiContextLayout, 'cpiContext'),\n u8('outputAccountMerkleTreeIndex'),\n]);\n\n// Approve and revoke instuctions do not support optional proof yet.\nconst emptyProof: ValidityProof = {\n a: new Array(32).fill(0),\n b: new Array(64).fill(0),\n c: new Array(32).fill(0),\n};\n\nfunction isEmptyProof(proof: ValidityProof): boolean {\n return (\n proof.a.every(a => a === 0) &&\n proof.b.every(b => b === 0) &&\n proof.c.every(c => c === 0)\n );\n}\n\nexport function encodeApproveInstructionData(\n data: CompressedTokenInstructionDataApprove,\n): Buffer {\n const buffer = Buffer.alloc(1000);\n\n const proofOption = data.proof ?? emptyProof;\n\n const len = CompressedTokenInstructionDataApproveLayout.encode(\n {\n ...data,\n proof: proofOption,\n },\n buffer,\n );\n\n const lengthBuffer = Buffer.alloc(4);\n lengthBuffer.writeUInt32LE(len, 0);\n\n const dataBuffer = buffer.subarray(0, len);\n\n return Buffer.concat([\n new Uint8Array(APPROVE_DISCRIMINATOR),\n new Uint8Array(lengthBuffer),\n new Uint8Array(dataBuffer),\n ]);\n}\n\nexport function decodeApproveInstructionData(\n buffer: Buffer,\n): CompressedTokenInstructionDataApprove {\n const data = CompressedTokenInstructionDataApproveLayout.decode(\n buffer.subarray(APPROVE_DISCRIMINATOR.length),\n ) as CompressedTokenInstructionDataApprove;\n return {\n ...data,\n proof: isEmptyProof(data.proof!) ? null : data.proof!,\n };\n}\n\nexport function encodeRevokeInstructionData(\n data: CompressedTokenInstructionDataRevoke,\n): Buffer {\n const buffer = Buffer.alloc(1000);\n\n const proofOption = data.proof ?? emptyProof;\n\n const len = CompressedTokenInstructionDataRevokeLayout.encode(\n {\n ...data,\n proof: proofOption,\n },\n buffer,\n );\n\n const lengthBuffer = Buffer.alloc(4);\n lengthBuffer.writeUInt32LE(len, 0);\n\n const dataBuffer = buffer.subarray(0, len);\n\n return Buffer.concat([\n new Uint8Array(REVOKE_DISCRIMINATOR),\n new Uint8Array(lengthBuffer),\n new Uint8Array(dataBuffer),\n ]);\n}\n\nexport function decodeRevokeInstructionData(\n buffer: Buffer,\n): CompressedTokenInstructionDataRevoke {\n const data = CompressedTokenInstructionDataRevokeLayout.decode(\n buffer.subarray(REVOKE_DISCRIMINATOR.length),\n ) as CompressedTokenInstructionDataRevoke;\n return {\n ...data,\n proof: isEmptyProof(data.proof!) ? null : data.proof!,\n };\n}\n","import {\n PublicKey,\n TransactionInstruction,\n SystemProgram,\n Connection,\n AddressLookupTableProgram,\n AccountMeta,\n ComputeBudgetProgram,\n} from '@solana/web3.js';\nimport BN from 'bn.js';\nimport { Buffer } from 'buffer';\nimport {\n ValidityProof,\n LightSystemProgram,\n ParsedTokenAccount,\n bn,\n defaultStaticAccountsStruct,\n sumUpLamports,\n toArray,\n validateSameOwner,\n validateSufficientBalance,\n defaultTestStateTreeAccounts,\n TreeInfo,\n CompressedProof,\n featureFlags,\n TreeType,\n} from '@lightprotocol/stateless.js';\nimport {\n MINT_SIZE,\n TOKEN_2022_PROGRAM_ID,\n TOKEN_PROGRAM_ID,\n createInitializeMint2Instruction,\n createMintToInstruction,\n} from '@solana/spl-token';\nimport {\n CPI_AUTHORITY_SEED,\n POOL_SEED,\n CREATE_TOKEN_POOL_DISCRIMINATOR,\n ADD_TOKEN_POOL_DISCRIMINATOR,\n} from './constants';\nimport { checkMint, packCompressedTokenAccounts } from './utils';\nimport {\n encodeTransferInstructionData,\n encodeCompressSplTokenAccountInstructionData,\n encodeMintToInstructionData,\n createTokenPoolAccountsLayout,\n mintToAccountsLayout,\n transferAccountsLayout,\n approveAccountsLayout,\n revokeAccountsLayout,\n encodeApproveInstructionData,\n encodeRevokeInstructionData,\n addTokenPoolAccountsLayout,\n encodeBatchCompressInstructionData,\n} from './layout';\nimport {\n BatchCompressInstructionData,\n CompressedTokenInstructionDataApprove,\n CompressedTokenInstructionDataRevoke,\n CompressedTokenInstructionDataTransfer,\n DelegatedTransfer,\n TokenTransferOutputData,\n} from './types';\nimport {\n checkTokenPoolInfo,\n TokenPoolInfo,\n} from './utils/get-token-pool-infos';\n\nexport type CompressParams = {\n /**\n * Fee payer\n */\n payer: PublicKey;\n /**\n * Owner of uncompressed token account\n */\n owner: PublicKey;\n /**\n * Source SPL Token account address\n */\n source: PublicKey;\n /**\n * Recipient address(es)\n */\n toAddress: PublicKey | PublicKey[];\n /**\n * Token amount(s) to compress\n */\n amount: number | BN | number[] | BN[];\n /**\n * SPL Token mint address\n */\n mint: PublicKey;\n /**\n * State tree to write to\n */\n outputStateTreeInfo: TreeInfo;\n /**\n * Token pool\n */\n tokenPoolInfo: TokenPoolInfo;\n};\n\nexport type CompressSplTokenAccountParams = {\n /**\n * Fee payer\n */\n feePayer: PublicKey;\n /**\n * SPL Token account owner\n */\n authority: PublicKey;\n /**\n * SPL Token account to compress\n */\n tokenAccount: PublicKey;\n /**\n * SPL Token mint address\n */\n mint: PublicKey;\n /**\n * Amount to leave in token account\n */\n remainingAmount?: BN;\n /**\n * State tree to write to\n */\n outputStateTreeInfo: TreeInfo;\n /**\n * Token pool\n */\n tokenPoolInfo: TokenPoolInfo;\n};\n\nexport type DecompressParams = {\n /**\n * Fee payer\n */\n payer: PublicKey;\n /**\n * Source compressed token accounts\n */\n inputCompressedTokenAccounts: ParsedTokenAccount[];\n /**\n * Destination uncompressed token account\n */\n toAddress: PublicKey;\n /**\n * Token amount to decompress\n */\n amount: number | BN;\n /**\n * Validity proof for input state\n */\n recentValidityProof: ValidityProof | CompressedProof | null;\n /**\n * Recent state root indices\n */\n recentInputStateRootIndices: number[];\n /**\n * Token pool(s)\n */\n tokenPoolInfos: TokenPoolInfo | TokenPoolInfo[];\n};\n\nexport type TransferParams = {\n /**\n * Fee payer\n */\n payer: PublicKey;\n /**\n * Source compressed token accounts\n */\n inputCompressedTokenAccounts: ParsedTokenAccount[];\n /**\n * Recipient address\n */\n toAddress: PublicKey;\n /**\n * Token amount to transfer\n */\n amount: BN | number;\n /**\n * Validity proof for input state\n */\n recentValidityProof: ValidityProof | CompressedProof | null;\n /**\n * Recent state root indices\n */\n recentInputStateRootIndices: number[];\n};\n\nexport type ApproveParams = {\n /**\n * Fee payer\n */\n payer: PublicKey;\n /**\n * Source compressed token accounts\n */\n inputCompressedTokenAccounts: ParsedTokenAccount[];\n /**\n * Recipient address\n */\n toAddress: PublicKey;\n /**\n * Token amount to approve\n */\n amount: BN | number;\n /**\n * Validity proof for input state\n */\n recentValidityProof: ValidityProof | CompressedProof | null;\n /**\n * Recent state root indices\n */\n recentInputStateRootIndices: number[];\n};\n\nexport type RevokeParams = {\n /**\n * Fee payer\n */\n payer: PublicKey;\n /**\n * Input compressed token accounts\n */\n inputCompressedTokenAccounts: ParsedTokenAccount[];\n /**\n * Validity proof for input state\n */\n recentValidityProof: ValidityProof | CompressedProof | null;\n /**\n * Recent state root indices\n */\n recentInputStateRootIndices: number[];\n};\n\n/**\n * Create Mint account for compressed Tokens\n */\nexport type CreateMintParams = {\n /**\n * Fee payer\n */\n feePayer: PublicKey;\n /**\n * SPL Mint address\n */\n mint: PublicKey;\n /**\n * Mint authority\n */\n authority: PublicKey;\n /**\n * Optional: freeze authority\n */\n freezeAuthority: PublicKey | null;\n /**\n * Mint decimals\n */\n decimals: number;\n /**\n * lamport amount for mint account rent exemption\n */\n rentExemptBalance: number;\n /**\n * Optional: The token program ID. Default: SPL Token Program ID\n */\n tokenProgramId?: PublicKey;\n /**\n * Optional: Mint size to use, defaults to MINT_SIZE\n */\n mintSize?: number;\n};\n\n/**\n * Parameters for merging compressed token accounts\n */\nexport type MergeTokenAccountsParams = {\n /**\n * Fee payer\n */\n payer: PublicKey;\n /**\n * Owner of the compressed token accounts to be merged\n */\n owner: PublicKey;\n /**\n * SPL Token mint address\n */\n mint: PublicKey;\n /**\n * Array of compressed token accounts to merge\n */\n inputCompressedTokenAccounts: ParsedTokenAccount[];\n /**\n * Validity proof for state inclusion\n */\n recentValidityProof: ValidityProof | CompressedProof | null;\n /**\n * State root indices of the input state\n */\n recentInputStateRootIndices: number[];\n};\n\n/**\n * Create compressed token accounts\n */\nexport type MintToParams = {\n /**\n * Fee payer\n */\n feePayer: PublicKey;\n /**\n * Token mint address\n */\n mint: PublicKey;\n /**\n * Mint authority\n */\n authority: PublicKey;\n /**\n * Recipient address(es)\n */\n toPubkey: PublicKey[] | PublicKey;\n /**\n * Token amount(s) to mint\n */\n amount: BN | BN[] | number | number[];\n /**\n * State tree for minted tokens\n */\n outputStateTreeInfo: TreeInfo;\n /**\n * Token pool\n */\n tokenPoolInfo: TokenPoolInfo;\n};\n\n/**\n * Register an existing SPL mint account to the compressed token program\n * Creates an omnibus account for the mint\n */\nexport type CreateTokenPoolParams = {\n /**\n * Fee payer\n */\n feePayer: PublicKey;\n /**\n * SPL Mint address\n */\n mint: PublicKey;\n /**\n * Optional: The token program ID. Default: SPL Token Program ID\n */\n tokenProgramId?: PublicKey;\n};\n\nexport type AddTokenPoolParams = {\n /**\n * Fee payer\n */\n feePayer: PublicKey;\n /**\n * Token mint address\n */\n mint: PublicKey;\n /**\n * Token pool index\n */\n poolIndex: number;\n /**\n * Optional: Token program ID. Default: SPL Token Program ID\n */\n tokenProgramId?: PublicKey;\n};\n\n/**\n * Mint from existing SPL mint to compressed token accounts\n */\nexport type ApproveAndMintToParams = {\n /**\n * Fee payer\n */\n feePayer: PublicKey;\n /**\n * SPL Mint address\n */\n mint: PublicKey;\n /**\n * Mint authority\n */\n authority: PublicKey;\n /**\n * Mint authority (associated) token account\n */\n authorityTokenAccount: PublicKey;\n /**\n * Recipient address\n */\n toPubkey: PublicKey;\n /**\n * Token amount to mint\n */\n amount: BN | number;\n /**\n * State tree to write to\n */\n outputStateTreeInfo: TreeInfo;\n /**\n * Token pool\n */\n tokenPoolInfo: TokenPoolInfo;\n};\n\nexport type CreateTokenProgramLookupTableParams = {\n /**\n * Fee payer\n */\n payer: PublicKey;\n /**\n * Authority of the transaction\n */\n authority: PublicKey;\n /**\n * Optional Mint addresses to store in the lookup table\n */\n mints?: PublicKey[];\n /**\n * Recently finalized Solana slot\n */\n recentSlot: number;\n /**\n * Optional additional addresses to store in the lookup table\n */\n remainingAccounts?: PublicKey[];\n};\n\n/**\n * Sum up the token amounts of the compressed token accounts\n */\nexport const sumUpTokenAmount = (accounts: ParsedTokenAccount[]): BN => {\n return accounts.reduce(\n (acc, account: ParsedTokenAccount) => acc.add(account.parsed.amount),\n bn(0),\n );\n};\n\n/**\n * Validate that all the compressed token accounts are owned by the same owner.\n */\nexport const validateSameTokenOwner = (accounts: ParsedTokenAccount[]) => {\n const owner = accounts[0].parsed.owner;\n accounts.forEach(acc => {\n if (!acc.parsed.owner.equals(owner)) {\n throw new Error('Token accounts must be owned by the same owner');\n }\n });\n};\n\n/**\n * Parse compressed token accounts to get the mint, current owner and delegate.\n */\nexport const parseTokenData = (\n compressedTokenAccounts: ParsedTokenAccount[],\n) => {\n const mint = compressedTokenAccounts[0].parsed.mint;\n const currentOwner = compressedTokenAccounts[0].parsed.owner;\n const delegate = compressedTokenAccounts[0].parsed.delegate;\n\n return { mint, currentOwner, delegate };\n};\n\nexport const parseMaybeDelegatedTransfer = (\n inputs: ParsedTokenAccount[],\n outputs: TokenTransferOutputData[],\n): { delegatedTransfer: DelegatedTransfer | null; authority: PublicKey } => {\n if (inputs.length < 1)\n throw new Error('Must supply at least one input token account.');\n\n const owner = inputs[0].parsed.owner;\n\n const delegatedAccountsIndex = inputs.findIndex(a => a.parsed.delegate);\n\n /// Fast path: no delegated account used\n if (delegatedAccountsIndex === -1)\n return { delegatedTransfer: null, authority: owner };\n\n const delegate = inputs[delegatedAccountsIndex].parsed.delegate;\n const delegateChangeAccountIndex = outputs.length <= 1 ? null : 0;\n\n return {\n delegatedTransfer: {\n owner,\n delegateChangeAccountIndex,\n },\n authority: delegate!,\n };\n};\n\n/**\n * Create the output state for a transfer transaction.\n * @param inputCompressedTokenAccounts Input state\n * @param toAddress Recipient address\n * @param amount Amount of tokens to transfer\n * @returns Output token data for the transfer\n * instruction\n */\nexport function createTransferOutputState(\n inputCompressedTokenAccounts: ParsedTokenAccount[],\n toAddress: PublicKey,\n amount: number | BN,\n): TokenTransferOutputData[] {\n amount = bn(amount);\n const inputAmount = sumUpTokenAmount(inputCompressedTokenAccounts);\n const inputLamports = sumUpLamports(\n inputCompressedTokenAccounts.map(acc => acc.compressedAccount),\n );\n\n const changeAmount = inputAmount.sub(amount);\n\n validateSufficientBalance(changeAmount);\n\n if (changeAmount.eq(bn(0)) && inputLamports.eq(bn(0))) {\n return [\n {\n owner: toAddress,\n amount,\n lamports: inputLamports,\n tlv: null,\n },\n ];\n }\n\n /// validates token program\n validateSameOwner(\n inputCompressedTokenAccounts.map(acc => acc.compressedAccount),\n );\n validateSameTokenOwner(inputCompressedTokenAccounts);\n\n const outputCompressedAccounts: TokenTransferOutputData[] = [\n {\n owner: inputCompressedTokenAccounts[0].parsed.owner,\n amount: changeAmount,\n lamports: inputLamports,\n tlv: null,\n },\n {\n owner: toAddress,\n amount,\n lamports: bn(0),\n tlv: null,\n },\n ];\n return outputCompressedAccounts;\n}\n\n/**\n * Create the output state for a compress transaction.\n * @param inputCompressedTokenAccounts Input state\n * @param amount Amount of tokens to compress\n * @returns Output token data for the compress\n * instruction\n */\nexport function createDecompressOutputState(\n inputCompressedTokenAccounts: ParsedTokenAccount[],\n amount: number | BN,\n): TokenTransferOutputData[] {\n amount = bn(amount);\n const inputLamports = sumUpLamports(\n inputCompressedTokenAccounts.map(acc => acc.compressedAccount),\n );\n const inputAmount = sumUpTokenAmount(inputCompressedTokenAccounts);\n const changeAmount = inputAmount.sub(amount);\n\n validateSufficientBalance(changeAmount);\n\n /// lamports gets decompressed\n if (changeAmount.eq(bn(0)) && inputLamports.eq(bn(0))) {\n return [];\n }\n\n validateSameOwner(\n inputCompressedTokenAccounts.map(acc => acc.compressedAccount),\n );\n validateSameTokenOwner(inputCompressedTokenAccounts);\n\n const tokenTransferOutputs: TokenTransferOutputData[] = [\n {\n owner: inputCompressedTokenAccounts[0].parsed.owner,\n amount: changeAmount,\n lamports: inputLamports,\n tlv: null,\n },\n ];\n return tokenTransferOutputs;\n}\n\nexport class CompressedTokenProgram {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Public key that identifies the CompressedPda program\n */\n static programId: PublicKey = new PublicKey(\n 'cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m',\n );\n\n /**\n * Set a custom programId via PublicKey or base58 encoded string.\n * This method is not required for regular usage.\n *\n * Use this only if you know what you are doing.\n */\n static setProgramId(programId: PublicKey | string) {\n this.programId =\n typeof programId === 'string'\n ? new PublicKey(programId)\n : programId;\n }\n\n /**\n * Derive the token pool pda.\n * To derive the token pool pda with bump, use {@link deriveTokenPoolPdaWithIndex}.\n *\n * @param mint The mint of the token pool\n *\n * @returns The token pool pda\n */\n static deriveTokenPoolPda(mint: PublicKey): PublicKey {\n const seeds = [POOL_SEED, mint.toBuffer()];\n const [address, _] = PublicKey.findProgramAddressSync(\n seeds,\n this.programId,\n );\n return address;\n }\n\n /**\n * Find the index and bump for a given token pool pda and mint.\n *\n * @param poolPda The token pool pda to find the index and bump for\n * @param mint The mint of the token pool\n *\n * @returns The index and bump number.\n */\n static findTokenPoolIndexAndBump(\n poolPda: PublicKey,\n mint: PublicKey,\n ): [number, number] {\n for (let index = 0; index < 5; index++) {\n const derivedPda =\n CompressedTokenProgram.deriveTokenPoolPdaWithIndex(mint, index);\n if (derivedPda[0].equals(poolPda)) {\n return [index, derivedPda[1]];\n }\n }\n throw new Error('Token pool not found');\n }\n\n /**\n * Derive the token pool pda with index.\n *\n * @param mint The mint of the token pool\n * @param index Index. starts at 0. The Protocol supports 4 indexes aka token pools\n * per mint.\n *\n * @returns The token pool pda and bump.\n */\n static deriveTokenPoolPdaWithIndex(\n mint: PublicKey,\n index: number,\n ): [PublicKey, number] {\n let seeds: Buffer[] = [];\n if (index === 0) {\n seeds = [Buffer.from('pool'), mint.toBuffer(), Buffer.from([])]; // legacy, 1st\n } else {\n seeds = [\n Buffer.from('pool'),\n mint.toBuffer(),\n Buffer.from([index]),\n ];\n }\n const [address, bump] = PublicKey.findProgramAddressSync(\n seeds,\n this.programId,\n );\n return [address, bump];\n }\n\n /** @internal */\n static get deriveCpiAuthorityPda(): PublicKey {\n const [address, _] = PublicKey.findProgramAddressSync(\n [CPI_AUTHORITY_SEED],\n this.programId,\n );\n return address;\n }\n\n /**\n * Construct createMint instruction for compressed tokens.\n *\n * @param feePayer Fee payer.\n * @param mint SPL Mint address.\n * @param authority Mint authority.\n * @param freezeAuthority Optional: freeze authority.\n * @param decimals Decimals.\n * @param rentExemptBalance Lamport amount for mint account rent exemption.\n * @param tokenProgramId Optional: Token program ID. Default: SPL Token Program ID\n * @param mintSize Optional: mint size. Default: MINT_SIZE\n *\n * @returns [createMintAccountInstruction, initializeMintInstruction,\n * createTokenPoolInstruction]\n *\n * Note that `createTokenPoolInstruction` must be executed after\n * `initializeMintInstruction`.\n */\n static async createMint({\n feePayer,\n mint,\n authority,\n freezeAuthority,\n decimals,\n rentExemptBalance,\n tokenProgramId,\n mintSize,\n }: CreateMintParams): Promise<TransactionInstruction[]> {\n const tokenProgram = tokenProgramId ?? TOKEN_PROGRAM_ID;\n\n /// Create and initialize SPL Mint account\n const createMintAccountInstruction = SystemProgram.createAccount({\n fromPubkey: feePayer,\n lamports: rentExemptBalance,\n newAccountPubkey: mint,\n programId: tokenProgram,\n space: mintSize ?? MINT_SIZE,\n });\n\n const initializeMintInstruction = createInitializeMint2Instruction(\n mint,\n decimals,\n authority,\n freezeAuthority,\n tokenProgram,\n );\n\n const createTokenPoolInstruction = await this.createTokenPool({\n feePayer,\n mint,\n tokenProgramId: tokenProgram,\n });\n\n return [\n createMintAccountInstruction,\n initializeMintInstruction,\n createTokenPoolInstruction,\n ];\n }\n\n /**\n * Enable compression for an existing SPL mint, creating an omnibus account.\n * For new mints, use `CompressedTokenProgram.createMint`.\n *\n * @param feePayer Fee payer.\n * @param mint SPL Mint address.\n * @param tokenProgramId Optional: Token program ID. Default: SPL\n * Token Program ID\n *\n * @returns The createTokenPool instruction\n */\n static async createTokenPool({\n feePayer,\n mint,\n tokenProgramId,\n }: CreateTokenPoolParams): Promise<TransactionInstruction> {\n const tokenProgram = tokenProgramId ?? TOKEN_PROGRAM_ID;\n\n const tokenPoolPda = this.deriveTokenPoolPdaWithIndex(mint, 0);\n\n const keys = createTokenPoolAccountsLayout({\n mint,\n feePayer,\n tokenPoolPda: tokenPoolPda[0],\n tokenProgram,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n systemProgram: SystemProgram.programId,\n });\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data: CREATE_TOKEN_POOL_DISCRIMINATOR,\n });\n }\n\n /**\n * Add a token pool to an existing SPL mint. For new mints, use\n * {@link createTokenPool}.\n *\n * @param feePayer Fee payer.\n * @param mint SPL Mint address.\n * @param poolIndex Pool index.\n * @param tokenProgramId Optional: Token program ID. Default: SPL\n * Token Program ID\n *\n * @returns The addTokenPool instruction\n */\n static async addTokenPool({\n feePayer,\n mint,\n poolIndex,\n tokenProgramId,\n }: AddTokenPoolParams): Promise<TransactionInstruction> {\n if (poolIndex <= 0) {\n throw new Error(\n 'Pool index must be greater than 0. For 0, use CreateTokenPool instead.',\n );\n }\n if (poolIndex > 3) {\n throw new Error(\n `Invalid poolIndex ${poolIndex}. Max 4 pools per mint.`,\n );\n }\n\n const tokenProgram = tokenProgramId ?? TOKEN_PROGRAM_ID;\n\n const existingTokenPoolPda = this.deriveTokenPoolPdaWithIndex(\n mint,\n poolIndex - 1,\n );\n const tokenPoolPda = this.deriveTokenPoolPdaWithIndex(mint, poolIndex);\n\n const keys = addTokenPoolAccountsLayout({\n mint,\n feePayer,\n tokenPoolPda: tokenPoolPda[0],\n existingTokenPoolPda: existingTokenPoolPda[0],\n tokenProgram,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n systemProgram: SystemProgram.programId,\n });\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data: Buffer.concat([\n new Uint8Array(ADD_TOKEN_POOL_DISCRIMINATOR),\n new Uint8Array(Buffer.from([poolIndex])),\n ]),\n });\n }\n\n /**\n * Construct mintTo instruction for compressed tokens\n *\n * @param feePayer Fee payer.\n * @param mint SPL Mint address.\n * @param authority Mint authority.\n * @param toPubkey Recipient owner address.\n * @param amount Amount of tokens to mint.\n * @param outputStateTreeInfo State tree to write to.\n * @param tokenPoolInfo Token pool info.\n *\n * @returns The mintTo instruction\n */\n static async mintTo({\n feePayer,\n mint,\n authority,\n toPubkey,\n amount,\n outputStateTreeInfo,\n tokenPoolInfo,\n }: MintToParams): Promise<TransactionInstruction> {\n const systemKeys = defaultStaticAccountsStruct();\n const tokenProgram = tokenPoolInfo.tokenProgram;\n checkTokenPoolInfo(tokenPoolInfo, mint);\n\n const amounts = toArray<BN | number>(amount).map(amount => bn(amount));\n const toPubkeys = toArray(toPubkey);\n\n if (amounts.length !== toPubkeys.length) {\n throw new Error(\n 'Amount and toPubkey arrays must have the same length',\n );\n }\n\n const keys = mintToAccountsLayout({\n mint,\n feePayer,\n authority,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n tokenProgram,\n tokenPoolPda: tokenPoolInfo.tokenPoolPda,\n lightSystemProgram: LightSystemProgram.programId,\n registeredProgramPda: systemKeys.registeredProgramPda,\n noopProgram: systemKeys.noopProgram,\n accountCompressionAuthority: systemKeys.accountCompressionAuthority,\n accountCompressionProgram: systemKeys.accountCompressionProgram,\n merkleTree:\n outputStateTreeInfo.treeType === TreeType.StateV2\n ? outputStateTreeInfo.queue\n : outputStateTreeInfo.tree,\n selfProgram: this.programId,\n systemProgram: SystemProgram.programId,\n solPoolPda: null,\n });\n\n const data = encodeMintToInstructionData({\n recipients: toPubkeys,\n amounts,\n lamports: null,\n });\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n }\n\n /**\n * Mint tokens from registered SPL mint account to a compressed account\n *\n * @param feePayer Fee payer.\n * @param mint SPL Mint address.\n * @param authority Mint authority.\n * @param authorityTokenAccount The mint authority's associated token\n * account (ATA).\n * @param toPubkey Recipient owner address.\n * @param amount Amount of tokens to mint.\n * @param outputStateTreeInfo State tree to write to.\n * @param tokenPoolInfo Token pool info.\n *\n * @returns The mintTo instruction\n */\n static async approveAndMintTo({\n feePayer,\n mint,\n authority,\n authorityTokenAccount,\n toPubkey,\n amount,\n outputStateTreeInfo,\n tokenPoolInfo,\n }: ApproveAndMintToParams) {\n const amountBigInt: bigint = BigInt(amount.toString());\n\n /// 1. Mint to existing ATA of mintAuthority.\n const splMintToInstruction = createMintToInstruction(\n mint,\n authorityTokenAccount,\n authority,\n amountBigInt,\n [],\n tokenPoolInfo.tokenProgram,\n );\n\n /// 2. Compress from mint authority ATA to recipient compressed account\n const compressInstruction = await this.compress({\n payer: feePayer,\n owner: authority,\n source: authorityTokenAccount,\n toAddress: toPubkey,\n mint,\n amount,\n outputStateTreeInfo,\n tokenPoolInfo,\n });\n\n return [splMintToInstruction, compressInstruction];\n }\n\n /**\n * Construct transfer instruction for compressed tokens\n *\n * @param payer Fee payer.\n * @param inputCompressedTokenAccounts Source compressed token accounts.\n * @param toAddress Recipient owner address.\n * @param amount Amount of tokens to transfer.\n * @param recentValidityProof Recent validity proof.\n * @param recentInputStateRootIndices Recent state root indices.\n *\n * @returns The transfer instruction\n */\n static async transfer({\n payer,\n inputCompressedTokenAccounts,\n toAddress,\n amount,\n recentValidityProof,\n recentInputStateRootIndices,\n }: TransferParams): Promise<TransactionInstruction> {\n const tokenTransferOutputs: TokenTransferOutputData[] =\n createTransferOutputState(\n inputCompressedTokenAccounts,\n toAddress,\n amount,\n );\n\n const {\n inputTokenDataWithContext,\n packedOutputTokenData,\n remainingAccountMetas,\n } = packCompressedTokenAccounts({\n inputCompressedTokenAccounts,\n rootIndices: recentInputStateRootIndices,\n tokenTransferOutputs,\n });\n\n const { mint } = parseTokenData(inputCompressedTokenAccounts);\n\n const { delegatedTransfer, authority } = parseMaybeDelegatedTransfer(\n inputCompressedTokenAccounts,\n tokenTransferOutputs,\n );\n\n const rawData: CompressedTokenInstructionDataTransfer = {\n proof: recentValidityProof,\n mint,\n delegatedTransfer,\n inputTokenDataWithContext,\n outputCompressedAccounts: packedOutputTokenData,\n compressOrDecompressAmount: null,\n isCompress: false,\n cpiContext: null,\n lamportsChangeAccountMerkleTreeIndex: null,\n };\n const data = encodeTransferInstructionData(rawData);\n\n const {\n accountCompressionAuthority,\n noopProgram,\n registeredProgramPda,\n accountCompressionProgram,\n } = defaultStaticAccountsStruct();\n const keys = transferAccountsLayout({\n feePayer: payer,\n authority,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n lightSystemProgram: LightSystemProgram.programId,\n registeredProgramPda: registeredProgramPda,\n noopProgram: noopProgram,\n accountCompressionAuthority: accountCompressionAuthority,\n accountCompressionProgram: accountCompressionProgram,\n selfProgram: this.programId,\n tokenPoolPda: undefined,\n compressOrDecompressTokenAccount: undefined,\n tokenProgram: undefined,\n systemProgram: SystemProgram.programId,\n });\n\n keys.push(...remainingAccountMetas);\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n }\n\n /**\n * Create lookup table instructions for the token program's default\n * accounts.\n *\n * @param payer Fee payer.\n * @param authority Authority.\n * @param mints Mints.\n * @param recentSlot Recent slot.\n * @param remainingAccounts Remaining accounts.\n *\n * @returns [createInstruction, extendInstruction, option(extendInstruction2)]\n */\n static async createTokenProgramLookupTable({\n payer,\n authority,\n mints,\n recentSlot,\n remainingAccounts,\n }: CreateTokenProgramLookupTableParams) {\n // Gather all keys into a single deduped array before creating instructions\n let allKeys: PublicKey[] = [\n SystemProgram.programId,\n ComputeBudgetProgram.programId,\n this.deriveCpiAuthorityPda,\n LightSystemProgram.programId,\n CompressedTokenProgram.programId,\n defaultStaticAccountsStruct().registeredProgramPda,\n defaultStaticAccountsStruct().noopProgram,\n defaultStaticAccountsStruct().accountCompressionAuthority,\n defaultStaticAccountsStruct().accountCompressionProgram,\n defaultTestStateTreeAccounts().merkleTree,\n defaultTestStateTreeAccounts().nullifierQueue,\n defaultTestStateTreeAccounts().addressTree,\n defaultTestStateTreeAccounts().addressQueue,\n this.programId,\n TOKEN_PROGRAM_ID,\n TOKEN_2022_PROGRAM_ID,\n authority,\n ];\n\n if (mints) {\n allKeys.push(\n ...mints,\n ...mints.map(mint => this.deriveTokenPoolPda(mint)),\n );\n }\n\n if (remainingAccounts && remainingAccounts.length > 0) {\n allKeys.push(...remainingAccounts);\n }\n\n // Deduplicate keys\n const seen = new Set<string>();\n const dedupedKeys = allKeys.filter(key => {\n const keyStr = key.toBase58();\n if (seen.has(keyStr)) return false;\n seen.add(keyStr);\n return true;\n });\n\n const [createInstruction, lookupTableAddress] =\n AddressLookupTableProgram.createLookupTable({\n authority,\n payer: authority,\n recentSlot,\n });\n\n const instructions = [createInstruction];\n\n // Add up to 25 keys per extend instruction\n for (let i = 0; i < dedupedKeys.length; i += 25) {\n const chunk = dedupedKeys.slice(i, i + 25);\n const extendIx = AddressLookupTableProgram.extendLookupTable({\n payer,\n authority,\n lookupTable: lookupTableAddress,\n addresses: chunk,\n });\n instructions.push(extendIx);\n }\n\n return {\n instructions,\n address: lookupTableAddress,\n };\n }\n\n /**\n * Create compress instruction\n *\n * @param payer Fee payer.\n * @param owner Owner of uncompressed token account.\n * @param source Source SPL Token account address.\n * @param toAddress Recipient owner address(es).\n * @param amount Amount of tokens to compress.\n * @param mint SPL Token mint address.\n * @param outputStateTreeInfo State tree to write to.\n * @param tokenPoolInfo Token pool info.\n *\n * @returns The compress instruction\n */\n static async compress({\n payer,\n owner,\n source,\n toAddress,\n amount,\n mint,\n outputStateTreeInfo,\n tokenPoolInfo,\n }: CompressParams): Promise<TransactionInstruction> {\n let tokenTransferOutputs: TokenTransferOutputData[];\n\n const amountArray = toArray<BN | number>(amount);\n const toAddressArray = toArray(toAddress);\n\n checkTokenPoolInfo(tokenPoolInfo, mint);\n\n if (amountArray.length !== toAddressArray.length) {\n throw new Error(\n 'Amount and toAddress arrays must have the same length',\n );\n }\n if (featureFlags.isV2()) {\n const [index, bump] = this.findTokenPoolIndexAndBump(\n tokenPoolInfo.tokenPoolPda,\n mint,\n );\n const rawData: BatchCompressInstructionData = {\n pubkeys: toAddressArray,\n amounts:\n amountArray.length > 1\n ? amountArray.map(amt => bn(amt))\n : null,\n lamports: null,\n amount: amountArray.length === 1 ? bn(amountArray[0]) : null,\n index,\n bump,\n };\n\n const data = encodeBatchCompressInstructionData(rawData);\n const keys = mintToAccountsLayout({\n mint,\n feePayer: payer,\n authority: owner,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n tokenProgram: tokenPoolInfo.tokenProgram,\n tokenPoolPda: tokenPoolInfo.tokenPoolPda,\n lightSystemProgram: LightSystemProgram.programId,\n ...defaultStaticAccountsStruct(),\n merkleTree: outputStateTreeInfo.queue,\n selfProgram: this.programId,\n systemProgram: SystemProgram.programId,\n solPoolPda: null,\n });\n keys.push({\n pubkey: source,\n isWritable: true,\n isSigner: false,\n });\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n } else {\n tokenTransferOutputs = amountArray.map((amt, index) => {\n const amountBN = bn(amt);\n return {\n owner: toAddressArray[index],\n amount: amountBN,\n lamports: null,\n tlv: null,\n };\n });\n\n const {\n inputTokenDataWithContext,\n packedOutputTokenData,\n remainingAccountMetas,\n } = packCompressedTokenAccounts({\n inputCompressedTokenAccounts: [],\n outputStateTreeInfo,\n rootIndices: [],\n tokenTransferOutputs,\n });\n\n const rawData: CompressedTokenInstructionDataTransfer = {\n proof: null,\n mint,\n delegatedTransfer: null,\n inputTokenDataWithContext,\n outputCompressedAccounts: packedOutputTokenData,\n compressOrDecompressAmount: Array.isArray(amount)\n ? amount\n .map(amt => bn(amt))\n .reduce((sum, amt) => sum.add(amt), bn(0))\n : bn(amount),\n isCompress: true,\n cpiContext: null,\n lamportsChangeAccountMerkleTreeIndex: null,\n };\n const data = encodeTransferInstructionData(rawData);\n const keys = transferAccountsLayout({\n ...defaultStaticAccountsStruct(),\n feePayer: payer,\n authority: owner,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n lightSystemProgram: LightSystemProgram.programId,\n selfProgram: this.programId,\n systemProgram: SystemProgram.programId,\n tokenPoolPda: tokenPoolInfo.tokenPoolPda,\n compressOrDecompressTokenAccount: source,\n tokenProgram: tokenPoolInfo.tokenProgram,\n });\n keys.push(...remainingAccountMetas);\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n }\n }\n\n /**\n * Construct decompress instruction\n *\n * @param payer Fee payer.\n * @param inputCompressedTokenAccounts Source compressed token accounts.\n * @param toAddress Destination **uncompressed** token\n * account address. (ATA)\n * @param amount Amount of tokens to decompress.\n * @param recentValidityProof Recent validity proof.\n * @param recentInputStateRootIndices Recent state root indices.\n * @param tokenPoolInfos Token pool info.\n *\n * @returns The decompress instruction\n */\n static async decompress({\n payer,\n inputCompressedTokenAccounts,\n toAddress,\n amount,\n recentValidityProof,\n recentInputStateRootIndices,\n tokenPoolInfos,\n }: DecompressParams): Promise<TransactionInstruction> {\n const amountBN = bn(amount);\n const tokenPoolInfosArray = toArray(tokenPoolInfos);\n\n const tokenTransferOutputs = createDecompressOutputState(\n inputCompressedTokenAccounts,\n amountBN,\n );\n\n /// Pack\n const {\n inputTokenDataWithContext,\n packedOutputTokenData,\n remainingAccountMetas,\n } = packCompressedTokenAccounts({\n inputCompressedTokenAccounts,\n rootIndices: recentInputStateRootIndices,\n tokenTransferOutputs: tokenTransferOutputs,\n remainingAccounts: tokenPoolInfosArray\n .slice(1)\n .map(info => info.tokenPoolPda),\n });\n\n const { mint } = parseTokenData(inputCompressedTokenAccounts);\n const { delegatedTransfer, authority } = parseMaybeDelegatedTransfer(\n inputCompressedTokenAccounts,\n tokenTransferOutputs,\n );\n\n const rawData: CompressedTokenInstructionDataTransfer = {\n proof: recentValidityProof,\n mint,\n delegatedTransfer,\n inputTokenDataWithContext,\n outputCompressedAccounts: packedOutputTokenData,\n compressOrDecompressAmount: amountBN,\n isCompress: false,\n cpiContext: null,\n lamportsChangeAccountMerkleTreeIndex: null,\n };\n const data = encodeTransferInstructionData(rawData);\n const tokenProgram = tokenPoolInfosArray[0].tokenProgram;\n\n const {\n accountCompressionAuthority,\n noopProgram,\n registeredProgramPda,\n accountCompressionProgram,\n } = defaultStaticAccountsStruct();\n\n const keys = transferAccountsLayout({\n feePayer: payer,\n authority: authority,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n lightSystemProgram: LightSystemProgram.programId,\n registeredProgramPda: registeredProgramPda,\n noopProgram: noopProgram,\n accountCompressionAuthority: accountCompressionAuthority,\n accountCompressionProgram: accountCompressionProgram,\n selfProgram: this.programId,\n tokenPoolPda: tokenPoolInfosArray[0].tokenPoolPda,\n compressOrDecompressTokenAccount: toAddress,\n tokenProgram,\n systemProgram: SystemProgram.programId,\n });\n keys.push(...remainingAccountMetas);\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n }\n\n /**\n * Create `mergeTokenAccounts` instruction\n *\n * @param payer Fee payer.\n * @param owner Owner of the compressed token\n * accounts to be merged.\n * @param inputCompressedTokenAccounts Source compressed token accounts.\n * @param mint SPL Token mint address.\n * @param recentValidityProof Recent validity proof.\n * @param recentInputStateRootIndices Recent state root indices.\n *\n * @returns instruction\n */\n static async mergeTokenAccounts({\n payer,\n owner,\n inputCompressedTokenAccounts,\n mint,\n recentValidityProof,\n recentInputStateRootIndices,\n }: MergeTokenAccountsParams): Promise<TransactionInstruction[]> {\n if (inputCompressedTokenAccounts.length > 4) {\n throw new Error('Cannot merge more than 4 token accounts at once');\n }\n\n checkMint(inputCompressedTokenAccounts, mint);\n\n const ix = await this.transfer({\n payer,\n inputCompressedTokenAccounts,\n toAddress: owner,\n amount: inputCompressedTokenAccounts.reduce(\n (sum, account) => sum.add(account.parsed.amount),\n bn(0),\n ),\n recentInputStateRootIndices,\n recentValidityProof,\n });\n\n return [ix];\n }\n\n /**\n * Create `compressSplTokenAccount` instruction\n *\n * @param feePayer Fee payer.\n * @param authority SPL Token account owner.\n * @param tokenAccount SPL Token account to compress.\n * @param mint SPL Token mint address.\n * @param remainingAmount Optional: Amount to leave in token account.\n * @param outputStateTreeInfo State tree to write to.\n * @param tokenPoolInfo Token pool info.\n *\n * @returns instruction\n */\n static async compressSplTokenAccount({\n feePayer,\n authority,\n tokenAccount,\n mint,\n remainingAmount,\n outputStateTreeInfo,\n tokenPoolInfo,\n }: CompressSplTokenAccountParams): Promise<TransactionInstruction> {\n checkTokenPoolInfo(tokenPoolInfo, mint);\n const remainingAccountMetas: AccountMeta[] = [\n {\n pubkey:\n outputStateTreeInfo.treeType === TreeType.StateV2\n ? outputStateTreeInfo.queue\n : outputStateTreeInfo.tree,\n isSigner: false,\n isWritable: true,\n },\n ];\n\n const data = encodeCompressSplTokenAccountInstructionData({\n owner: authority,\n remainingAmount: remainingAmount ?? null,\n cpiContext: null,\n });\n const {\n accountCompressionAuthority,\n noopProgram,\n registeredProgramPda,\n accountCompressionProgram,\n } = defaultStaticAccountsStruct();\n\n const keys = transferAccountsLayout({\n feePayer,\n authority,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n lightSystemProgram: LightSystemProgram.programId,\n registeredProgramPda: registeredProgramPda,\n noopProgram: noopProgram,\n accountCompressionAuthority: accountCompressionAuthority,\n accountCompressionProgram: accountCompressionProgram,\n selfProgram: this.programId,\n tokenPoolPda: tokenPoolInfo.tokenPoolPda,\n compressOrDecompressTokenAccount: tokenAccount,\n tokenProgram: tokenPoolInfo.tokenProgram,\n systemProgram: SystemProgram.programId,\n });\n\n keys.push(...remainingAccountMetas);\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n }\n\n /**\n * Get the program ID for a mint\n *\n * @param mint SPL Token mint address.\n * @param connection Connection.\n *\n * @returns program ID\n */\n static async getMintProgramId(\n mint: PublicKey,\n connection: Connection,\n ): Promise<PublicKey | undefined> {\n return (await connection.getAccountInfo(mint))?.owner;\n }\n\n /**\n * Create `approve` instruction to delegate compressed tokens.\n *\n * @param payer Fee payer.\n * @param inputCompressedTokenAccounts Source compressed token accounts.\n * @param toAddress Owner to delegate to.\n * @param amount Amount of tokens to delegate.\n * @param recentValidityProof Recent validity proof.\n * @param recentInputStateRootIndices Recent state root indices.\n *\n * @returns instruction\n */\n static async approve({\n payer,\n inputCompressedTokenAccounts,\n toAddress,\n amount,\n recentValidityProof,\n recentInputStateRootIndices,\n }: ApproveParams): Promise<TransactionInstruction> {\n const { inputTokenDataWithContext, remainingAccountMetas } =\n packCompressedTokenAccounts({\n inputCompressedTokenAccounts,\n rootIndices: recentInputStateRootIndices,\n tokenTransferOutputs: [],\n });\n\n const { mint, currentOwner } = parseTokenData(\n inputCompressedTokenAccounts,\n );\n\n const CHANGE_INDEX =\n inputCompressedTokenAccounts[0].compressedAccount.treeInfo\n .treeType === TreeType.StateV2\n ? 1\n : 0;\n\n const rawData: CompressedTokenInstructionDataApprove = {\n proof: recentValidityProof,\n mint,\n inputTokenDataWithContext,\n cpiContext: null,\n delegate: toAddress,\n delegatedAmount: bn(amount),\n delegateMerkleTreeIndex: CHANGE_INDEX,\n changeAccountMerkleTreeIndex: CHANGE_INDEX,\n delegateLamports: null,\n };\n\n const data = encodeApproveInstructionData(rawData);\n\n const {\n accountCompressionAuthority,\n noopProgram,\n registeredProgramPda,\n accountCompressionProgram,\n } = defaultStaticAccountsStruct();\n\n const keys = approveAccountsLayout({\n feePayer: payer,\n authority: currentOwner,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n lightSystemProgram: LightSystemProgram.programId,\n registeredProgramPda: registeredProgramPda,\n noopProgram: noopProgram,\n accountCompressionAuthority: accountCompressionAuthority,\n accountCompressionProgram: accountCompressionProgram,\n selfProgram: this.programId,\n systemProgram: SystemProgram.programId,\n });\n\n keys.push(...remainingAccountMetas);\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n }\n\n /**\n * Create `revoke` instruction to revoke delegation of compressed tokens.\n *\n * @param payer Fee payer.\n * @param inputCompressedTokenAccounts Source compressed token accounts.\n * @param recentValidityProof Recent validity proof.\n * @param recentInputStateRootIndices Recent state root indices.\n *\n * @returns instruction\n */\n static async revoke({\n payer,\n inputCompressedTokenAccounts,\n recentValidityProof,\n recentInputStateRootIndices,\n }: RevokeParams): Promise<TransactionInstruction> {\n validateSameTokenOwner(inputCompressedTokenAccounts);\n\n const { inputTokenDataWithContext, remainingAccountMetas } =\n packCompressedTokenAccounts({\n inputCompressedTokenAccounts,\n rootIndices: recentInputStateRootIndices,\n tokenTransferOutputs: [],\n });\n\n const { mint, currentOwner } = parseTokenData(\n inputCompressedTokenAccounts,\n );\n\n const rawData: CompressedTokenInstructionDataRevoke = {\n proof: recentValidityProof,\n mint,\n inputTokenDataWithContext,\n cpiContext: null,\n outputAccountMerkleTreeIndex:\n inputCompressedTokenAccounts[0].compressedAccount.treeInfo\n .treeType === TreeType.StateV2\n ? 2\n : 1,\n };\n const data = encodeRevokeInstructionData(rawData);\n\n const {\n accountCompressionAuthority,\n noopProgram,\n registeredProgramPda,\n accountCompressionProgram,\n } = defaultStaticAccountsStruct();\n const keys = revokeAccountsLayout({\n feePayer: payer,\n authority: currentOwner,\n cpiAuthorityPda: this.deriveCpiAuthorityPda,\n lightSystemProgram: LightSystemProgram.programId,\n registeredProgramPda: registeredProgramPda,\n noopProgram: noopProgram,\n accountCompressionAuthority: accountCompressionAuthority,\n accountCompressionProgram: accountCompressionProgram,\n selfProgram: this.programId,\n systemProgram: SystemProgram.programId,\n });\n\n keys.push(...remainingAccountMetas);\n\n return new TransactionInstruction({\n programId: this.programId,\n keys,\n data,\n });\n }\n}\n","import {\n COMPRESSED_TOKEN_PROGRAM_ID,\n deriveAddressV2,\n TreeInfo,\n} from '@lightprotocol/stateless.js';\nimport { PublicKey } from '@solana/web3.js';\n\n/**\n * Returns the compressed mint address as a Array (32 bytes).\n */\nexport function deriveCompressedMintAddress(\n mintSeed: PublicKey,\n addressTreeInfo: TreeInfo,\n) {\n // find_spl_mint_address returns [splMint, bump], we want splMint\n // In JS, just use the mintSeed directly as the SPL mint address\n const address = deriveAddressV2(\n findMintAddress(mintSeed)[0].toBytes(),\n addressTreeInfo.tree.toBytes(),\n COMPRESSED_TOKEN_PROGRAM_ID.toBytes(),\n );\n return Array.from(address);\n}\n\n/// b\"compressed_mint\"\nexport const COMPRESSED_MINT_SEED = Buffer.from([\n 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 95, 109, 105, 110, 116,\n]);\n\n/**\n * Finds the SPL mint PDA for a compressed mint.\n * @param mintSeed The mint seed public key.\n * @returns [PDA, bump]\n */\nexport function findMintAddress(mintSigner: PublicKey): [PublicKey, number] {\n const [address, bump] = PublicKey.findProgramAddressSync(\n [COMPRESSED_MINT_SEED, mintSigner.toBuffer()],\n COMPRESSED_TOKEN_PROGRAM_ID,\n );\n return [address, bump];\n}\n\n/// Same as \"getAssociatedTokenAddress\" but returns the bump as well.\n/// Uses compressed token program ID.\nexport function getAssociatedCTokenAddressAndBump(\n owner: PublicKey,\n mint: PublicKey,\n) {\n return PublicKey.findProgramAddressSync(\n [\n owner.toBuffer(),\n COMPRESSED_TOKEN_PROGRAM_ID.toBuffer(),\n mint.toBuffer(),\n ],\n COMPRESSED_TOKEN_PROGRAM_ID,\n );\n}\n\n/// Same as \"getAssociatedTokenAddress\" but implicitly uses compressed token program ID.\nexport function getAssociatedCTokenAddress(owner: PublicKey, mint: PublicKey) {\n return PublicKey.findProgramAddressSync(\n [\n owner.toBuffer(),\n COMPRESSED_TOKEN_PROGRAM_ID.toBuffer(),\n mint.toBuffer(),\n ],\n COMPRESSED_TOKEN_PROGRAM_ID,\n )[0];\n}\n","export type LightCompressedToken = {\n version: '1.2.0';\n name: 'light_compressed_token';\n instructions: [\n {\n name: 'createTokenPool';\n docs: [\n 'This instruction creates a token pool for a given mint. Every spl mint',\n 'can have one token pool. When a token is compressed the tokens are',\n 'transferrred to the token pool, and their compressed equivalent is',\n 'minted into a Merkle tree.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'tokenPoolPda';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'mint';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'tokenProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [];\n },\n {\n name: 'addTokenPool';\n docs: [\n 'This instruction creates an additional token pool for a given mint.',\n 'The maximum number of token pools per mint is 5.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'tokenPoolPda';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'existingTokenPoolPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'mint';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'tokenProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'tokenPoolIndex';\n type: 'u8';\n },\n ];\n },\n {\n name: 'mintTo';\n docs: [\n 'Mints tokens from an spl token mint to a list of compressed accounts.',\n 'Minted tokens are transferred to a pool account owned by the compressed',\n 'token program. The instruction creates one compressed output account for',\n 'every amount and pubkey input pair. A constant amount of lamports can be',\n 'transferred to each output account to enable. A use case to add lamports',\n 'to a compressed token account is to prevent spam. This is the only way',\n 'to add lamports to a compressed token account.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'mint';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'tokenPoolPda';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'tokenProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n docs: ['programs'];\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'merkleTree';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'solPoolPda';\n isMut: true;\n isSigner: false;\n isOptional: true;\n },\n ];\n args: [\n {\n name: 'publicKeys';\n type: {\n vec: 'publicKey';\n };\n },\n {\n name: 'amounts';\n type: {\n vec: 'u64';\n };\n },\n {\n name: 'lamports';\n type: {\n option: 'u64';\n };\n },\n ];\n },\n {\n name: 'compressSplTokenAccount';\n docs: [\n 'Compresses the balance of an spl token account sub an optional remaining',\n 'amount. This instruction does not close the spl token account. To close',\n 'the account bundle a close spl account instruction in your transaction.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ];\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n docs: ['this program is the signer of the cpi.'];\n },\n {\n name: 'tokenPoolPda';\n isMut: true;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'compressOrDecompressTokenAccount';\n isMut: true;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'tokenProgram';\n isMut: false;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'owner';\n type: 'publicKey';\n },\n {\n name: 'remainingAmount';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'cpiContext';\n type: {\n option: {\n defined: 'CompressedCpiContext';\n };\n };\n },\n ];\n },\n {\n name: 'transfer';\n docs: [\n 'Transfers compressed tokens from one account to another. All accounts',\n 'must be of the same mint. Additional spl tokens can be compressed or',\n 'decompressed. In one transaction only compression or decompression is',\n 'possible. Lamports can be transferred alongside tokens. If output token',\n 'accounts specify less lamports than inputs the remaining lamports are',\n 'transferred to an output compressed account. Signer must be owner or',\n 'delegate. If a delegated token account is transferred the delegate is',\n 'not preserved.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ];\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n docs: ['this program is the signer of the cpi.'];\n },\n {\n name: 'tokenPoolPda';\n isMut: true;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'compressOrDecompressTokenAccount';\n isMut: true;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'tokenProgram';\n isMut: false;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'inputs';\n type: 'bytes';\n },\n ];\n },\n {\n name: 'approve';\n docs: [\n 'Delegates an amount to a delegate. A compressed token account is either',\n 'completely delegated or not. Prior delegates are not preserved. Cannot',\n 'be called by a delegate.',\n 'The instruction creates two output accounts:',\n '1. one account with delegated amount',\n '2. one account with remaining(change) amount',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ];\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n docs: ['this program is the signer of the cpi.'];\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'inputs';\n type: 'bytes';\n },\n ];\n },\n {\n name: 'revoke';\n docs: [\n 'Revokes a delegation. The instruction merges all inputs into one output',\n 'account. Cannot be called by a delegate. Delegates are not preserved.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ];\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n docs: ['this program is the signer of the cpi.'];\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'inputs';\n type: 'bytes';\n },\n ];\n },\n {\n name: 'freeze';\n docs: [\n 'Freezes compressed token accounts. Inputs must not be frozen. Creates as',\n 'many outputs as inputs. Balances and delegates are preserved.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n docs: ['that this program is the signer of the cpi.'];\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'mint';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'inputs';\n type: 'bytes';\n },\n ];\n },\n {\n name: 'thaw';\n docs: [\n 'Thaws frozen compressed token accounts. Inputs must be frozen. Creates',\n 'as many outputs as inputs. Balances and delegates are preserved.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n docs: ['that this program is the signer of the cpi.'];\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'mint';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'inputs';\n type: 'bytes';\n },\n ];\n },\n {\n name: 'burn';\n docs: [\n 'Burns compressed tokens and spl tokens from the pool account. Delegates',\n 'can burn tokens. The output compressed token account remains delegated.',\n 'Creates one output compressed token account.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ];\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'mint';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'tokenPoolPda';\n isMut: true;\n isSigner: false;\n },\n {\n name: 'tokenProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'inputs';\n type: 'bytes';\n },\n ];\n },\n {\n name: 'stubIdlBuild';\n docs: [\n 'This function is a stub to allow Anchor to include the input types in',\n 'the IDL. It should not be included in production builds nor be called in',\n 'practice.',\n ];\n accounts: [\n {\n name: 'feePayer';\n isMut: true;\n isSigner: true;\n docs: ['UNCHECKED: only pays fees.'];\n },\n {\n name: 'authority';\n isMut: false;\n isSigner: true;\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ];\n },\n {\n name: 'cpiAuthorityPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'lightSystemProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'registeredProgramPda';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'noopProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionAuthority';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'accountCompressionProgram';\n isMut: false;\n isSigner: false;\n },\n {\n name: 'selfProgram';\n isMut: false;\n isSigner: false;\n docs: ['this program is the signer of the cpi.'];\n },\n {\n name: 'tokenPoolPda';\n isMut: true;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'compressOrDecompressTokenAccount';\n isMut: true;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'tokenProgram';\n isMut: false;\n isSigner: false;\n isOptional: true;\n },\n {\n name: 'systemProgram';\n isMut: false;\n isSigner: false;\n },\n ];\n args: [\n {\n name: 'inputs1';\n type: {\n defined: 'CompressedTokenInstructionDataTransfer';\n };\n },\n {\n name: 'inputs2';\n type: {\n defined: 'TokenData';\n };\n },\n ];\n },\n ];\n types: [\n {\n name: 'AccountState';\n type: {\n kind: 'enum';\n variants: [\n {\n name: 'Initialized';\n },\n {\n name: 'Frozen';\n },\n ];\n };\n },\n {\n name: 'CompressedAccount';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'owner';\n type: 'publicKey';\n },\n {\n name: 'lamports';\n type: 'u64';\n },\n {\n name: 'address';\n type: {\n option: {\n array: ['u8', 32];\n };\n };\n },\n {\n name: 'data';\n type: {\n option: {\n defined: 'CompressedAccountData';\n };\n };\n },\n ];\n };\n },\n {\n name: 'CompressedAccountData';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'discriminator';\n type: {\n array: ['u8', 8];\n };\n },\n {\n name: 'data';\n type: 'bytes';\n },\n {\n name: 'dataHash';\n type: {\n array: ['u8', 32];\n };\n },\n ];\n };\n },\n {\n name: 'CompressedCpiContext';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'setContext';\n docs: [\n 'Is set by the program that is invoking the CPI to signal that is should',\n 'set the cpi context.',\n ];\n type: 'bool';\n },\n {\n name: 'firstSetContext';\n docs: [\n 'Is set to wipe the cpi context since someone could have set it before',\n 'with unrelated data.',\n ];\n type: 'bool';\n },\n {\n name: 'cpiContextAccountIndex';\n docs: [\n 'Index of cpi context account in remaining accounts.',\n ];\n type: 'u8';\n },\n ];\n };\n },\n {\n name: 'CompressedProof';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'a';\n type: {\n array: ['u8', 32];\n };\n },\n {\n name: 'b';\n type: {\n array: ['u8', 64];\n };\n },\n {\n name: 'c';\n type: {\n array: ['u8', 32];\n };\n },\n ];\n };\n },\n {\n name: 'CompressedTokenInstructionDataTransfer';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'proof';\n type: {\n option: {\n defined: 'CompressedProof';\n };\n };\n },\n {\n name: 'mint';\n type: 'publicKey';\n },\n {\n name: 'delegatedTransfer';\n docs: [\n 'Is required if the signer is delegate,',\n '-> delegate is authority account,',\n 'owner = Some(owner) is the owner of the token account.',\n ];\n type: {\n option: {\n defined: 'DelegatedTransfer';\n };\n };\n },\n {\n name: 'inputTokenDataWithContext';\n type: {\n vec: {\n defined: 'InputTokenDataWithContext';\n };\n };\n },\n {\n name: 'outputCompressedAccounts';\n type: {\n vec: {\n defined: 'PackedTokenTransferOutputData';\n };\n };\n },\n {\n name: 'isCompress';\n type: 'bool';\n },\n {\n name: 'compressOrDecompressAmount';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'cpiContext';\n type: {\n option: {\n defined: 'CompressedCpiContext';\n };\n };\n },\n {\n name: 'lamportsChangeAccountMerkleTreeIndex';\n type: {\n option: 'u8';\n };\n },\n ];\n };\n },\n {\n name: 'CompressedTokenInstructionDataRevoke';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'proof';\n type: {\n option: {\n defined: 'CompressedProof';\n };\n };\n },\n {\n name: 'mint';\n type: 'publicKey';\n },\n {\n name: 'inputTokenDataWithContext';\n type: {\n vec: {\n defined: 'InputTokenDataWithContext';\n };\n };\n },\n {\n name: 'cpiContext';\n type: {\n option: {\n defined: 'CompressedCpiContext';\n };\n };\n },\n {\n name: 'outputAccountMerkleTreeIndex';\n type: 'u8';\n },\n ];\n };\n },\n {\n name: 'CompressedTokenInstructionDataApprove';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'proof';\n type: {\n option: {\n defined: 'CompressedProof';\n };\n };\n },\n {\n name: 'mint';\n type: 'publicKey';\n },\n {\n name: 'inputTokenDataWithContext';\n type: {\n vec: {\n defined: 'InputTokenDataWithContext';\n };\n };\n },\n {\n name: 'cpiContext';\n type: {\n option: {\n defined: 'CompressedCpiContext';\n };\n };\n },\n {\n name: 'delegate';\n type: 'publicKey';\n },\n {\n name: 'delegatedAmount';\n type: 'u64';\n },\n {\n name: 'delegateMerkleTreeIndex';\n type: 'u8';\n },\n {\n name: 'changeAccountMerkleTreeIndex';\n type: 'u8';\n },\n {\n name: 'delegateLamports';\n type: {\n option: 'u64';\n };\n },\n ];\n };\n },\n {\n name: 'DelegatedTransfer';\n docs: [\n 'Struct to provide the owner when the delegate is signer of the transaction.',\n ];\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'owner';\n type: 'publicKey';\n },\n {\n name: 'delegateChangeAccountIndex';\n docs: [\n 'Index of change compressed account in output compressed accounts. In',\n \"case that the delegate didn't spend the complete delegated compressed\",\n 'account balance the change compressed account will be delegated to her',\n 'as well.',\n ];\n type: {\n option: 'u8';\n };\n },\n ];\n };\n },\n {\n name: 'InputTokenDataWithContext';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'amount';\n type: 'u64';\n },\n {\n name: 'delegateIndex';\n type: {\n option: 'u8';\n };\n },\n {\n name: 'merkleContext';\n type: {\n defined: 'PackedMerkleContext';\n };\n },\n {\n name: 'rootIndex';\n type: 'u16';\n },\n {\n name: 'lamports';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'tlv';\n docs: [\n 'Placeholder for TokenExtension tlv data (unimplemented)',\n ];\n type: {\n option: 'bytes';\n };\n },\n ];\n };\n },\n {\n name: 'InstructionDataInvoke';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'proof';\n type: {\n option: {\n defined: 'CompressedProof';\n };\n };\n },\n {\n name: 'inputCompressedAccountsWithMerkleContext';\n type: {\n vec: {\n defined: 'PackedCompressedAccountWithMerkleContext';\n };\n };\n },\n {\n name: 'outputCompressedAccounts';\n type: {\n vec: {\n defined: 'OutputCompressedAccountWithPackedContext';\n };\n };\n },\n {\n name: 'relayFee';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'newAddressParams';\n type: {\n vec: {\n defined: 'NewAddressParamsPacked';\n };\n };\n },\n {\n name: 'compressOrDecompressLamports';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'isCompress';\n type: 'bool';\n },\n ];\n };\n },\n {\n name: 'InstructionDataInvokeCpi';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'proof';\n type: {\n option: {\n defined: 'CompressedProof';\n };\n };\n },\n {\n name: 'newAddressParams';\n type: {\n vec: {\n defined: 'NewAddressParamsPacked';\n };\n };\n },\n {\n name: 'inputCompressedAccountsWithMerkleContext';\n type: {\n vec: {\n defined: 'PackedCompressedAccountWithMerkleContext';\n };\n };\n },\n {\n name: 'outputCompressedAccounts';\n type: {\n vec: {\n defined: 'OutputCompressedAccountWithPackedContext';\n };\n };\n },\n {\n name: 'relayFee';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'compressOrDecompressLamports';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'isCompress';\n type: 'bool';\n },\n {\n name: 'cpiContext';\n type: {\n option: {\n defined: 'CompressedCpiContext';\n };\n };\n },\n ];\n };\n },\n {\n name: 'MerkleTreeSequenceNumber';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'pubkey';\n type: 'publicKey';\n },\n {\n name: 'seq';\n type: 'u64';\n },\n ];\n };\n },\n {\n name: 'NewAddressParamsPacked';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'seed';\n type: {\n array: ['u8', 32];\n };\n },\n {\n name: 'addressQueueAccountIndex';\n type: 'u8';\n },\n {\n name: 'addressMerkleTreeAccountIndex';\n type: 'u8';\n },\n {\n name: 'addressMerkleTreeRootIndex';\n type: 'u16';\n },\n ];\n };\n },\n {\n name: 'OutputCompressedAccountWithPackedContext';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'compressedAccount';\n type: {\n defined: 'CompressedAccount';\n };\n },\n {\n name: 'merkleTreeIndex';\n type: 'u8';\n },\n ];\n };\n },\n {\n name: 'PackedCompressedAccountWithMerkleContext';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'compressedAccount';\n type: {\n defined: 'CompressedAccount';\n };\n },\n {\n name: 'merkleContext';\n type: {\n defined: 'PackedMerkleContext';\n };\n },\n {\n name: 'rootIndex';\n docs: [\n 'Index of root used in inclusion validity proof.',\n ];\n type: 'u16';\n },\n {\n name: 'readOnly';\n docs: [\n 'Placeholder to mark accounts read-only unimplemented set to false.',\n ];\n type: 'bool';\n },\n ];\n };\n },\n {\n name: 'PackedMerkleContext';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'merkleTreePubkeyIndex';\n type: 'u8';\n },\n {\n name: 'queuePubkeyIndex';\n type: 'u8';\n },\n {\n name: 'leafIndex';\n type: 'u32';\n },\n {\n name: 'proveByIndex';\n type: 'bool';\n },\n ];\n };\n },\n {\n name: 'PackedTokenTransferOutputData';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'owner';\n type: 'publicKey';\n },\n {\n name: 'amount';\n type: 'u64';\n },\n {\n name: 'lamports';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'merkleTreeIndex';\n type: 'u8';\n },\n {\n name: 'tlv';\n docs: [\n 'Placeholder for TokenExtension tlv data (unimplemented)',\n ];\n type: {\n option: 'bytes';\n };\n },\n ];\n };\n },\n {\n name: 'PublicTransactionEvent';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'inputCompressedAccountHashes';\n type: {\n vec: {\n array: ['u8', 32];\n };\n };\n },\n {\n name: 'outputCompressedAccountHashes';\n type: {\n vec: {\n array: ['u8', 32];\n };\n };\n },\n {\n name: 'outputCompressedAccounts';\n type: {\n vec: {\n defined: 'OutputCompressedAccountWithPackedContext';\n };\n };\n },\n {\n name: 'outputLeafIndices';\n type: {\n vec: 'u32';\n };\n },\n {\n name: 'sequenceNumbers';\n type: {\n vec: {\n defined: 'MerkleTreeSequenceNumber';\n };\n };\n },\n {\n name: 'relayFee';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'isCompress';\n type: 'bool';\n },\n {\n name: 'compressOrDecompressLamports';\n type: {\n option: 'u64';\n };\n },\n {\n name: 'pubkeyArray';\n type: {\n vec: 'publicKey';\n };\n },\n {\n name: 'message';\n type: {\n option: 'bytes';\n };\n },\n ];\n };\n },\n {\n name: 'QueueIndex';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'queueId';\n docs: ['Id of queue in queue account.'];\n type: 'u8';\n },\n {\n name: 'index';\n docs: ['Index of compressed account hash in queue.'];\n type: 'u16';\n },\n ];\n };\n },\n {\n name: 'TokenData';\n type: {\n kind: 'struct';\n fields: [\n {\n name: 'mint';\n docs: ['The mint associated with this account'];\n type: 'publicKey';\n },\n {\n name: 'owner';\n docs: ['The owner of this account.'];\n type: 'publicKey';\n },\n {\n name: 'amount';\n docs: ['The amount of tokens this account holds.'];\n type: 'u64';\n },\n {\n name: 'delegate';\n docs: [\n 'If `delegate` is `Some` then `delegated_amount` represents',\n 'the amount authorized by the delegate',\n ];\n type: {\n option: 'publicKey';\n };\n },\n {\n name: 'state';\n docs: [\"The account's state\"];\n type: {\n defined: 'AccountState';\n };\n },\n {\n name: 'tlv';\n docs: [\n 'Placeholder for TokenExtension tlv data (unimplemented)',\n ];\n type: {\n option: 'bytes';\n };\n },\n ];\n };\n },\n ];\n errors: [\n {\n code: 6000;\n name: 'PublicKeyAmountMissmatch';\n msg: 'public keys and amounts must be of same length';\n },\n {\n code: 6001;\n name: 'ComputeInputSumFailed';\n msg: 'ComputeInputSumFailed';\n },\n {\n code: 6002;\n name: 'ComputeOutputSumFailed';\n msg: 'ComputeOutputSumFailed';\n },\n {\n code: 6003;\n name: 'ComputeCompressSumFailed';\n msg: 'ComputeCompressSumFailed';\n },\n {\n code: 6004;\n name: 'ComputeDecompressSumFailed';\n msg: 'ComputeDecompressSumFailed';\n },\n {\n code: 6005;\n name: 'SumCheckFailed';\n msg: 'SumCheckFailed';\n },\n {\n code: 6006;\n name: 'DecompressRecipientUndefinedForDecompress';\n msg: 'DecompressRecipientUndefinedForDecompress';\n },\n {\n code: 6007;\n name: 'CompressedPdaUndefinedForDecompress';\n msg: 'CompressedPdaUndefinedForDecompress';\n },\n {\n code: 6008;\n name: 'DeCompressAmountUndefinedForDecompress';\n msg: 'DeCompressAmountUndefinedForDecompress';\n },\n {\n code: 6009;\n name: 'CompressedPdaUndefinedForCompress';\n msg: 'CompressedPdaUndefinedForCompress';\n },\n {\n code: 6010;\n name: 'DeCompressAmountUndefinedForCompress';\n msg: 'DeCompressAmountUndefinedForCompress';\n },\n {\n code: 6011;\n name: 'DelegateSignerCheckFailed';\n msg: 'DelegateSignerCheckFailed';\n },\n {\n code: 6012;\n name: 'MintTooLarge';\n msg: 'Minted amount greater than u64::MAX';\n },\n {\n code: 6013;\n name: 'SplTokenSupplyMismatch';\n msg: 'SplTokenSupplyMismatch';\n },\n {\n code: 6014;\n name: 'HeapMemoryCheckFailed';\n msg: 'HeapMemoryCheckFailed';\n },\n {\n code: 6015;\n name: 'InstructionNotCallable';\n msg: 'The instruction is not callable';\n },\n {\n code: 6016;\n name: 'ArithmeticUnderflow';\n msg: 'ArithmeticUnderflow';\n },\n {\n code: 6017;\n name: 'HashToFieldError';\n msg: 'HashToFieldError';\n },\n {\n code: 6018;\n name: 'InvalidAuthorityMint';\n msg: 'Expected the authority to be also a mint authority';\n },\n {\n code: 6019;\n name: 'InvalidFreezeAuthority';\n msg: 'Provided authority is not the freeze authority';\n },\n {\n code: 6020;\n name: 'InvalidDelegateIndex';\n },\n {\n code: 6021;\n name: 'TokenPoolPdaUndefined';\n },\n {\n code: 6022;\n name: 'IsTokenPoolPda';\n msg: 'Compress or decompress recipient is the same account as the token pool pda.';\n },\n {\n code: 6023;\n name: 'InvalidTokenPoolPda';\n },\n {\n code: 6024;\n name: 'NoInputTokenAccountsProvided';\n },\n {\n code: 6025;\n name: 'NoInputsProvided';\n },\n {\n code: 6026;\n name: 'MintHasNoFreezeAuthority';\n },\n {\n code: 6027;\n name: 'MintWithInvalidExtension';\n },\n {\n code: 6028;\n name: 'InsufficientTokenAccountBalance';\n msg: 'The token account balance is less than the remaining amount.';\n },\n {\n code: 6029;\n name: 'InvalidTokenPoolBump';\n msg: 'Max number of token pools reached.';\n },\n {\n code: 6030;\n name: 'FailedToDecompress';\n },\n {\n code: 6031;\n name: 'FailedToBurnSplTokensFromTokenPool';\n },\n {\n code: 6032;\n name: 'NoMatchingBumpFound';\n },\n ];\n};\nexport const IDL: LightCompressedToken = {\n version: '1.2.0',\n name: 'light_compressed_token',\n instructions: [\n {\n name: 'createTokenPool',\n docs: [\n 'This instruction creates a token pool for a given mint. Every spl mint',\n 'can have one token pool. When a token is compressed the tokens are',\n 'transferrred to the token pool, and their compressed equivalent is',\n 'minted into a Merkle tree.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'tokenPoolPda',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'mint',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'tokenProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [],\n },\n {\n name: 'addTokenPool',\n docs: [\n 'This instruction creates an additional token pool for a given mint.',\n 'The maximum number of token pools per mint is 5.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'tokenPoolPda',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'existingTokenPoolPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'mint',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'tokenProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'tokenPoolIndex',\n type: 'u8',\n },\n ],\n },\n {\n name: 'mintTo',\n docs: [\n 'Mints tokens from an spl token mint to a list of compressed accounts.',\n 'Minted tokens are transferred to a pool account owned by the compressed',\n 'token program. The instruction creates one compressed output account for',\n 'every amount and pubkey input pair. A constant amount of lamports can be',\n 'transferred to each output account to enable. A use case to add lamports',\n 'to a compressed token account is to prevent spam. This is the only way',\n 'to add lamports to a compressed token account.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'mint',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'tokenPoolPda',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'tokenProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n docs: ['programs'],\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'merkleTree',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'solPoolPda',\n isMut: true,\n isSigner: false,\n isOptional: true,\n },\n ],\n args: [\n {\n name: 'publicKeys',\n type: {\n vec: 'publicKey',\n },\n },\n {\n name: 'amounts',\n type: {\n vec: 'u64',\n },\n },\n {\n name: 'lamports',\n type: {\n option: 'u64',\n },\n },\n ],\n },\n {\n name: 'compressSplTokenAccount',\n docs: [\n 'Compresses the balance of an spl token account sub an optional remaining',\n 'amount. This instruction does not close the spl token account. To close',\n 'the account bundle a close spl account instruction in your transaction.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ],\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n docs: ['this program is the signer of the cpi.'],\n },\n {\n name: 'tokenPoolPda',\n isMut: true,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'compressOrDecompressTokenAccount',\n isMut: true,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'tokenProgram',\n isMut: false,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'owner',\n type: 'publicKey',\n },\n {\n name: 'remainingAmount',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'cpiContext',\n type: {\n option: {\n defined: 'CompressedCpiContext',\n },\n },\n },\n ],\n },\n {\n name: 'transfer',\n docs: [\n 'Transfers compressed tokens from one account to another. All accounts',\n 'must be of the same mint. Additional spl tokens can be compressed or',\n 'decompressed. In one transaction only compression or decompression is',\n 'possible. Lamports can be transferred alongside tokens. If output token',\n 'accounts specify less lamports than inputs the remaining lamports are',\n 'transferred to an output compressed account. Signer must be owner or',\n 'delegate. If a delegated token account is transferred the delegate is',\n 'not preserved.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ],\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n docs: ['this program is the signer of the cpi.'],\n },\n {\n name: 'tokenPoolPda',\n isMut: true,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'compressOrDecompressTokenAccount',\n isMut: true,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'tokenProgram',\n isMut: false,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'inputs',\n type: 'bytes',\n },\n ],\n },\n {\n name: 'approve',\n docs: [\n 'Delegates an amount to a delegate. A compressed token account is either',\n 'completely delegated or not. Prior delegates are not preserved. Cannot',\n 'be called by a delegate.',\n 'The instruction creates two output accounts:',\n '1. one account with delegated amount',\n '2. one account with remaining(change) amount',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ],\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n docs: ['this program is the signer of the cpi.'],\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'inputs',\n type: 'bytes',\n },\n ],\n },\n {\n name: 'revoke',\n docs: [\n 'Revokes a delegation. The instruction merges all inputs into one output',\n 'account. Cannot be called by a delegate. Delegates are not preserved.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ],\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n docs: ['this program is the signer of the cpi.'],\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'inputs',\n type: 'bytes',\n },\n ],\n },\n {\n name: 'freeze',\n docs: [\n 'Freezes compressed token accounts. Inputs must not be frozen. Creates as',\n 'many outputs as inputs. Balances and delegates are preserved.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n docs: ['that this program is the signer of the cpi.'],\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'mint',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'inputs',\n type: 'bytes',\n },\n ],\n },\n {\n name: 'thaw',\n docs: [\n 'Thaws frozen compressed token accounts. Inputs must be frozen. Creates',\n 'as many outputs as inputs. Balances and delegates are preserved.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n docs: ['that this program is the signer of the cpi.'],\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'mint',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'inputs',\n type: 'bytes',\n },\n ],\n },\n {\n name: 'burn',\n docs: [\n 'Burns compressed tokens and spl tokens from the pool account. Delegates',\n 'can burn tokens. The output compressed token account remains delegated.',\n 'Creates one output compressed token account.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ],\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'mint',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'tokenPoolPda',\n isMut: true,\n isSigner: false,\n },\n {\n name: 'tokenProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'inputs',\n type: 'bytes',\n },\n ],\n },\n {\n name: 'stubIdlBuild',\n docs: [\n 'This function is a stub to allow Anchor to include the input types in',\n 'the IDL. It should not be included in production builds nor be called in',\n 'practice.',\n ],\n accounts: [\n {\n name: 'feePayer',\n isMut: true,\n isSigner: true,\n docs: ['UNCHECKED: only pays fees.'],\n },\n {\n name: 'authority',\n isMut: false,\n isSigner: true,\n docs: [\n 'Authority is verified through proof since both owner and delegate',\n 'are included in the token data hash, which is a public input to the',\n 'validity proof.',\n ],\n },\n {\n name: 'cpiAuthorityPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'lightSystemProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'registeredProgramPda',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'noopProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionAuthority',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'accountCompressionProgram',\n isMut: false,\n isSigner: false,\n },\n {\n name: 'selfProgram',\n isMut: false,\n isSigner: false,\n docs: ['this program is the signer of the cpi.'],\n },\n {\n name: 'tokenPoolPda',\n isMut: true,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'compressOrDecompressTokenAccount',\n isMut: true,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'tokenProgram',\n isMut: false,\n isSigner: false,\n isOptional: true,\n },\n {\n name: 'systemProgram',\n isMut: false,\n isSigner: false,\n },\n ],\n args: [\n {\n name: 'inputs1',\n type: {\n defined: 'CompressedTokenInstructionDataTransfer',\n },\n },\n {\n name: 'inputs2',\n type: {\n defined: 'TokenData',\n },\n },\n ],\n },\n ],\n types: [\n {\n name: 'AccountState',\n type: {\n kind: 'enum',\n variants: [\n {\n name: 'Initialized',\n },\n {\n name: 'Frozen',\n },\n ],\n },\n },\n {\n name: 'CompressedAccount',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'owner',\n type: 'publicKey',\n },\n {\n name: 'lamports',\n type: 'u64',\n },\n {\n name: 'address',\n type: {\n option: {\n array: ['u8', 32],\n },\n },\n },\n {\n name: 'data',\n type: {\n option: {\n defined: 'CompressedAccountData',\n },\n },\n },\n ],\n },\n },\n {\n name: 'CompressedAccountData',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'discriminator',\n type: {\n array: ['u8', 8],\n },\n },\n {\n name: 'data',\n type: 'bytes',\n },\n {\n name: 'dataHash',\n type: {\n array: ['u8', 32],\n },\n },\n ],\n },\n },\n {\n name: 'CompressedCpiContext',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'setContext',\n docs: [\n 'Is set by the program that is invoking the CPI to signal that is should',\n 'set the cpi context.',\n ],\n type: 'bool',\n },\n {\n name: 'firstSetContext',\n docs: [\n 'Is set to wipe the cpi context since someone could have set it before',\n 'with unrelated data.',\n ],\n type: 'bool',\n },\n {\n name: 'cpiContextAccountIndex',\n docs: [\n 'Index of cpi context account in remaining accounts.',\n ],\n type: 'u8',\n },\n ],\n },\n },\n {\n name: 'CompressedProof',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'a',\n type: {\n array: ['u8', 32],\n },\n },\n {\n name: 'b',\n type: {\n array: ['u8', 64],\n },\n },\n {\n name: 'c',\n type: {\n array: ['u8', 32],\n },\n },\n ],\n },\n },\n {\n name: 'CompressedTokenInstructionDataTransfer',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'proof',\n type: {\n option: {\n defined: 'CompressedProof',\n },\n },\n },\n {\n name: 'mint',\n type: 'publicKey',\n },\n {\n name: 'delegatedTransfer',\n docs: [\n 'Is required if the signer is delegate,',\n '-> delegate is authority account,',\n 'owner = Some(owner) is the owner of the token account.',\n ],\n type: {\n option: {\n defined: 'DelegatedTransfer',\n },\n },\n },\n {\n name: 'inputTokenDataWithContext',\n type: {\n vec: {\n defined: 'InputTokenDataWithContext',\n },\n },\n },\n {\n name: 'outputCompressedAccounts',\n type: {\n vec: {\n defined: 'PackedTokenTransferOutputData',\n },\n },\n },\n {\n name: 'isCompress',\n type: 'bool',\n },\n {\n name: 'compressOrDecompressAmount',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'cpiContext',\n type: {\n option: {\n defined: 'CompressedCpiContext',\n },\n },\n },\n {\n name: 'lamportsChangeAccountMerkleTreeIndex',\n type: {\n option: 'u8',\n },\n },\n ],\n },\n },\n {\n name: 'CompressedTokenInstructionDataRevoke',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'proof',\n type: {\n option: {\n defined: 'CompressedProof',\n },\n },\n },\n {\n name: 'mint',\n type: 'publicKey',\n },\n {\n name: 'inputTokenDataWithContext',\n type: {\n vec: {\n defined: 'InputTokenDataWithContext',\n },\n },\n },\n {\n name: 'cpiContext',\n type: {\n option: {\n defined: 'CompressedCpiContext',\n },\n },\n },\n {\n name: 'outputAccountMerkleTreeIndex',\n type: 'u8',\n },\n ],\n },\n },\n {\n name: 'CompressedTokenInstructionDataApprove',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'proof',\n type: {\n option: {\n defined: 'CompressedProof',\n },\n },\n },\n {\n name: 'mint',\n type: 'publicKey',\n },\n {\n name: 'inputTokenDataWithContext',\n type: {\n vec: {\n defined: 'InputTokenDataWithContext',\n },\n },\n },\n {\n name: 'cpiContext',\n type: {\n option: {\n defined: 'CompressedCpiContext',\n },\n },\n },\n {\n name: 'delegate',\n type: 'publicKey',\n },\n {\n name: 'delegatedAmount',\n type: 'u64',\n },\n {\n name: 'delegateMerkleTreeIndex',\n type: 'u8',\n },\n {\n name: 'changeAccountMerkleTreeIndex',\n type: 'u8',\n },\n {\n name: 'delegateLamports',\n type: {\n option: 'u64',\n },\n },\n ],\n },\n },\n {\n name: 'DelegatedTransfer',\n docs: [\n 'Struct to provide the owner when the delegate is signer of the transaction.',\n ],\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'owner',\n type: 'publicKey',\n },\n {\n name: 'delegateChangeAccountIndex',\n docs: [\n 'Index of change compressed account in output compressed accounts. In',\n \"case that the delegate didn't spend the complete delegated compressed\",\n 'account balance the change compressed account will be delegated to her',\n 'as well.',\n ],\n type: {\n option: 'u8',\n },\n },\n ],\n },\n },\n {\n name: 'InputTokenDataWithContext',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'amount',\n type: 'u64',\n },\n {\n name: 'delegateIndex',\n type: {\n option: 'u8',\n },\n },\n {\n name: 'merkleContext',\n type: {\n defined: 'PackedMerkleContext',\n },\n },\n {\n name: 'rootIndex',\n type: 'u16',\n },\n {\n name: 'lamports',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'tlv',\n docs: [\n 'Placeholder for TokenExtension tlv data (unimplemented)',\n ],\n type: {\n option: 'bytes',\n },\n },\n ],\n },\n },\n {\n name: 'InstructionDataInvoke',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'proof',\n type: {\n option: {\n defined: 'CompressedProof',\n },\n },\n },\n {\n name: 'inputCompressedAccountsWithMerkleContext',\n type: {\n vec: {\n defined:\n 'PackedCompressedAccountWithMerkleContext',\n },\n },\n },\n {\n name: 'outputCompressedAccounts',\n type: {\n vec: {\n defined:\n 'OutputCompressedAccountWithPackedContext',\n },\n },\n },\n {\n name: 'relayFee',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'newAddressParams',\n type: {\n vec: {\n defined: 'NewAddressParamsPacked',\n },\n },\n },\n {\n name: 'compressOrDecompressLamports',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'isCompress',\n type: 'bool',\n },\n ],\n },\n },\n {\n name: 'InstructionDataInvokeCpi',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'proof',\n type: {\n option: {\n defined: 'CompressedProof',\n },\n },\n },\n {\n name: 'newAddressParams',\n type: {\n vec: {\n defined: 'NewAddressParamsPacked',\n },\n },\n },\n {\n name: 'inputCompressedAccountsWithMerkleContext',\n type: {\n vec: {\n defined:\n 'PackedCompressedAccountWithMerkleContext',\n },\n },\n },\n {\n name: 'outputCompressedAccounts',\n type: {\n vec: {\n defined:\n 'OutputCompressedAccountWithPackedContext',\n },\n },\n },\n {\n name: 'relayFee',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'compressOrDecompressLamports',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'isCompress',\n type: 'bool',\n },\n {\n name: 'cpiContext',\n type: {\n option: {\n defined: 'CompressedCpiContext',\n },\n },\n },\n ],\n },\n },\n {\n name: 'MerkleTreeSequenceNumber',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'pubkey',\n type: 'publicKey',\n },\n {\n name: 'seq',\n type: 'u64',\n },\n ],\n },\n },\n {\n name: 'NewAddressParamsPacked',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'seed',\n type: {\n array: ['u8', 32],\n },\n },\n {\n name: 'addressQueueAccountIndex',\n type: 'u8',\n },\n {\n name: 'addressMerkleTreeAccountIndex',\n type: 'u8',\n },\n {\n name: 'addressMerkleTreeRootIndex',\n type: 'u16',\n },\n ],\n },\n },\n {\n name: 'OutputCompressedAccountWithPackedContext',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'compressedAccount',\n type: {\n defined: 'CompressedAccount',\n },\n },\n {\n name: 'merkleTreeIndex',\n type: 'u8',\n },\n ],\n },\n },\n {\n name: 'PackedCompressedAccountWithMerkleContext',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'compressedAccount',\n type: {\n defined: 'CompressedAccount',\n },\n },\n {\n name: 'merkleContext',\n type: {\n defined: 'PackedMerkleContext',\n },\n },\n {\n name: 'rootIndex',\n docs: [\n 'Index of root used in inclusion validity proof.',\n ],\n type: 'u16',\n },\n {\n name: 'readOnly',\n docs: [\n 'Placeholder to mark accounts read-only unimplemented set to false.',\n ],\n type: 'bool',\n },\n ],\n },\n },\n {\n name: 'PackedMerkleContext',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'merkleTreePubkeyIndex',\n type: 'u8',\n },\n {\n name: 'queuePubkeyIndex',\n type: 'u8',\n },\n {\n name: 'leafIndex',\n type: 'u32',\n },\n {\n name: 'proveByIndex',\n type: 'bool',\n },\n ],\n },\n },\n {\n name: 'PackedTokenTransferOutputData',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'owner',\n type: 'publicKey',\n },\n {\n name: 'amount',\n type: 'u64',\n },\n {\n name: 'lamports',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'merkleTreeIndex',\n type: 'u8',\n },\n {\n name: 'tlv',\n docs: [\n 'Placeholder for TokenExtension tlv data (unimplemented)',\n ],\n type: {\n option: 'bytes',\n },\n },\n ],\n },\n },\n {\n name: 'PublicTransactionEvent',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'inputCompressedAccountHashes',\n type: {\n vec: {\n array: ['u8', 32],\n },\n },\n },\n {\n name: 'outputCompressedAccountHashes',\n type: {\n vec: {\n array: ['u8', 32],\n },\n },\n },\n {\n name: 'outputCompressedAccounts',\n type: {\n vec: {\n defined:\n 'OutputCompressedAccountWithPackedContext',\n },\n },\n },\n {\n name: 'outputLeafIndices',\n type: {\n vec: 'u32',\n },\n },\n {\n name: 'sequenceNumbers',\n type: {\n vec: {\n defined: 'MerkleTreeSequenceNumber',\n },\n },\n },\n {\n name: 'relayFee',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'isCompress',\n type: 'bool',\n },\n {\n name: 'compressOrDecompressLamports',\n type: {\n option: 'u64',\n },\n },\n {\n name: 'pubkeyArray',\n type: {\n vec: 'publicKey',\n },\n },\n {\n name: 'message',\n type: {\n option: 'bytes',\n },\n },\n ],\n },\n },\n {\n name: 'QueueIndex',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'queueId',\n docs: ['Id of queue in queue account.'],\n type: 'u8',\n },\n {\n name: 'index',\n docs: ['Index of compressed account hash in queue.'],\n type: 'u16',\n },\n ],\n },\n },\n {\n name: 'TokenData',\n type: {\n kind: 'struct',\n fields: [\n {\n name: 'mint',\n docs: ['The mint associated with this account'],\n type: 'publicKey',\n },\n {\n name: 'owner',\n docs: ['The owner of this account.'],\n type: 'publicKey',\n },\n {\n name: 'amount',\n docs: ['The amount of tokens this account holds.'],\n type: 'u64',\n },\n {\n name: 'delegate',\n docs: [\n 'If `delegate` is `Some` then `delegated_amount` represents',\n 'the amount authorized by the delegate',\n ],\n type: {\n option: 'publicKey',\n },\n },\n {\n name: 'state',\n docs: [\"The account's state\"],\n type: {\n defined: 'AccountState',\n },\n },\n {\n name: 'tlv',\n docs: [\n 'Placeholder for TokenExtension tlv data (unimplemented)',\n ],\n type: {\n option: 'bytes',\n },\n },\n ],\n },\n },\n ],\n errors: [\n {\n code: 6000,\n name: 'PublicKeyAmountMissmatch',\n msg: 'public keys and amounts must be of same length',\n },\n {\n code: 6001,\n name: 'ComputeInputSumFailed',\n msg: 'ComputeInputSumFailed',\n },\n {\n code: 6002,\n name: 'ComputeOutputSumFailed',\n msg: 'ComputeOutputSumFailed',\n },\n {\n code: 6003,\n name: 'ComputeCompressSumFailed',\n msg: 'ComputeCompressSumFailed',\n },\n {\n code: 6004,\n name: 'ComputeDecompressSumFailed',\n msg: 'ComputeDecompressSumFailed',\n },\n {\n code: 6005,\n name: 'SumCheckFailed',\n msg: 'SumCheckFailed',\n },\n {\n code: 6006,\n name: 'DecompressRecipientUndefinedForDecompress',\n msg: 'DecompressRecipientUndefinedForDecompress',\n },\n {\n code: 6007,\n name: 'CompressedPdaUndefinedForDecompress',\n msg: 'CompressedPdaUndefinedForDecompress',\n },\n {\n code: 6008,\n name: 'DeCompressAmountUndefinedForDecompress',\n msg: 'DeCompressAmountUndefinedForDecompress',\n },\n {\n code: 6009,\n name: 'CompressedPdaUndefinedForCompress',\n msg: 'CompressedPdaUndefinedForCompress',\n },\n {\n code: 6010,\n name: 'DeCompressAmountUndefinedForCompress',\n msg: 'DeCompressAmountUndefinedForCompress',\n },\n {\n code: 6011,\n name: 'DelegateSignerCheckFailed',\n msg: 'DelegateSignerCheckFailed',\n },\n {\n code: 6012,\n name: 'MintTooLarge',\n msg: 'Minted amount greater than u64::MAX',\n },\n {\n code: 6013,\n name: 'SplTokenSupplyMismatch',\n msg: 'SplTokenSupplyMismatch',\n },\n {\n code: 6014,\n name: 'HeapMemoryCheckFailed',\n msg: 'HeapMemoryCheckFailed',\n },\n {\n code: 6015,\n name: 'InstructionNotCallable',\n msg: 'The instruction is not callable',\n },\n {\n code: 6016,\n name: 'ArithmeticUnderflow',\n msg: 'ArithmeticUnderflow',\n },\n {\n code: 6017,\n name: 'HashToFieldError',\n msg: 'HashToFieldError',\n },\n {\n code: 6018,\n name: 'InvalidAuthorityMint',\n msg: 'Expected the authority to be also a mint authority',\n },\n {\n code: 6019,\n name: 'InvalidFreezeAuthority',\n msg: 'Provided authority is not the freeze authority',\n },\n {\n code: 6020,\n name: 'InvalidDelegateIndex',\n },\n {\n code: 6021,\n name: 'TokenPoolPdaUndefined',\n },\n {\n code: 6022,\n name: 'IsTokenPoolPda',\n msg: 'Compress or decompress recipient is the same account as the token pool pda.',\n },\n {\n code: 6023,\n name: 'InvalidTokenPoolPda',\n },\n {\n code: 6024,\n name: 'NoInputTokenAccountsProvided',\n },\n {\n code: 6025,\n name: 'NoInputsProvided',\n },\n {\n code: 6026,\n name: 'MintHasNoFreezeAuthority',\n },\n {\n code: 6027,\n name: 'MintWithInvalidExtension',\n },\n {\n code: 6028,\n name: 'InsufficientTokenAccountBalance',\n msg: 'The token account balance is less than the remaining amount.',\n },\n {\n code: 6029,\n name: 'InvalidTokenPoolBump',\n msg: 'Max number of token pools reached.',\n },\n {\n code: 6030,\n name: 'FailedToDecompress',\n },\n {\n code: 6031,\n name: 'FailedToBurnSplTokensFromTokenPool',\n },\n {\n code: 6032,\n name: 'NoMatchingBumpFound',\n },\n ],\n};\n","import {\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionInstruction,\n TransactionSignature,\n} from '@solana/web3.js';\nimport { CompressedTokenProgram } from '../program';\nimport {\n Rpc,\n buildAndSignTx,\n sendAndConfirmTx,\n} from '@lightprotocol/stateless.js';\nimport { getTokenPoolInfos } from '../utils/get-token-pool-infos';\n\n/**\n * Register an existing mint with the CompressedToken program\n *\n * @param rpc RPC connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param confirmOptions Options for confirming the transaction\n * @param tokenProgramId Optional: Address of the token program. Default:\n * TOKEN_PROGRAM_ID\n *\n * @return transaction signature\n */\nexport async function createTokenPool(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n confirmOptions?: ConfirmOptions,\n tokenProgramId?: PublicKey,\n): Promise<TransactionSignature> {\n tokenProgramId = tokenProgramId\n ? tokenProgramId\n : await CompressedTokenProgram.getMintProgramId(mint, rpc);\n\n const ix = await CompressedTokenProgram.createTokenPool({\n feePayer: payer.publicKey,\n mint,\n tokenProgramId,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n\n const tx = buildAndSignTx([ix], payer, blockhash);\n\n const txId = await sendAndConfirmTx(rpc, tx, confirmOptions);\n\n return txId;\n}\n\n/**\n * Create additional token pools for an existing mint\n *\n * @param rpc RPC connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param numMaxAdditionalPools Number of additional token pools to create. Max\n * 3.\n * @param confirmOptions Optional: Options for confirming the transaction\n * @param tokenProgramId Optional: Address of the token program. Default:\n * TOKEN_PROGRAM_ID\n *\n * @return transaction signature\n */\nexport async function addTokenPools(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n numMaxAdditionalPools: number,\n confirmOptions?: ConfirmOptions,\n tokenProgramId?: PublicKey,\n) {\n tokenProgramId = tokenProgramId\n ? tokenProgramId\n : await CompressedTokenProgram.getMintProgramId(mint, rpc);\n const instructions: TransactionInstruction[] = [];\n\n const infos = (await getTokenPoolInfos(rpc, mint)).slice(0, 4);\n\n // Get indices of uninitialized pools\n const uninitializedIndices = [];\n for (let i = 0; i < infos.length; i++) {\n if (!infos[i].isInitialized) {\n uninitializedIndices.push(i);\n }\n }\n\n // Create instructions for requested number of pools\n for (let i = 0; i < numMaxAdditionalPools; i++) {\n if (i >= uninitializedIndices.length) {\n break;\n }\n\n instructions.push(\n await CompressedTokenProgram.addTokenPool({\n mint,\n feePayer: payer.publicKey,\n tokenProgramId,\n poolIndex: uninitializedIndices[i],\n }),\n );\n }\n const { blockhash } = await rpc.getLatestBlockhash();\n\n const tx = buildAndSignTx(instructions, payer, blockhash);\n\n const txId = await sendAndConfirmTx(rpc, tx, confirmOptions);\n\n return txId;\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n bn,\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n} from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport { CompressedTokenProgram } from '../program';\nimport {\n selectMinCompressedTokenAccountsForTransfer,\n selectTokenAccountsForApprove,\n} from '../utils';\n\n/**\n * Approve a delegate to spend tokens\n *\n * @param rpc Rpc to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param amount Number of tokens to delegate\n * @param owner Owner of the SPL token account.\n * @param delegate Address of the delegate\n * @param confirmOptions Options for confirming the transaction\n *\n * @return Signature of the confirmed transaction\n */\nexport async function approve(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n amount: number | BN,\n owner: Signer,\n delegate: PublicKey,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n amount = bn(amount);\n const compressedTokenAccounts = await rpc.getCompressedTokenAccountsByOwner(\n owner.publicKey,\n {\n mint,\n },\n );\n\n const [inputAccounts] = selectTokenAccountsForApprove(\n compressedTokenAccounts.items,\n amount,\n );\n\n const proof = await rpc.getValidityProofV0(\n inputAccounts.map(account => ({\n hash: account.compressedAccount.hash,\n tree: account.compressedAccount.treeInfo.tree,\n queue: account.compressedAccount.treeInfo.queue,\n })),\n );\n\n const ix = await CompressedTokenProgram.approve({\n payer: payer.publicKey,\n inputCompressedTokenAccounts: inputAccounts,\n toAddress: delegate,\n amount,\n recentInputStateRootIndices: proof.rootIndices,\n recentValidityProof: proof.compressedProof,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n const signedTx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 350_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n\n return sendAndConfirmTx(rpc, signedTx, confirmOptions);\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport BN from 'bn.js';\nimport {\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n selectStateTreeInfo,\n toArray,\n TreeInfo,\n} from '@lightprotocol/stateless.js';\nimport { CompressedTokenProgram } from '../program';\nimport { getOrCreateAssociatedTokenAccount } from '@solana/spl-token';\n\nimport {\n getTokenPoolInfos,\n selectTokenPoolInfo,\n TokenPoolInfo,\n} from '../utils/get-token-pool-infos';\n\n/**\n * Mint compressed tokens to a solana address from an external mint authority\n *\n * @param rpc Rpc to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param toPubkey Address of the account to mint to\n * @param authority Minting authority\n * @param amount Amount to mint\n * @param outputStateTreeInfo Optional: State tree account that the compressed\n * tokens should be inserted into. Defaults to a\n * shared state tree account.\n * @param tokenPoolInfo Optional: Token pool info.\n * @param confirmOptions Options for confirming the transaction\n *\n * @return Signature of the confirmed transaction\n */\nexport async function approveAndMintTo(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n toPubkey: PublicKey,\n authority: Signer,\n amount: number | BN,\n outputStateTreeInfo?: TreeInfo,\n tokenPoolInfo?: TokenPoolInfo,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n outputStateTreeInfo =\n outputStateTreeInfo ??\n selectStateTreeInfo(await rpc.getStateTreeInfos());\n tokenPoolInfo =\n tokenPoolInfo ??\n selectTokenPoolInfo(await getTokenPoolInfos(rpc, mint));\n\n const authorityTokenAccount = await getOrCreateAssociatedTokenAccount(\n rpc,\n payer,\n mint,\n authority.publicKey,\n undefined,\n undefined,\n confirmOptions,\n tokenPoolInfo.tokenProgram,\n );\n\n const ixs = await CompressedTokenProgram.approveAndMintTo({\n feePayer: payer.publicKey,\n mint,\n authority: authority.publicKey,\n authorityTokenAccount: authorityTokenAccount.address,\n amount,\n toPubkey,\n outputStateTreeInfo,\n tokenPoolInfo,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [authority]);\n\n const tx = buildAndSignTx(\n [\n ComputeBudgetProgram.setComputeUnitLimit({\n units: 150_000 + toArray(amount).length * 20_000,\n }),\n ...ixs,\n ],\n payer,\n blockhash,\n additionalSigners,\n );\n\n return await sendAndConfirmTx(rpc, tx, confirmOptions);\n}\n","import {\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n ComputeBudgetProgram,\n} from '@solana/web3.js';\nimport {\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n selectStateTreeInfo,\n toArray,\n TreeInfo,\n} from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport { CompressedTokenProgram } from '../program';\nimport {\n getTokenPoolInfos,\n selectTokenPoolInfo,\n TokenPoolInfo,\n} from '../utils/get-token-pool-infos';\n\n/**\n * Compress SPL tokens\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param amount Number of tokens to compress.\n * @param owner Owner of the SPL token account.\n * @param sourceTokenAccount Source SPL token account. (ATA)\n * @param toAddress Recipient owner address.\n * @param outputStateTreeInfo Optional: State tree account that the compressed\n * tokens should be inserted into. Defaults to a\n * shared state tree account.\n * @param tokenPoolInfo Optional: Token pool info.\n * @param confirmOptions Options for confirming the transaction\n *\n * @return Signature of the confirmed transaction\n */\nexport async function compress(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n amount: number | BN | number[] | BN[],\n owner: Signer,\n sourceTokenAccount: PublicKey,\n toAddress: PublicKey | Array<PublicKey>,\n outputStateTreeInfo?: TreeInfo,\n tokenPoolInfo?: TokenPoolInfo,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n outputStateTreeInfo =\n outputStateTreeInfo ??\n selectStateTreeInfo(await rpc.getStateTreeInfos());\n tokenPoolInfo =\n tokenPoolInfo ??\n selectTokenPoolInfo(await getTokenPoolInfos(rpc, mint));\n\n const compressIx = await CompressedTokenProgram.compress({\n payer: payer.publicKey,\n owner: owner.publicKey,\n source: sourceTokenAccount,\n toAddress,\n amount,\n mint,\n outputStateTreeInfo,\n tokenPoolInfo,\n });\n\n const blockhashCtx = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n const signedTx = buildAndSignTx(\n [\n ComputeBudgetProgram.setComputeUnitLimit({\n units: 130_000 + toArray(amount).length * 20_000,\n }),\n compressIx,\n ],\n payer,\n blockhashCtx.blockhash,\n additionalSigners,\n );\n\n return await sendAndConfirmTx(rpc, signedTx, confirmOptions, blockhashCtx);\n}\n","import {\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n ComputeBudgetProgram,\n} from '@solana/web3.js';\nimport {\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n selectStateTreeInfo,\n TreeInfo,\n} from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport {\n getTokenPoolInfos,\n selectTokenPoolInfo,\n TokenPoolInfo,\n} from '../utils/get-token-pool-infos';\nimport { CompressedTokenProgram } from '../program';\n\n/**\n * Compress SPL tokens into compressed token format\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param owner Owner of the token account\n * @param tokenAccount Token account to compress\n * @param remainingAmount Optional: amount to leave in token account.\n * Default: 0\n * @param outputStateTreeInfo Optional: State tree account that the compressed\n * account into\n * @param tokenPoolInfo Optional: Token pool info.\n * @param confirmOptions Options for confirming the transaction\n\n *\n * @return Signature of the confirmed transaction\n */\nexport async function compressSplTokenAccount(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n owner: Signer,\n tokenAccount: PublicKey,\n remainingAmount?: BN,\n outputStateTreeInfo?: TreeInfo,\n tokenPoolInfo?: TokenPoolInfo,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n outputStateTreeInfo =\n outputStateTreeInfo ??\n selectStateTreeInfo(await rpc.getStateTreeInfos());\n tokenPoolInfo =\n tokenPoolInfo ??\n selectTokenPoolInfo(await getTokenPoolInfos(rpc, mint));\n\n const compressIx = await CompressedTokenProgram.compressSplTokenAccount({\n feePayer: payer.publicKey,\n authority: owner.publicKey,\n tokenAccount,\n mint,\n remainingAmount,\n outputStateTreeInfo,\n tokenPoolInfo,\n });\n\n const blockhashCtx = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n\n const signedTx = buildAndSignTx(\n [\n ComputeBudgetProgram.setComputeUnitLimit({\n units: 150_000,\n }),\n compressIx,\n ],\n payer,\n blockhashCtx.blockhash,\n additionalSigners,\n );\n\n return await sendAndConfirmTx(rpc, signedTx, confirmOptions, blockhashCtx);\n}\n","import {\n ConfirmOptions,\n Keypair,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport { CompressedTokenProgram } from '../program';\nimport {\n MINT_SIZE,\n TOKEN_2022_PROGRAM_ID,\n TOKEN_PROGRAM_ID,\n} from '@solana/spl-token';\nimport {\n Rpc,\n buildAndSignTx,\n dedupeSigner,\n sendAndConfirmTx,\n} from '@lightprotocol/stateless.js';\n\n/**\n * Create and initialize a new compressed token mint\n *\n * @param rpc RPC connection to use\n * @param payer Fee payer\n * @param mintAuthority Account that will control minting\n * @param decimals Location of the decimal place\n * @param keypair Optional: Mint keypair. Defaults to a random\n * keypair.\n * @param confirmOptions Options for confirming the transaction\n * @param tokenProgramId Optional: Program ID for the token. Defaults to\n * TOKEN_PROGRAM_ID.\n * @param freezeAuthority Optional: Account that will control freeze and thaw.\n * Defaults to none.\n *\n * @return Object with mint address and transaction signature\n */\nexport async function createMint(\n rpc: Rpc,\n payer: Signer,\n mintAuthority: PublicKey | Signer,\n decimals: number,\n keypair = Keypair.generate(),\n confirmOptions?: ConfirmOptions,\n tokenProgramId?: PublicKey | boolean,\n freezeAuthority?: PublicKey | Signer,\n): Promise<{ mint: PublicKey; transactionSignature: TransactionSignature }> {\n const rentExemptBalance =\n await rpc.getMinimumBalanceForRentExemption(MINT_SIZE);\n\n // If true, uses TOKEN_2022_PROGRAM_ID.\n // If false or undefined, defaults to TOKEN_PROGRAM_ID.\n // Otherwise, uses the provided tokenProgramId.\n const resolvedTokenProgramId =\n tokenProgramId === true\n ? TOKEN_2022_PROGRAM_ID\n : tokenProgramId || TOKEN_PROGRAM_ID;\n\n const ixs = await CompressedTokenProgram.createMint({\n feePayer: payer.publicKey,\n mint: keypair.publicKey,\n decimals,\n authority:\n 'secretKey' in mintAuthority\n ? mintAuthority.publicKey\n : mintAuthority,\n freezeAuthority:\n freezeAuthority && 'secretKey' in freezeAuthority\n ? freezeAuthority.publicKey\n : (freezeAuthority ?? null),\n rentExemptBalance,\n tokenProgramId: resolvedTokenProgramId,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n\n const additionalSigners = dedupeSigner(\n payer,\n [mintAuthority, freezeAuthority].filter(\n (signer): signer is Signer =>\n signer != undefined && 'secretKey' in signer,\n ),\n );\n\n const tx = buildAndSignTx(ixs, payer, blockhash, [\n ...additionalSigners,\n keypair,\n ]);\n const txId = await sendAndConfirmTx(rpc, tx, confirmOptions);\n\n return { mint: keypair.publicKey, transactionSignature: txId };\n}\n","import { PublicKey, Signer, TransactionSignature } from '@solana/web3.js';\nimport {\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n} from '@lightprotocol/stateless.js';\n\nimport { CompressedTokenProgram } from '../program';\n\n/**\n * Create a lookup table for the token program's default accounts\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param authority Authority of the lookup table\n * @param mints Optional array of mint public keys to include in\n * the lookup table\n * @param additionalAccounts Optional array of additional account public keys\n * to include in the lookup table\n *\n * @return Object with transaction signatures and the address of the created\n * lookup table\n */\nexport async function createTokenProgramLookupTable(\n rpc: Rpc,\n payer: Signer,\n authority: Signer,\n mints?: PublicKey[],\n additionalAccounts?: PublicKey[],\n): Promise<{ txIds: TransactionSignature[]; address: PublicKey }> {\n const recentSlot = await rpc.getSlot('finalized');\n const { instructions, address } =\n await CompressedTokenProgram.createTokenProgramLookupTable({\n payer: payer.publicKey,\n authority: authority.publicKey,\n mints,\n remainingAccounts: additionalAccounts,\n recentSlot,\n });\n\n const additionalSigners = dedupeSigner(payer, [authority]);\n const txIds = [];\n\n for (const instruction of instructions) {\n const blockhashCtx = await rpc.getLatestBlockhash();\n const signedTx = buildAndSignTx(\n [instruction],\n payer,\n blockhashCtx.blockhash,\n additionalSigners,\n );\n const txId = await sendAndConfirmTx(\n rpc,\n signedTx,\n { commitment: 'finalized' },\n blockhashCtx,\n );\n txIds.push(txId);\n }\n\n return { txIds, address };\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n bn,\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n} from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport { CompressedTokenProgram } from '../program';\nimport { selectMinCompressedTokenAccountsForTransfer } from '../utils';\nimport {\n selectTokenPoolInfosForDecompression,\n TokenPoolInfo,\n} from '../utils/get-token-pool-infos';\nimport { getTokenPoolInfos } from '../utils/get-token-pool-infos';\n\n/**\n * Decompress compressed tokens\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param amount Number of tokens to transfer\n * @param owner Owner of the compressed tokens\n * @param toAddress Destination **uncompressed** token account\n * address. (ATA)\n * @param tokenPoolInfos Optional: Token pool infos.\n * @param confirmOptions Options for confirming the transaction\n *\n * @return confirmed transaction signature\n */\nexport async function decompress(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n amount: number | BN,\n owner: Signer,\n toAddress: PublicKey,\n tokenPoolInfos?: TokenPoolInfo[],\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n amount = bn(amount);\n\n const compressedTokenAccounts = await rpc.getCompressedTokenAccountsByOwner(\n owner.publicKey,\n {\n mint,\n },\n );\n\n const [inputAccounts] = selectMinCompressedTokenAccountsForTransfer(\n compressedTokenAccounts.items,\n amount,\n );\n\n const proof = await rpc.getValidityProofV0(\n inputAccounts.map(account => ({\n hash: account.compressedAccount.hash,\n tree: account.compressedAccount.treeInfo.tree,\n queue: account.compressedAccount.treeInfo.queue,\n })),\n );\n\n tokenPoolInfos = tokenPoolInfos ?? (await getTokenPoolInfos(rpc, mint));\n\n const selectedTokenPoolInfos = selectTokenPoolInfosForDecompression(\n tokenPoolInfos,\n amount,\n );\n\n const ix = await CompressedTokenProgram.decompress({\n payer: payer.publicKey,\n inputCompressedTokenAccounts: inputAccounts,\n toAddress,\n amount,\n tokenPoolInfos: selectedTokenPoolInfos,\n recentInputStateRootIndices: proof.rootIndices,\n recentValidityProof: proof.compressedProof,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n const signedTx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 350_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n return await sendAndConfirmTx(rpc, signedTx, confirmOptions);\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n bn,\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n} from '@lightprotocol/stateless.js';\n\nimport BN from 'bn.js';\n\nimport { CompressedTokenProgram } from '../program';\nimport { selectMinCompressedTokenAccountsForTransfer } from '../utils';\nimport {\n selectTokenPoolInfosForDecompression,\n TokenPoolInfo,\n} from '../utils/get-token-pool-infos';\nimport { getTokenPoolInfos } from '../utils/get-token-pool-infos';\n\n/**\n * Decompress delegated compressed tokens. Remaining compressed tokens are\n * returned to the owner without delegation.\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param amount Number of tokens to decompress\n * @param owner Owner of the compressed tokens\n * @param toAddress Destination **uncompressed** token account\n * address. (ATA)\n * @param tokenPoolInfos Optional: Token pool infos.\n * @param confirmOptions Options for confirming the transaction\n *\n * @return Signature of the confirmed transaction\n */\nexport async function decompressDelegated(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n amount: number | BN,\n owner: Signer,\n toAddress: PublicKey,\n tokenPoolInfos?: TokenPoolInfo[],\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n amount = bn(amount);\n\n const compressedTokenAccounts =\n await rpc.getCompressedTokenAccountsByDelegate(owner.publicKey, {\n mint,\n });\n\n const [inputAccounts] = selectMinCompressedTokenAccountsForTransfer(\n compressedTokenAccounts.items,\n amount,\n );\n\n const proof = await rpc.getValidityProofV0(\n inputAccounts.map(account => ({\n hash: account.compressedAccount.hash,\n tree: account.compressedAccount.treeInfo.tree,\n queue: account.compressedAccount.treeInfo.queue,\n })),\n );\n\n const tokenPoolInfosToUse =\n tokenPoolInfos ??\n selectTokenPoolInfosForDecompression(\n await getTokenPoolInfos(rpc, mint),\n amount,\n );\n\n const ix = await CompressedTokenProgram.decompress({\n payer: payer.publicKey,\n inputCompressedTokenAccounts: inputAccounts,\n toAddress,\n amount,\n recentInputStateRootIndices: proof.rootIndices,\n recentValidityProof: proof.compressedProof,\n tokenPoolInfos: tokenPoolInfosToUse,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n const signedTx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 350_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n\n return sendAndConfirmTx(rpc, signedTx, confirmOptions);\n}\n","import { PublicKey } from '@solana/web3.js';\nimport BN from 'bn.js';\nimport { Buffer } from 'buffer';\nimport {\n ValidityProof,\n PackedMerkleContextLegacy,\n CompressedCpiContext,\n} from '@lightprotocol/stateless.js';\nimport { TokenPoolInfo } from './utils/get-token-pool-infos';\n\nexport type TokenTransferOutputData = {\n /**\n * The owner of the output token account\n */\n owner: PublicKey;\n /**\n * The amount of tokens of the output token account\n */\n amount: BN;\n /**\n * lamports associated with the output token account\n */\n lamports: BN | null;\n /**\n * TokenExtension tlv\n */\n tlv: Buffer | null;\n};\n\nexport type PackedTokenTransferOutputData = {\n /**\n * The owner of the output token account\n */\n owner: PublicKey;\n /**\n * The amount of tokens of the output token account\n */\n amount: BN;\n /**\n * lamports associated with the output token account\n */\n lamports: BN | null;\n /**\n * Merkle tree pubkey index in remaining accounts\n */\n merkleTreeIndex: number;\n /**\n * TokenExtension tlv\n */\n tlv: Buffer | null;\n};\n\nexport type InputTokenDataWithContext = {\n amount: BN;\n delegateIndex: number | null;\n merkleContext: PackedMerkleContextLegacy;\n rootIndex: number;\n lamports: BN | null;\n tlv: Buffer | null;\n};\n\nexport type DelegatedTransfer = {\n owner: PublicKey;\n delegateChangeAccountIndex: number | null;\n};\n\nexport type BatchCompressInstructionData = {\n pubkeys: PublicKey[];\n amounts: BN[] | null;\n lamports: BN | null;\n amount: BN | null;\n index: number;\n bump: number;\n};\n\nexport type MintToInstructionData = {\n recipients: PublicKey[];\n amounts: BN[];\n lamports: BN | null;\n};\nexport type CompressSplTokenAccountInstructionData = {\n owner: PublicKey;\n remainingAmount: BN | null;\n cpiContext: CompressedCpiContext | null;\n};\n\nexport function isSingleTokenPoolInfo(\n tokenPoolInfos: TokenPoolInfo | TokenPoolInfo[],\n): tokenPoolInfos is TokenPoolInfo {\n return !Array.isArray(tokenPoolInfos);\n}\n\nexport type CompressedTokenInstructionDataTransfer = {\n /**\n * Validity proof\n */\n proof: ValidityProof | null;\n /**\n * The mint of the transfer\n */\n mint: PublicKey;\n /**\n * Whether the signer is a delegate\n */\n delegatedTransfer: DelegatedTransfer | null;\n /**\n * Input token data with packed merkle context\n */\n inputTokenDataWithContext: InputTokenDataWithContext[];\n /**\n * Data of the output token accounts\n */\n outputCompressedAccounts: PackedTokenTransferOutputData[];\n /**\n * Whether it's a compress or decompress action if compressOrDecompressAmount is non-null\n */\n isCompress: boolean;\n /**\n * If null, it's a transfer.\n * If some, the amount that is being deposited into (compress) or withdrawn from (decompress) the token escrow\n */\n compressOrDecompressAmount: BN | null;\n /**\n * CPI context if\n */\n cpiContext: CompressedCpiContext | null;\n /**\n * The index of the Merkle tree for a lamport change account.\n */\n lamportsChangeAccountMerkleTreeIndex: number | null;\n};\n\nexport type TokenData = {\n /**\n * The mint associated with this account\n */\n mint: PublicKey;\n /**\n * The owner of this account\n */\n owner: PublicKey;\n /**\n * The amount of tokens this account holds\n */\n amount: BN;\n /**\n * If `delegate` is `Some` then `delegated_amount` represents the amount\n * authorized by the delegate\n */\n delegate: PublicKey | null;\n /**\n * The account's state\n */\n state: number;\n /**\n * TokenExtension tlv\n */\n tlv: Buffer | null;\n};\n\nexport type CompressedTokenInstructionDataApprove = {\n proof: ValidityProof | null;\n mint: PublicKey;\n inputTokenDataWithContext: InputTokenDataWithContext[];\n cpiContext: CompressedCpiContext | null;\n delegate: PublicKey;\n delegatedAmount: BN;\n delegateMerkleTreeIndex: number;\n changeAccountMerkleTreeIndex: number;\n delegateLamports: BN | null;\n};\n\nexport type CompressedTokenInstructionDataRevoke = {\n proof: ValidityProof | null;\n mint: PublicKey;\n inputTokenDataWithContext: InputTokenDataWithContext[];\n cpiContext: CompressedCpiContext | null;\n outputAccountMerkleTreeIndex: number;\n};\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n Rpc,\n dedupeSigner,\n buildAndSignTx,\n sendAndConfirmTx,\n bn,\n} from '@lightprotocol/stateless.js';\nimport { CompressedTokenProgram } from '../program';\n\n/**\n * Merge multiple compressed token accounts for a given mint into a single\n * account\n *\n * @param rpc RPC connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param owner Owner of the token accounts to be merged\n * @param confirmOptions Options for confirming the transaction\n *\n * @return confirmed transaction signature\n */\nexport async function mergeTokenAccounts(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n owner: Signer,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n const compressedTokenAccounts = await rpc.getCompressedTokenAccountsByOwner(\n owner.publicKey,\n { mint },\n );\n\n if (compressedTokenAccounts.items.length === 0) {\n throw new Error(\n `No compressed token accounts found for mint ${mint.toBase58()}`,\n );\n }\n\n const instructions = [\n ComputeBudgetProgram.setComputeUnitLimit({ units: 1_000_000 }),\n ];\n\n for (\n let i = 0;\n i < compressedTokenAccounts.items.slice(0, 8).length;\n i += 4\n ) {\n const batch = compressedTokenAccounts.items.slice(i, i + 4);\n\n const proof = await rpc.getValidityProof(\n batch.map(account => bn(account.compressedAccount.hash)),\n );\n\n const batchInstructions =\n await CompressedTokenProgram.mergeTokenAccounts({\n payer: payer.publicKey,\n owner: owner.publicKey,\n inputCompressedTokenAccounts: batch,\n mint,\n recentValidityProof: proof.compressedProof,\n recentInputStateRootIndices: proof.rootIndices,\n });\n\n instructions.push(...batchInstructions);\n }\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n\n const signedTx = buildAndSignTx(\n instructions,\n payer,\n blockhash,\n additionalSigners,\n );\n\n return sendAndConfirmTx(rpc, signedTx, confirmOptions);\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport BN from 'bn.js';\nimport {\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n selectStateTreeInfo,\n TreeInfo,\n} from '@lightprotocol/stateless.js';\nimport { CompressedTokenProgram } from '../program';\nimport {\n getTokenPoolInfos,\n selectTokenPoolInfo,\n TokenPoolInfo,\n} from '../utils/get-token-pool-infos';\n\n/**\n * Mint compressed tokens to a solana address\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param toPubkey Address of the account to mint to. Can be an\n * array of addresses if the amount is an array of\n * amounts.\n * @param authority Mint authority\n * @param amount Amount to mint. Pass an array of amounts if the\n * toPubkey is an array of addresses.\n * @param outputStateTreeInfo Optional: State tree account that the compressed\n * tokens should be part of. Defaults to the\n * default state tree account.\n * @param tokenPoolInfo Optional: Token pool information\n * @param confirmOptions Options for confirming the transaction\n *\n * @return Signature of the confirmed transaction\n */\nexport async function mintTo(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n toPubkey: PublicKey | PublicKey[],\n authority: Signer,\n amount: number | BN | number[] | BN[],\n outputStateTreeInfo?: TreeInfo,\n tokenPoolInfo?: TokenPoolInfo,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n outputStateTreeInfo =\n outputStateTreeInfo ??\n selectStateTreeInfo(await rpc.getStateTreeInfos());\n tokenPoolInfo =\n tokenPoolInfo ??\n selectTokenPoolInfo(await getTokenPoolInfos(rpc, mint));\n\n const ix = await CompressedTokenProgram.mintTo({\n feePayer: payer.publicKey,\n mint,\n authority: authority.publicKey,\n amount,\n toPubkey,\n outputStateTreeInfo,\n tokenPoolInfo,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [authority]);\n\n const tx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 1_000_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n\n return sendAndConfirmTx(rpc, tx, confirmOptions);\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n ParsedTokenAccount,\n} from '@lightprotocol/stateless.js';\nimport { CompressedTokenProgram } from '../program';\n\n/**\n * Revoke one or more delegated token accounts\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param accounts Delegated compressed token accounts to revoke\n * @param owner Owner of the compressed tokens\n * @param confirmOptions Options for confirming the transaction\n *\n * @return Signature of the confirmed transaction\n */\nexport async function revoke(\n rpc: Rpc,\n payer: Signer,\n accounts: ParsedTokenAccount[],\n owner: Signer,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n const proof = await rpc.getValidityProofV0(\n accounts.map(account => ({\n hash: account.compressedAccount.hash,\n tree: account.compressedAccount.treeInfo.tree,\n queue: account.compressedAccount.treeInfo.queue,\n })),\n );\n checkOwner(owner, accounts);\n checkIsDelegated(accounts);\n\n const ix = await CompressedTokenProgram.revoke({\n payer: payer.publicKey,\n inputCompressedTokenAccounts: accounts,\n recentInputStateRootIndices: proof.rootIndices,\n recentValidityProof: proof.compressedProof,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n const signedTx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 500_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n\n return sendAndConfirmTx(rpc, signedTx, confirmOptions);\n}\n\nfunction checkOwner(owner: Signer, accounts: ParsedTokenAccount[]) {\n if (!owner.publicKey.equals(accounts[0].parsed.owner)) {\n throw new Error(\n `Owner ${owner.publicKey.toBase58()} does not match account ${accounts[0].parsed.owner.toBase58()}`,\n );\n }\n}\n\nfunction checkIsDelegated(accounts: ParsedTokenAccount[]) {\n if (accounts.some(account => account.parsed.delegate === null)) {\n throw new Error('Account is not delegated');\n }\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n bn,\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n StateTreeInfo,\n selectStateTreeInfo,\n} from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport { CompressedTokenProgram } from '../program';\nimport { selectMinCompressedTokenAccountsForTransfer } from '../utils';\n\n/**\n * Transfer compressed tokens from one owner to another\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param amount Number of tokens to transfer\n * @param owner Owner of the compressed tokens\n * @param toAddress Destination address of the recipient\n * @param confirmOptions Options for confirming the transaction\n *\n * @return confirmed transaction signature\n */\nexport async function transfer(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n amount: number | BN,\n owner: Signer,\n toAddress: PublicKey,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n amount = bn(amount);\n const compressedTokenAccounts = await rpc.getCompressedTokenAccountsByOwner(\n owner.publicKey,\n {\n mint,\n },\n );\n\n const [inputAccounts] = selectMinCompressedTokenAccountsForTransfer(\n compressedTokenAccounts.items,\n amount,\n );\n\n const proof = await rpc.getValidityProofV0(\n inputAccounts.map(account => ({\n hash: account.compressedAccount.hash,\n tree: account.compressedAccount.treeInfo.tree,\n queue: account.compressedAccount.treeInfo.queue,\n })),\n );\n\n const ix = await CompressedTokenProgram.transfer({\n payer: payer.publicKey,\n inputCompressedTokenAccounts: inputAccounts,\n toAddress,\n amount,\n recentInputStateRootIndices: proof.rootIndices,\n recentValidityProof: proof.compressedProof,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n const signedTx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 500_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n\n return sendAndConfirmTx(rpc, signedTx, confirmOptions);\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n bn,\n sendAndConfirmTx,\n buildAndSignTx,\n Rpc,\n dedupeSigner,\n} from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport { CompressedTokenProgram } from '../program';\nimport { selectMinCompressedTokenAccountsForTransfer } from '../utils';\n\n/**\n * Transfer delegated compressed tokens to another owner\n *\n * @param rpc Rpc connection to use\n * @param payer Fee payer\n * @param mint SPL Mint address\n * @param amount Number of tokens to transfer\n * @param owner Owner of the compressed tokens\n * @param toAddress Destination address of the recipient\n * @param confirmOptions Options for confirming the transaction\n *\n * @return confirmed transaction signature\n */\nexport async function transferDelegated(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n amount: number | BN,\n owner: Signer,\n toAddress: PublicKey,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n amount = bn(amount);\n const compressedTokenAccounts =\n await rpc.getCompressedTokenAccountsByDelegate(owner.publicKey, {\n mint,\n });\n\n const [inputAccounts] = selectMinCompressedTokenAccountsForTransfer(\n compressedTokenAccounts.items,\n amount,\n );\n\n const proof = await rpc.getValidityProofV0(\n inputAccounts.map(account => ({\n hash: account.compressedAccount.hash,\n tree: account.compressedAccount.treeInfo.tree,\n queue: account.compressedAccount.treeInfo.queue,\n })),\n );\n\n const ix = await CompressedTokenProgram.transfer({\n payer: payer.publicKey,\n inputCompressedTokenAccounts: inputAccounts,\n toAddress,\n amount,\n recentInputStateRootIndices: proof.rootIndices,\n recentValidityProof: proof.compressedProof,\n });\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n const signedTx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 500_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n\n return sendAndConfirmTx(rpc, signedTx, confirmOptions);\n}\n"],"names":["POOL_SEED","Buffer","from","CPI_AUTHORITY_SEED","CREATE_TOKEN_POOL_DISCRIMINATOR","MINT_TO_DISCRIMINATOR","BATCH_COMPRESS_DISCRIMINATOR","TRANSFER_DISCRIMINATOR","COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR","APPROVE_DISCRIMINATOR","REVOKE_DISCRIMINATOR","ADD_TOKEN_POOL_DISCRIMINATOR","checkTokenPoolInfo","tokenPoolInfo","mint","equals","Error","isInitialized","toBase58","async","getTokenPoolInfos","rpc","commitment","addressesAndBumps","Array","length","_","i","CompressedTokenProgram","deriveTokenPoolPdaWithIndex","accountInfos","getMultipleAccountsInfo","map","addressAndBump","parsedInfos","unpackAccount","owner","tokenProgram","parsedInfo","tokenPoolPda","address","activity","undefined","balance","bn","amount","toString","poolIndex","bump","Action","shuffleArray","array","j","Math","floor","random","selectTokenPoolInfo","infos","filteredInfos","filter","info","selectTokenPoolInfosForDecompression","decompressAmount","sufficientBalanceInfo","find","gte","mul","sort","a","b","every","isZero","ERROR_NO_ACCOUNTS_FOUND","selectTokenAccountsForApprove","accounts","approveAmount","maxInputs","exactMatch","account","parsed","eq","compressedAccount","lamports","selectMinCompressedTokenAccountsForTransfer","transferAmount","selectedAccounts","accumulatedAmount","accumulatedLamports","maxPossibleAmount","selectMinCompressedTokenAccountsForTransferOrPartial","lt","totalBalance","reduce","acc","add","cmp","push","slice","total","console","log","selectSmartCompressedTokenAccountsForTransferOrPartial","nonZeroAccounts","remainingAccounts","smallestAccount","min","max","packCompressedTokenAccounts","params","inputCompressedTokenAccounts","outputStateTreeInfo","rootIndices","tokenTransferOutputs","_remainingAccounts","delegateIndex","delegate","getIndexOrAdd","packedInputTokenData","forEach","index","merkleTreePubkeyIndex","treeInfo","tree","queuePubkeyIndex","queue","merkleContext","leafIndex","proveByIndex","rootIndex","tlv","activeTreeInfo","nextTreeInfo","activeTreeOrQueue","treeType","TreeType","StateV2","featureFlags","isV2","paddedOutputStateMerkleTrees","padOutputStateMerkleTrees","packedOutputTokenData","merkleTreeIndex","_a","remainingAccountMetas","pubkey","isWritable","isSigner","inputTokenDataWithContext","checkMint","compressedTokenAccounts","Layout","constructor","span","property","Number","isInteger","TypeError","this","makeDestinationObject","decode","offset","encode","src","getSpan","RangeError","replicate","rv","Object","create","prototype","assign","fromArray","values","nameWithProperty","name","lo","Layout_1","bindConstructorLayout","Class","layout","hasOwnProperty","layout_","boundConstructor_","defineProperty","value","writable","ExternalLayout","isCount","GreedyCount","elementSpan","super","rem","OffsetLayout","UInt","UIntBE","readUIntLE","writeUIntLE","readUIntBE","writeUIntBE","Int","readIntLE","writeIntLE","IntBE","readIntBE","writeIntBE","V2E32","pow","divmodInt64","hi32","lo32","roundedInt64","NearUInt64","readUInt32LE","split","writeUInt32LE","NearUInt64BE","readUInt32BE","writeUInt32BE","NearInt64","readInt32LE","writeInt32LE","NearInt64BE","readInt32BE","writeInt32BE","Float","readFloatLE","writeFloatLE","FloatBE","readFloatBE","writeFloatBE","Double","readDoubleLE","writeDoubleLE","DoubleBE","readDoubleBE","writeDoubleBE","Sequence","elementLayout","count","idx","elo","v","Structure","fields","decodePrefixes","isArray","fd","e","fsp","dest","firstOffset","lastOffset","lastWrote","fv","shift","layoutFor","offsetOf","UnionDiscriminator","UnionLayoutDiscriminator","Union","discr","defaultLayout","upv","discriminator","usesPrefixDiscriminator","registry","boundGetSourceVariant","defaultGetSourceVariant","bind","getSourceVariant","configGetSourceVariant","gsv","vlo","getVariant","tag","dlo","clo","contentOffset","addVariant","variant","VariantLayout","vb","isBuffer","union","fixBitwiseResult","BitStructure","word","msb","_packedSetValue","_packedGetValue","addField","bits","bf","BitField","addBoolean","Boolean","fieldFor","container","totalBits","usedBits","sum","valueMask","start","wordMask","wordValue","call","Blob","write","CString","srcb","copy","UTF8","maxSpan","Constant","greedy","u8","u16","u24","u32","u40","u48","nu64","u16be","u24be","u32be","u40be","u48be","nu64be","s8","s16","s24","s32","s40","s48","ns64","s16be","s24be","s32be","s40be","s48be","ns64be","f32","f32be","f64","f64be","struct","seq","unionLayoutDiscriminator","blob","cstr","utf8","const","module","exports","assert","val","msg","inherits","ctor","superCtor","super_","TempCtor","BN","number","base","endian","isBN","negative","words","red","_init","wordSize","window","require$$0","parseHex4Bits","string","c","charCodeAt","parseHexByte","lowerBound","r","parseBase","str","end","len","move","num","left","right","_initNumber","_initArray","replace","_parseHex","_parseBase","toArray","ceil","w","off","_strip","limbLen","limbPow","mod","imuln","_iaddn","_move","clone","_expand","size","_normSign","Symbol","for","inspect","zeros","groupSizes","groupBases","smallMulTo","self","out","carry","k","ncarry","rword","maxJ","padding","groupSize","groupBase","modrn","idivn","toNumber","ret","toJSON","toBuffer","toArrayLike","ArrayType","byteLength","reqLength","res","allocUnsafe","allocate","_toArrayLikeLE","position","_toArrayLikeBE","clz32","_countBits","t","_zeroBits","bitLength","hi","zeroBits","toTwos","width","abs","inotn","iaddn","fromTwos","testn","notn","ineg","isNeg","neg","iuor","ior","or","uor","iuand","iand","and","uand","iuxor","ixor","xor","uxor","bytesNeeded","bitsLeft","setn","bit","wbit","iadd","isub","sub","comb10MulTo","mid","o","a0","al0","ah0","a1","al1","ah1","a2","al2","ah2","a3","al3","ah3","a4","al4","ah4","a5","al5","ah5","a6","al6","ah6","a7","al7","ah7","a8","al8","ah8","a9","al9","ah9","b0","bl0","bh0","b1","bl1","bh1","b2","bl2","bh2","b3","bl3","bh3","b4","bl4","bh4","b5","bl5","bh5","b6","bl6","bh6","b7","bl7","bh7","b8","bl8","bh8","b9","bl9","bh9","w0","imul","w1","w2","w3","w4","w5","w6","w7","w8","w9","w10","w11","w12","w13","w14","w15","w16","w17","w18","bigMulTo","hncarry","jumboMulTo","mulTo","mulf","isNegNum","muln","sqr","isqr","toBitArray","q","iushln","s","carryMask","newCarry","ishln","iushrn","hint","extended","h","mask","maskedWords","ishrn","shln","ushln","shrn","ushrn","imaskn","maskn","isubn","addn","subn","iabs","_ishlnsubmul","_wordDiv","mode","bhi","m","diff","qj","div","divmod","positive","divn","umod","divRound","dm","half","r2","andln","p","modn","egcd","x","y","A","B","C","D","g","isEven","yp","xp","im","isOdd","jm","gcd","_invmp","x1","x2","delta","cmpn","invm","bincn","ucmp","gtn","gt","gten","ltn","lten","lte","eqn","Red","toRed","ctx","convertTo","_forceRed","fromRed","convertFrom","forceRed","redAdd","redIAdd","redSub","redISub","redShl","shl","redMul","_verify2","redIMul","redSqr","_verify1","redISqr","redSqrt","sqrt","redInvm","redNeg","redPow","primes","k256","p224","p192","p25519","MPrime","n","tmp","_tmp","K256","P224","P192","P25519","prime","_prime","Mont","imod","rinv","minv","ireduce","rlen","imulK","strip","input","output","outLen","prev","next","mod3","one","nOne","lpow","z","inv","wnd","current","currentLen","mont","u","__importDefault","__esModule","default","rustEnum","vecU8","tagged","vec","bool","option","publicKey","i256","u256","i128","u128","u64","i32","i16","i8","buffer_layout_1","web3_js_1","require$$1","bn_js_1","require$$2","buffer_layout_2","enumerable","get","BNLayout","signed","i64","WrappedLayout","decoder","encoder","PublicKey","key","OptionLayout","decodeBool","encodeBool","data","wrappedLayout","receivedTag","variants","discriminant","unionLayout","MapEntryLayout","keyLayout","valueLayout","keyBytes","Map","entries","CompressedProofLayout","PackedTokenTransferOutputDataLayout","InputTokenDataWithContextLayout","DelegatedTransferLayout","CpiContextLayout","CompressedTokenInstructionDataTransferLayout","mintToLayout","batchCompressLayout","compressSplTokenAccountInstructionDataLayout","encodeMintToInstructionData","buffer","alloc","recipients","amounts","concat","Uint8Array","subarray","encodeBatchCompressInstructionData","lengthBuffer","dataBuffer","encodeCompressSplTokenAccountInstructionData","remainingAmount","cpiContext","encodeTransferInstructionData","createTokenPoolAccountsLayout","feePayer","systemProgram","cpiAuthorityPda","addTokenPoolAccountsLayout","existingTokenPoolPda","mintToAccountsLayout","defaultPubkey","programId","authority","lightSystemProgram","registeredProgramPda","noopProgram","accountCompressionAuthority","accountCompressionProgram","merkleTree","selfProgram","solPoolPda","transferAccountsLayout","compressOrDecompressTokenAccount","approveAccountsLayout","revokeAccountsLayout","freezeAccountsLayout","thawAccountsLayout","CompressedTokenInstructionDataApproveLayout","CompressedTokenInstructionDataRevokeLayout","emptyProof","fill","isEmptyProof","proof","encodeApproveInstructionData","proofOption","encodeRevokeInstructionData","sumUpTokenAmount","validateSameTokenOwner","parseTokenData","currentOwner","parseMaybeDelegatedTransfer","inputs","outputs","delegatedAccountsIndex","findIndex","delegatedTransfer","delegateChangeAccountIndex","createTransferOutputState","toAddress","inputAmount","inputLamports","sumUpLamports","changeAmount","validateSufficientBalance","validateSameOwner","createDecompressOutputState","setProgramId","deriveTokenPoolPda","seeds","findProgramAddressSync","findTokenPoolIndexAndBump","poolPda","derivedPda","deriveCpiAuthorityPda","createMint","freezeAuthority","decimals","rentExemptBalance","tokenProgramId","mintSize","TOKEN_PROGRAM_ID","SystemProgram","createAccount","fromPubkey","newAccountPubkey","space","MINT_SIZE","createInitializeMint2Instruction","createTokenPool","keys","TransactionInstruction","addTokenPool","mintTo","toPubkey","systemKeys","defaultStaticAccountsStruct","toPubkeys","LightSystemProgram","approveAndMintTo","authorityTokenAccount","amountBigInt","BigInt","createMintToInstruction","compress","payer","source","transfer","recentValidityProof","recentInputStateRootIndices","outputCompressedAccounts","compressOrDecompressAmount","isCompress","lamportsChangeAccountMerkleTreeIndex","createTokenProgramLookupTable","mints","recentSlot","allKeys","ComputeBudgetProgram","defaultTestStateTreeAccounts","nullifierQueue","addressTree","addressQueue","TOKEN_2022_PROGRAM_ID","seen","Set","dedupedKeys","keyStr","has","createInstruction","lookupTableAddress","AddressLookupTableProgram","createLookupTable","instructions","chunk","extendIx","extendLookupTable","lookupTable","addresses","amountArray","toAddressArray","pubkeys","amt","amountBN","decompress","tokenPoolInfos","tokenPoolInfosArray","mergeTokenAccounts","compressSplTokenAccount","tokenAccount","getMintProgramId","connection","getAccountInfo","approve","CHANGE_INDEX","delegatedAmount","delegateMerkleTreeIndex","changeAccountMerkleTreeIndex","delegateLamports","revoke","outputAccountMerkleTreeIndex","COMPRESSED_MINT_SEED","findMintAddress","mintSigner","COMPRESSED_TOKEN_PROGRAM_ID","version","docs","isMut","args","type","isOptional","defined","types","kind","errors","code","numMaxAdditionalPools","confirmOptions","uninitializedIndices","blockhash","getLatestBlockhash","tx","buildAndSignTx","sendAndConfirmTx","getCompressedTokenAccountsByOwner","inputAccounts","items","getValidityProofV0","hash","ix","compressedProof","additionalSigners","dedupeSigner","signedTx","setComputeUnitLimit","units","selectStateTreeInfo","getStateTreeInfos","getOrCreateAssociatedTokenAccount","ixs","sourceTokenAccount","compressIx","blockhashCtx","mintAuthority","keypair","Keypair","generate","getMinimumBalanceForRentExemption","resolvedTokenProgramId","signer","txId","transactionSignature","additionalAccounts","getSlot","txIds","instruction","selectedTokenPoolInfos","getCompressedTokenAccountsByDelegate","tokenPoolInfosToUse","mintSeed","addressTreeInfo","deriveAddressV2","toBytes","batch","getValidityProof","batchInstructions","checkOwner","some","checkIsDelegated","totalLamports"],"mappings":"syqBACa,MAAAA,GAAYC,EAAOC,KAAK,QAExBC,GAAqBF,EAAOC,KAAK,iBAIjCE,GAAkCH,EAAOC,KAAK,CACvD,GAAI,IAAK,GAAI,IAAK,IAAK,IAAK,IAAK,MAExBG,GAAwBJ,EAAOC,KAAK,CAC7C,IAAK,GAAI,GAAI,IAAK,GAAI,IAAK,IAAK,MAEvBI,GAA+BL,EAAOC,KAAK,CACpD,GAAI,IAAK,IAAK,GAAI,IAAK,GAAI,IAAK,MAEvBK,GAAyBN,EAAOC,KAAK,CAC9C,IAAK,GAAI,IAAK,IAAK,IAAK,EAAG,GAAI,MAEtBM,GAA2CP,EAAOC,KAAK,CAChE,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,KAG1BO,GAAwBR,EAAOC,KAAK,CAC7C,GAAI,GAAI,IAAK,GAAI,IAAK,IAAK,GAAI,KAEtBQ,GAAuBT,EAAOC,KAAK,CAC5C,IAAK,GAAI,GAAI,GAAI,IAAK,IAAK,GAAI,MAEtBS,GAA+BV,EAAOC,KAAK,CACpD,IAAK,IAAK,IAAK,GAAI,GAAI,IAAK,EAAG,MClBnB,SAAAU,GACZC,EACAC,GAEA,IAAKD,EAAcC,KAAKC,OAAOD,GAC3B,MAAM,IAAIE,MAAM,oDAGpB,IAAKH,EAAcI,cACf,MAAM,IAAID,MACN,iFAAiFF,EAAKI,qCAG9F,OAAO,CACX,CAUOC,eAAeC,GAClBC,EACAP,EACAQ,GAEA,MAAMC,EAAoBC,MAAMtB,KAAK,CAAEuB,OAAQ,IAAK,CAACC,EAAGC,IACpDC,GAAuBC,4BAA4Bf,EAAMa,KAGvDG,QAAqBT,EAAIU,wBAC3BR,EAAkBS,KAAIC,GAAkBA,EAAe,KACvDX,GAGJ,GAAwB,OAApBQ,EAAa,GACb,MAAM,I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