require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`);require(`../../constants/protocol.constants.cjs`);const t=require(`../../functions/pre-transaction/solana.cjs`),n=require(`../../error-handling/error-codes.constants.cjs`),r=require(`../../functions/utils/solanaMint.utils.cjs`),i=require(`../../functions/utils/addresses.cjs`),a=require(`../../functions/utils/token-check.utils.cjs`),o=require(`../../functions/utils/create-provider.cjs`),s=require(`../../functions/pre-transaction/constructAdminData.cjs`),c=require(`../AccountActions/AccountActions.cjs`),l=require(`../../functions/pre-transaction/sendV0Transaction.cjs`),u=require(`../../API/admin-calls.cjs`);let d=require(`@coral-xyz/anchor`),f=require(`@solana/web3.js`),p=require(`@solana/spl-token`);var m=async({program:e,mintPublicKey:n,mintAddressString:r,tokenAmount:i,anchorStealthStructure:a,senderPublickey:o,originalDeployer:s,storageAccount:c,storageVault:l})=>{let u=new d.BN(i.toString()),f=t.getTokenLimitStorageAccountPublicKey(e.programId,s,n),p=r===`11111111111111111111111111111111`?null:n,m=r===`11111111111111111111111111111111`?null:void 0;return e.methods.prooflessDeposit(u,a).accounts({mint:p,signer:o,signerAta:m,originalDeployer:s,storageAccount:c,storageVault:l,tokenLimitStorage:f,storageVaultAta:m,accessTokenOwner:null}).instruction()},h=async(a,s,l,u,d,h)=>{let g=h??a.getRecipientInfo();if(!i.isValidPrivateAddress(g))throw Error(n.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);let _=c.AccountActions.getAddressFromSubAccount(s,d);if(!_)throw Error(`Public account address is not available`);let{hinkalIdl:v,hinkalAddress:y,originalDeployer:b}=e.networkRegistry[s].contractData;if(!v)throw Error(`No IDL configured for Solana program on this network`);if(!b)throw Error(`missing original deployer`);let x=a.getSolanaProgram(v),S=new f.PublicKey(b),C=new f.PublicKey(y),w=new f.PublicKey(_),{erc20TokenAddress:T}=l,{fetchRpcUrl:E}=e.networkRegistry[s];if(!E)throw Error(`RPC URL not found for the specified chain ID`);let D=o.createCustomSolanaConnection(E),{mintPublicKey:O}=r.formatMintAddress(T),k=O.toString(),A=t.getStorageAccountPublicKey(C,S),j=t.getStorageVaultPublicKey(C,S),M=await m({program:x,mintPublicKey:O,mintAddressString:k,tokenAmount:u,anchorStealthStructure:t.buildAnchorStealthAddressStructure(i.constructStealthAddressStructure(g)),senderPublickey:w,originalDeployer:S,storageAccount:A,storageVault:j}),N=l.is2022Program?p.TOKEN_2022_PROGRAM_ID:p.TOKEN_PROGRAM_ID;return{connection:D,senderAddress:_,senderPublickey:w,instructions:[M],storageAccount:A,programId:N}},g=async(e,t,n,r,i,o)=>{if(!r)throw Error(`subAccount is required`);let c=a.validateAndGetChainId([t]),[{connection:d,senderPublickey:f,instructions:p},m]=await Promise.all([h(e,c,t,n,r,i),e.getEthereumAddress()]),g=await l.sendProxyV0Transaction({connection:d,chainId:c,subAccount:r,payerPublicKey:f,instructions:p});return u.emitTxPublicData(s.constructAdminData(o,c,[t.erc20TokenAddress],[n],m)),g};exports.hinkalSolanaProxyShield=g;