@wormhole-foundation/wormhole-connect 2.4.0-beta.2-development → 2.4.0-beta.3-development

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.
Files changed (109) hide show
  1. package/dist/assets/{aptos-C2a0dQjT.js → aptos-BaxuZv2A.js} +2 -2
  2. package/dist/assets/{ccip-OC0Vc4gm.js → ccip-Br2IvhSW.js} +1 -1
  3. package/dist/assets/{evm-BqmuByVY.js → evm-CEkHuuN5.js} +3 -3
  4. package/dist/assets/{evm-DVLSeRFU.js → evm-DajrgWJp.js} +2 -2
  5. package/dist/assets/{index-BeEE7MyN.js → index-B8SSPOGN.js} +1 -1
  6. package/dist/assets/{index-CODUkWzQ.js → index-BGgxsbk4.js} +1 -1
  7. package/dist/assets/{index-iO-U9jSW.js → index-BIKKjy76.js} +2 -2
  8. package/dist/assets/{index-CB3XpWtg.js → index-BWKZaYh0.js} +1 -1
  9. package/dist/assets/{index-CvqWMPrS.js → index-BxMnYxyf.js} +1 -1
  10. package/dist/assets/{index-PnI0Le4b.js → index-CIIbEJG8.js} +1 -1
  11. package/dist/assets/{index-BIdhtTCf.js → index-D1RqQWR4.js} +1 -1
  12. package/dist/assets/{index-BVlgnsQb.js → index-DVzhMXXA.js} +1 -1
  13. package/dist/assets/{index-COKaKwn8.js → index-DnDUIJZk.js} +1 -1
  14. package/dist/assets/{index-Dcsj5S2N.js → index-DwbsyLxo.js} +1 -1
  15. package/dist/assets/index-GDpnrg5w.js +1 -0
  16. package/dist/assets/{index-M4NDMEge.js → index-ICy6eYwP.js} +1 -1
  17. package/dist/assets/{index-C1Dta-NJ.js → index-Zgbd9ue1.js} +1 -1
  18. package/dist/assets/{index-BZDxvV4g.js → index-ndTMsj-g.js} +1 -1
  19. package/dist/assets/{index-CBMmMx3W.js → index-ylKZk0sO.js} +1 -1
  20. package/dist/assets/{index-C-kVvSEJ.js → index-z2SBICrL.js} +1 -1
  21. package/dist/assets/{index.es-j8vEfzbO.js → index.es-AACkekVm.js} +6 -6
  22. package/dist/assets/{solana-pOvS3swt.js → solana-Cli5bij_.js} +2 -2
  23. package/dist/assets/solana-DlYSFsGk.js +2 -0
  24. package/dist/assets/solanaEmbed.esm-P5uPPwsm.js +37 -0
  25. package/dist/assets/{sui-DZhbOaP_.js → sui-76yNbUUP.js} +2 -2
  26. package/dist/main.js +114 -114
  27. package/lib/{aptos-DnLzj1Pw.js → aptos-CSvcKEJm.js} +1 -1
  28. package/lib/{aptos-UMYBfX-e.mjs → aptos-D3RPZgif.mjs} +5 -5
  29. package/lib/{aptos-BFg97d8i.js → aptos-WpCc6eOD.js} +2 -2
  30. package/lib/{aptos-BPPKNPmY.mjs → aptos-cEXzuL5b.mjs} +2 -2
  31. package/lib/{base64-dhNbNdy2.js → base64-C73YLbqA.js} +1 -1
  32. package/lib/{base64-BxOseFtQ.mjs → base64-D3sIs-fw.mjs} +1 -1
  33. package/lib/{ccip-Cc7zIRbR.mjs → ccip-BJTawxQ_.mjs} +1 -1
  34. package/lib/{ccip-DnuA-mnD.js → ccip-CaksatNz.js} +1 -1
  35. package/lib/{chunk-IMTC3J2M-DmAiw2IO.js → chunk-IMTC3J2M-DKXvnM6O.js} +1 -1
  36. package/lib/{chunk-IMTC3J2M-C3XVaTOx.mjs → chunk-IMTC3J2M-Dsnj4Vih.mjs} +3 -3
  37. package/lib/{evm-2u0XA9Kv.mjs → evm-Bs0OjXvE.mjs} +5 -5
  38. package/lib/{evm-DBg_gIux.js → evm-DNBYBo_p.js} +1 -1
  39. package/lib/{evm-BPMdXFY7.mjs → evm-D_aPV3AL.mjs} +6 -6
  40. package/lib/{evm-jazxlq_v.js → evm-Wv2nh7z1.js} +3 -3
  41. package/lib/{index-BEqeue2k.js → index--95bwciz.js} +1 -1
  42. package/lib/{index-DYo59dOt.mjs → index-9pPnVz73.mjs} +2 -2
  43. package/lib/{index-DrYmbAqE.mjs → index-B2VBT3u7.mjs} +2 -2
  44. package/lib/{index-CvO9BKU8.js → index-BCrWCNUq.js} +1 -1
  45. package/lib/{index-B9gGuUKR.js → index-BH-EfOl1.js} +1 -1
  46. package/lib/{index-_Tjd635F.js → index-BZpnoMd1.js} +1 -1
  47. package/lib/{index-DpL4G1gV.js → index-BeGnKztN.js} +1 -1
  48. package/lib/{index-cibSzunr.mjs → index-BpKxYGa-.mjs} +2 -2
  49. package/lib/{index-C_8uENxB.js → index-BrFIzqtL.js} +1 -1
  50. package/lib/{index-CLSG0-PT.mjs → index-BtA_-iXv.mjs} +2 -2
  51. package/lib/{index-BZO8YmLX.js → index-BvdMRpl6.js} +1 -1
  52. package/lib/{index-BH5x8knT.mjs → index-Bx5QNYj7.mjs} +1 -1
  53. package/lib/{index-BZijFWem.js → index-Bzn58Yhp.js} +1 -1
  54. package/lib/{index-C7jR2tws.js → index-C5rfYL4K.js} +1 -1
  55. package/lib/{index-DSVsrZrI.js → index-C6Hp_1yF.js} +1 -1
  56. package/lib/{index-geFlOFCr.js → index-CMw2Uill.js} +1 -1
  57. package/lib/{index-CLqF0DXs.mjs → index-COqO8I1C.mjs} +1 -1
  58. package/lib/{index-ndWybTXw.mjs → index-CUMRJ8yy.mjs} +10142 -9468
  59. package/lib/{index-B71D5i2u.js → index-CUSJAO56.js} +1 -1
  60. package/lib/{index-Ce7gKFw8.js → index-Cb51fnZM.js} +1 -1
  61. package/lib/{index-BH-QrHNF.mjs → index-CcEA2K6Q.mjs} +1 -1
  62. package/lib/{index-D6PJJHPq.mjs → index-Ci0LEPmE.mjs} +2 -2
  63. package/lib/{index-gsKAo8iZ.js → index-CjgM-0OC.js} +1 -1
  64. package/lib/{index-C0mg2EaP.js → index-Cvtp4dgE.js} +120 -120
  65. package/lib/{index-DxHy5H3l.mjs → index-D0NbpzAg.mjs} +1 -1
  66. package/lib/{index-DBF3Orza.mjs → index-D19OP8Mu.mjs} +2 -2
  67. package/lib/{index-CwnW1iXz.js → index-D7f2-3wk.js} +1 -1
  68. package/lib/{index-BudY-hBZ.js → index-DCRe22Ms.js} +1 -1
  69. package/lib/{index-INXKBIVC.mjs → index-DGGMUOzp.mjs} +3 -3
  70. package/lib/{index-BhZP5awL.js → index-DIqG9W_r.js} +1 -1
  71. package/lib/{index-DqPgH3Y4.js → index-DLeUCqIq.js} +1 -1
  72. package/lib/{index-CyPQH2yv.js → index-DNBuc7tl.js} +1 -1
  73. package/lib/{index-C2ecpt8K.mjs → index-DRMwoM8a.mjs} +4 -4
  74. package/lib/{index-B6Sz2PUf.mjs → index-DRYbBPuh.mjs} +2 -2
  75. package/lib/{index-Dw6DmujE.mjs → index-DS_rORqD.mjs} +1 -1
  76. package/lib/{index-DbgMQX1m.mjs → index-DYrT7_2n.mjs} +1 -1
  77. package/lib/{index-C7SwBJ74.mjs → index-DfPjBy3w.mjs} +1 -1
  78. package/lib/{index-BbuYs0Vv.mjs → index-DqRhhSXa.mjs} +2 -2
  79. package/lib/{index-CVVdam36.mjs → index-DwhWt2Jt.mjs} +1 -1
  80. package/lib/{index-Cleh-XCA.mjs → index-KpBoUsX2.mjs} +1 -1
  81. package/lib/{index-3LktUEbt.js → index-ZK1P1tUH.js} +1 -1
  82. package/lib/{index-CrDmkPiL.mjs → index-ctEY-xjJ.mjs} +3 -3
  83. package/lib/{index-DCXyETk0.mjs → index-e3oHdOB4.mjs} +1 -1
  84. package/lib/{index-CSWNAyvZ.mjs → index-q570DLLo.mjs} +2 -2
  85. package/lib/{index-CiFOveV0.js → index-tzTI5R9c.js} +1 -1
  86. package/lib/{index-DS1ZxkfX.js → index-v-_ti7Rn.js} +1 -1
  87. package/lib/{index.es-DaqXRV0H.mjs → index.es-By1LsNow.mjs} +5 -5
  88. package/lib/{index.es-D-KoMtU-.js → index.es-Czhf3Th8.js} +2 -2
  89. package/lib/index.js +1 -1
  90. package/lib/index.mjs +1 -1
  91. package/lib/{signer-CGCrqc_x.mjs → signer-CcpDR9mm.mjs} +1 -1
  92. package/lib/{signer-Cr8jlyL3.js → signer-jV9Ixq8U.js} +1 -1
  93. package/lib/{solana-BkE0Vobm.js → solana-4YAkIi-J.js} +1 -1
  94. package/lib/{solana-YmPJnJBl.mjs → solana-Bo2aMvX4.mjs} +4 -4
  95. package/lib/solana-DA02fWu7.mjs +17 -0
  96. package/lib/solana-DVFk6Z5q.js +1 -0
  97. package/lib/{solanaEmbed.esm-QawbC8eJ.mjs → solanaEmbed.esm-4CS_00aM.mjs} +1 -1
  98. package/lib/{solanaEmbed.esm-LQoue5a0.js → solanaEmbed.esm-B-rprhcd.js} +1 -1
  99. package/lib/{sui-BwFJqgyM.mjs → sui-BGaWik82.mjs} +1 -1
  100. package/lib/{sui-DZg5qrE0.js → sui-BgD7gx67.js} +1 -1
  101. package/lib/{sui-C88m3bWr.mjs → sui-DLOfqNsy.mjs} +5 -5
  102. package/lib/{sui-CIDA-hM_.js → sui-MorjdPyy.js} +1 -1
  103. package/package.json +5 -5
  104. package/dist/assets/events-7fnqQH7x.js +0 -1
  105. package/dist/assets/index-n50xdA-U.js +0 -1
  106. package/dist/assets/solana-D-pftkkJ.js +0 -2
  107. package/dist/assets/solanaEmbed.esm-DPIgn-PE.js +0 -37
  108. package/lib/solana-Bq3a7vGW.mjs +0 -17
  109. package/lib/solana-Bw-7Gaje.js +0 -1
@@ -1 +1 @@
1
- var Pt=Object.defineProperty;var _t=(e,t,r)=>t in e?Pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var f=(e,t,r)=>_t(e,typeof t!="symbol"?t+"":t,r);import{P as c,i as l,bf as A,ci as le,bj as z,bi as U,bk as G,bh as S,bg as V,cz as Ge,cA as He,cB as Wt,cC as It,cD as Ut,cE as Nt,ct as O,ch as E,bI as y,cF as T,cG as Ft,cH as ye,ca as dt,cI as xt,cj as lt,ck as zt,cJ as Ot,cK as Q,cL as Lt,cx as H,cy as Z,cM as Dt,cu as qt,cN as Kt,cO as Vt,cP as Se,cQ as Gt,bu as v,cw as Ht,a6 as oe,a7 as k,c9 as Ce,bP as Zt,an as j,cf as Be,cR as Yt,cS as Qt,ab as ae,T as L,cT as Xt,cm as ft,bV as mt,a8 as gt}from"../main.js";const M=new c("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");new c("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");const Ae=new c("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),D=new c("So11111111111111111111111111111111111111112");new c("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP");class ee extends Error{constructor(t){super(t)}}class Re extends ee{constructor(){super(...arguments),this.name="TokenAccountNotFoundError"}}class Jt extends ee{constructor(){super(...arguments),this.name="TokenInvalidAccountError"}}class ht extends ee{constructor(){super(...arguments),this.name="TokenInvalidAccountOwnerError"}}class ce extends ee{constructor(){super(...arguments),this.name="TokenInvalidAccountSizeError"}}class jt extends ee{constructor(){super(...arguments),this.name="TokenInvalidMintError"}}class pt extends ee{constructor(){super(...arguments),this.name="TokenOwnerOffCurveError"}}var $;(function(e){e[e.InitializeMint=0]="InitializeMint",e[e.InitializeAccount=1]="InitializeAccount",e[e.InitializeMultisig=2]="InitializeMultisig",e[e.Transfer=3]="Transfer",e[e.Approve=4]="Approve",e[e.Revoke=5]="Revoke",e[e.SetAuthority=6]="SetAuthority",e[e.MintTo=7]="MintTo",e[e.Burn=8]="Burn",e[e.CloseAccount=9]="CloseAccount",e[e.FreezeAccount=10]="FreezeAccount",e[e.ThawAccount=11]="ThawAccount",e[e.TransferChecked=12]="TransferChecked",e[e.ApproveChecked=13]="ApproveChecked",e[e.MintToChecked=14]="MintToChecked",e[e.BurnChecked=15]="BurnChecked",e[e.InitializeAccount2=16]="InitializeAccount2",e[e.SyncNative=17]="SyncNative",e[e.InitializeAccount3=18]="InitializeAccount3",e[e.InitializeMultisig2=19]="InitializeMultisig2",e[e.InitializeMint2=20]="InitializeMint2",e[e.GetAccountDataSize=21]="GetAccountDataSize",e[e.InitializeImmutableOwner=22]="InitializeImmutableOwner",e[e.AmountToUiAmount=23]="AmountToUiAmount",e[e.UiAmountToAmount=24]="UiAmountToAmount",e[e.InitializeMintCloseAuthority=25]="InitializeMintCloseAuthority",e[e.TransferFeeExtension=26]="TransferFeeExtension",e[e.ConfidentialTransferExtension=27]="ConfidentialTransferExtension",e[e.DefaultAccountStateExtension=28]="DefaultAccountStateExtension",e[e.Reallocate=29]="Reallocate",e[e.MemoTransferExtension=30]="MemoTransferExtension",e[e.CreateNativeMint=31]="CreateNativeMint",e[e.InitializeNonTransferableMint=32]="InitializeNonTransferableMint",e[e.InterestBearingMintExtension=33]="InterestBearingMintExtension",e[e.CpiGuardExtension=34]="CpiGuardExtension",e[e.InitializePermanentDelegate=35]="InitializePermanentDelegate",e[e.TransferHookExtension=36]="TransferHookExtension",e[e.MetadataPointerExtension=39]="MetadataPointerExtension"})($||($={}));function Ee(e,t,r){if(r.length){e.push({pubkey:t,isSigner:!1,isWritable:!1});for(const n of r)e.push({pubkey:n instanceof c?n:n.publicKey,isSigner:!0,isWritable:!1})}else e.push({pubkey:t,isSigner:!0,isWritable:!1});return e}const Ze=A([z("instruction"),U("amount")]);function $t(e,t,r,n,i=[],a=M){const o=Ee([{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t,isSigner:!1,isWritable:!1}],r,i),s=l.Buffer.alloc(Ze.span);return Ze.encode({instruction:$.Approve,amount:BigInt(n)},s),new le({keys:o,programId:a,data:s})}const Ye=A([z("instruction")]);function Qe(e,t,r,n=[],i=M){const a=Ee([{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t,isSigner:!1,isWritable:!0}],r,n),o=l.Buffer.alloc(Ye.span);return Ye.encode({instruction:$.CloseAccount},o),new le({keys:a,programId:i,data:o})}var ge;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Mint=1]="Mint",e[e.Account=2]="Account"})(ge||(ge={}));const Pe=1,en=A([z("m"),z("n"),G("isInitialized"),S("signer1"),S("signer2"),S("signer3"),S("signer4"),S("signer5"),S("signer6"),S("signer7"),S("signer8"),S("signer9"),S("signer10"),S("signer11")]),_e=en.span;var he;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initialized=1]="Initialized",e[e.Frozen=2]="Frozen"})(he||(he={}));const wt=A([S("mint"),S("owner"),U("amount"),V("delegateOption"),S("delegate"),z("state"),V("isNativeOption"),U("isNative"),U("delegatedAmount"),V("closeAuthorityOption"),S("closeAuthority")]),_=wt.span;async function tn(e,t,r,n=M){const i=await e.getAccountInfo(t,r);return rn(t,i,n)}async function Xe(e,t){return await nn(e,[],t)}async function nn(e,t,r){const n=zn(t);return await e.getMinimumBalanceForRentExemption(n,r)}function rn(e,t,r=M){if(!t)throw new Re;if(!t.owner.equals(r))throw new ht;if(t.data.length<_)throw new ce;const n=wt.decode(t.data.slice(0,_));let i=l.Buffer.alloc(0);if(t.data.length>_){if(t.data.length===_e)throw new ce;if(t.data[_]!=ge.Account)throw new Jt;i=t.data.slice(_+Pe)}return{address:e,mint:n.mint,owner:n.owner,amount:n.amount,delegate:n.delegateOption?n.delegate:null,delegatedAmount:n.delegatedAmount,isInitialized:n.state!==he.Uninitialized,isFrozen:n.state===he.Frozen,isNative:!!n.isNativeOption,rentExemptReserve:n.isNativeOption?n.isNative:null,closeAuthority:n.closeAuthorityOption?n.closeAuthority:null,tlvData:i}}const yt=A([V("mintAuthorityOption"),S("mintAuthority"),U("supply"),z("decimals"),G("isInitialized"),V("freezeAuthorityOption"),S("freezeAuthority")]),ve=yt.span;async function an(e,t,r,n=M){const i=await e.getAccountInfo(t,r);return sn(t,i,n)}function sn(e,t,r=M){if(!t)throw new Re;if(!t.owner.equals(r))throw new ht;if(t.data.length<ve)throw new ce;const n=yt.decode(t.data.slice(0,ve));let i=l.Buffer.alloc(0);if(t.data.length>ve){if(t.data.length<=_)throw new ce;if(t.data.length===_e)throw new ce;if(t.data[_]!=ge.Mint)throw new jt;i=t.data.slice(_+Pe)}return{address:e,mintAuthority:n.mintAuthorityOption?n.mintAuthority:null,supply:n.supply,decimals:n.decimals,isInitialized:n.isInitialized,freezeAuthority:n.freezeAuthorityOption?n.freezeAuthority:null,tlvData:i}}async function Je(e,t,r=!1,n=M,i=Ae){if(!r&&!c.isOnCurve(t.toBuffer()))throw new pt;const[a]=await c.findProgramAddress([t.toBuffer(),n.toBuffer(),e.toBuffer()],i);return a}function We(e,t,r=!1,n=M,i=Ae){if(!r&&!c.isOnCurve(t.toBuffer()))throw new pt;const[a]=c.findProgramAddressSync([t.toBuffer(),n.toBuffer(),e.toBuffer()],i);return a}const on=A([G("lockCpi")]),cn=on.span,un=A([z("state")]),dn=un.span,ln=A([]),fn=ln.span,mn=A([S("rateAuthority"),Ge("initializationTimestamp"),He("preUpdateAverageRate"),Ge("lastUpdateTimestamp"),He("currentRate")]),gn=mn.span,hn=A([G("requireIncomingTransferMemos")]),pn=hn.span,wn=A([S("authority"),S("metadataAddress")]),yn=wn.span,Sn=A([S("closeAuthority")]),An=Sn.span,St=A([]),Mn=St.span,kn=St.span,bn=A([S("delegate")]),Tn=bn.span,Cn=1e4;BigInt(Cn);function je(e){return A([U("epoch"),U("maximumFee"),Wt("transferFeeBasisPoints")],e)}const vn=A([S("transferFeeConfigAuthority"),S("withdrawWithheldAuthority"),U("withheldAmount"),je("olderTransferFee"),je("newerTransferFee")]),Bn=vn.span,Rn=A([U("withheldAmount")]),En=Rn.span,Pn=A([S("authority"),S("programId")]),_n=Pn.span,Wn=A([G("transferring")]),In=Wn.span,$e=A([z("discriminator"),It(32,"addressConfig"),G("isSigner"),G("isWritable")]),Un=A([V("count"),Ut($e,Nt($e.span),"extraAccounts")]);A([U("instructionDiscriminator"),V("length"),Un.replicate("extraAccountsList")]);var b;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.TransferFeeConfig=1]="TransferFeeConfig",e[e.TransferFeeAmount=2]="TransferFeeAmount",e[e.MintCloseAuthority=3]="MintCloseAuthority",e[e.ConfidentialTransferMint=4]="ConfidentialTransferMint",e[e.ConfidentialTransferAccount=5]="ConfidentialTransferAccount",e[e.DefaultAccountState=6]="DefaultAccountState",e[e.ImmutableOwner=7]="ImmutableOwner",e[e.MemoTransfer=8]="MemoTransfer",e[e.NonTransferable=9]="NonTransferable",e[e.InterestBearingConfig=10]="InterestBearingConfig",e[e.CpiGuard=11]="CpiGuard",e[e.PermanentDelegate=12]="PermanentDelegate",e[e.NonTransferableAccount=13]="NonTransferableAccount",e[e.TransferHook=14]="TransferHook",e[e.TransferHookAccount=15]="TransferHookAccount",e[e.MetadataPointer=18]="MetadataPointer"})(b||(b={}));const et=2,Nn=2;function Fn(e){switch(e){case b.Uninitialized:return 0;case b.TransferFeeConfig:return Bn;case b.TransferFeeAmount:return En;case b.MintCloseAuthority:return An;case b.ConfidentialTransferMint:return 97;case b.ConfidentialTransferAccount:return 286;case b.CpiGuard:return cn;case b.DefaultAccountState:return dn;case b.ImmutableOwner:return fn;case b.MemoTransfer:return pn;case b.MetadataPointer:return yn;case b.NonTransferable:return Mn;case b.InterestBearingConfig:return gn;case b.PermanentDelegate:return Tn;case b.NonTransferableAccount:return kn;case b.TransferHook:return _n;case b.TransferHookAccount:return In;default:throw Error(`Unknown extension type: ${e}`)}}function xn(e,t){if(e.length===0)return t;{const r=_+Pe+e.filter((n,i)=>i===e.indexOf(n)).map(n=>Fn(n)+et+Nn).reduce((n,i)=>n+i);return r===_e?r+et:r}}function zn(e){return xn(e,_)}const tt=A([z("instruction")]);function nt(e,t,r,n=M){const i=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:O,isSigner:!1,isWritable:!1}],a=l.Buffer.alloc(tt.span);return tt.encode({instruction:$.InitializeAccount},a),new le({keys:i,programId:n,data:a})}function At(e,t,r,n,i=M,a=Ae){return On(e,t,r,n,l.Buffer.alloc(0),i,a)}function On(e,t,r,n,i,a=M,o=Ae){const s=[{pubkey:e,isSigner:!0,isWritable:!0},{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:E.programId,isSigner:!1,isWritable:!1},{pubkey:a,isSigner:!1,isWritable:!1}];return new le({keys:s,programId:o,data:i})}const rt=A([z("instruction"),U("amount")]);function Ln(e,t,r,n,i=[],a=M){const o=Ee([{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t,isSigner:!1,isWritable:!0}],r,i),s=l.Buffer.alloc(rt.span);return rt.encode({instruction:$.Transfer,amount:BigInt(n)},s),new le({keys:o,programId:a,data:s})}function Ie(e,t){const r=l.Buffer.alloc(2);return r.writeUInt16BE(y(t)),T([l.Buffer.from("foreign_contract"),r],e)}function Dn(e){return T([l.Buffer.from("redeemer")],e)}function Ue(e,t){return T([l.Buffer.from("mint"),new c(t).toBuffer()],e)}function Mt(e){return T([l.Buffer.from("sender")],e)}function kt(e,t){return T([l.Buffer.from("tmp"),new c(t).toBuffer()],e)}function bt(e,t,r){return T([l.Buffer.from("bridged"),new c(t).toBuffer(),l.Buffer.from(Ft.toBytes(BigInt(r.toString()),8))],e)}function B(e){return T([l.Buffer.from("config")],e)}async function Rr(e,t,r){return e.getAccountInfo(B(t),r).then(n=>Ne.deserialize(ye(n)))}class Ne{constructor(t){f(this,"wormhole");this.wormhole=new c(t)}static deserialize(t){if(t.length!=32)throw new Error("data.length != 32");const r=t.subarray(0,32);return new Ne(r)}}function Me(e,t){return T([new c(t).toBuffer()],e)}function te(e,t,r){if(t==y("Solana"))throw new Error("emitterChain == CHAIN_ID_SOLANA cannot exist as foreign token bridge emitter");const n=typeof r=="string"?new dt(r).toUint8Array():r;return T([(()=>{const i=l.Buffer.alloc(2);return i.writeUInt16BE(t),i})(),n],e)}async function Er(e,t,r){return e.getAccountInfo(new c(t),r).then(n=>Fe.deserialize(ye(n)))}class Fe{constructor(t,r){f(this,"chain");f(this,"contract");this.chain=t,this.contract=r}static deserialize(t){if(t.length!=34)throw new Error("data.length != 34");const r=t.readUInt16LE(0),n=t.subarray(2,34);return new Fe(r,n)}}function xe(e){return T([l.Buffer.from("sender")],e)}function ze(e){return T([l.Buffer.from("redeemer")],e)}function ne(e){return T([l.Buffer.from("authority_signer")],e)}function fe(e){return T([l.Buffer.from("custody_signer")],e)}function ke(e){return T([l.Buffer.from("mint_signer")],e)}function re(e,t,r){if(t==y("Solana"))throw new Error("tokenChain == CHAIN_ID_SOLANA does not have wrapped mint key");return T([l.Buffer.from("wrapped"),(()=>{const n=l.Buffer.alloc(2);return n.writeUInt16BE(t),n})(),r],e)}function Y(e,t){return T([l.Buffer.from("meta"),new c(t).toBuffer()],e)}async function me(e,t,r,n){return e.getAccountInfo(Y(t,r),n).then(i=>Oe.deserialize(ye(i)))}class Oe{constructor(t,r,n,i){f(this,"chain");f(this,"tokenAddress");f(this,"originalDecimals");f(this,"lastUpdatedSequence");this.chain=t,this.tokenAddress=r,this.originalDecimals=n,this.lastUpdatedSequence=i}static deserialize(t){if(t.length!==35&&t.length!==43)throw new Error(`invalid wrapped meta length: ${t.length}`);const r=t.readUInt16LE(0),n=t.subarray(2,34),i=t.readUInt8(34),a=t.length===43?t.readBigUInt64LE(35):void 0;return new Oe(r,n,i,a)}}function it(e,t,r,n){return $t(new c(t),ne(e),new c(r),n)}class qn{constructor(t){f(this,"idl");this.idl=t}async encode(t,r){switch(t){default:throw new Error(`Invalid account name: ${t}`)}}decode(t,r){return this.decodeUnchecked(t,r)}decodeUnchecked(t,r){switch(t){default:throw new Error(`Invalid account name: ${t}`)}}memcmp(t,r){switch(t){default:throw new Error(`Invalid account name: ${t}`)}}size(t){return xt(this.idl,t)??0}}class Kn{constructor(t){}decode(t){throw new Error("Token Bridge program does not have events")}}class Vn{constructor(t){}encode(t,r){switch(t){case"initialize":return Gn(r);case"attestToken":return Hn(r);case"completeNative":return Zn(r);case"completeWrapped":return Yn(r);case"transferWrapped":return Qn(r);case"transferNative":return Xn(r);case"registerChain":return Jn(r);case"createWrapped":return jn(r);case"upgradeContract":return $n(r);case"transferWrappedWithPayload":return er(r);case"transferNativeWithPayload":return tr(r);default:throw new Error(`Invalid instruction: ${t}`)}}encodeState(t,r){throw new Error("Token Bridge program does not have state")}}var P;(function(e){e[e.Initialize=0]="Initialize",e[e.AttestToken=1]="AttestToken",e[e.CompleteNative=2]="CompleteNative",e[e.CompleteWrapped=3]="CompleteWrapped",e[e.TransferWrapped=4]="TransferWrapped",e[e.TransferNative=5]="TransferNative",e[e.RegisterChain=6]="RegisterChain",e[e.CreateWrapped=7]="CreateWrapped",e[e.UpgradeContract=8]="UpgradeContract",e[e.CompleteNativeWithPayload=9]="CompleteNativeWithPayload",e[e.CompleteWrappedWithPayload=10]="CompleteWrappedWithPayload",e[e.TransferWrappedWithPayload=11]="TransferWrappedWithPayload",e[e.TransferNativeWithPayload=12]="TransferNativeWithPayload"})(P||(P={}));function N(e,t){const r=t===void 0?0:t.length,n=l.Buffer.alloc(1+r);return n.writeUInt8(e,0),r>0&&n.write(t.toString("hex"),1,"hex"),n}function Gn({wormhole:e}){const t=l.Buffer.alloc(32);return t.write(new c(e).toBuffer().toString("hex"),0,"hex"),N(P.Initialize,t)}function Hn({nonce:e}){const t=l.Buffer.alloc(4);return t.writeUInt32LE(e,0),N(P.AttestToken,t)}function Zn({}){return N(P.CompleteNative)}function Yn({}){return N(P.CompleteWrapped)}function Tt({nonce:e,amount:t,fee:r,targetAddress:n,targetChain:i}){if(typeof t!="bigint"&&(t=BigInt(t)),typeof r!="bigint"&&(r=BigInt(r)),!l.Buffer.isBuffer(n))throw new Error("targetAddress must be Buffer");const a=l.Buffer.alloc(54);return a.writeUInt32LE(e,0),a.writeBigUInt64LE(t,4),a.writeBigUInt64LE(r,12),a.write(n.toString("hex"),20,"hex"),a.writeUInt16LE(i,52),a}function Qn({nonce:e,amount:t,fee:r,targetAddress:n,targetChain:i}){return N(P.TransferWrapped,Tt({nonce:e,amount:t,fee:r,targetAddress:n,targetChain:i}))}function Xn({nonce:e,amount:t,fee:r,targetAddress:n,targetChain:i}){return N(P.TransferNative,Tt({nonce:e,amount:t,fee:r,targetAddress:n,targetChain:i}))}function Jn({}){return N(P.RegisterChain)}function jn({}){return N(P.CreateWrapped)}function $n({}){return N(P.UpgradeContract)}function Ct({nonce:e,amount:t,targetAddress:r,targetChain:n,payload:i}){if(typeof t!="bigint"&&(t=BigInt(t)),!l.Buffer.isBuffer(r))throw new Error("targetAddress must be Buffer");if(!l.Buffer.isBuffer(i))throw new Error("payload must be Buffer");const a=l.Buffer.alloc(50);return a.writeUInt32LE(e,0),a.writeBigUInt64LE(t,4),a.write(r.toString("hex"),12,"hex"),a.writeUInt16LE(n,44),a.writeUInt32LE(i.length,46),l.Buffer.concat([a,i,l.Buffer.alloc(1)])}function er({nonce:e,amount:t,fee:r,targetAddress:n,targetChain:i,payload:a}){return N(P.TransferWrappedWithPayload,Ct({nonce:e,amount:t,targetAddress:n,targetChain:i,payload:a}))}function tr({nonce:e,amount:t,fee:r,targetAddress:n,targetChain:i,payload:a}){return N(P.TransferNativeWithPayload,Ct({nonce:e,amount:t,targetAddress:n,targetChain:i,payload:a}))}class nr{constructor(t){}encode(t,r){throw new Error("Token Bridge program does not have state")}decode(t){throw new Error("Token Bridge program does not have state")}}class rr{constructor(t){}encode(t,r){throw new Error("Token Bridge program does not have user-defined types")}decode(t,r){throw new Error("Token Bridge program does not have user-defined types")}}class ir{constructor(t){f(this,"instruction");f(this,"accounts");f(this,"state");f(this,"events");f(this,"types");this.instruction=new Vn(t),this.accounts=new qn(t),this.state=new nr(t),this.events=new Kn(t),this.types=new rr(t)}}const vt={version:"0.1.0",name:"wormhole",instructions:[{name:"initialize",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"config",isMut:!0,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"wormhole",type:"publicKey"}]},{name:"attestToken",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"config",isMut:!0,isSigner:!1},{name:"mint",isMut:!1,isSigner:!1},{name:"wrappedMeta",isMut:!1,isSigner:!1},{name:"splMetadata",isMut:!1,isSigner:!1},{name:"wormholeBridge",isMut:!0,isSigner:!1},{name:"wormholeMessage",isMut:!0,isSigner:!0},{name:"wormholeEmitter",isMut:!1,isSigner:!1},{name:"wormholeSequence",isMut:!0,isSigner:!1},{name:"wormholeFeeCollector",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1}],args:[{name:"nonce",type:"u32"}]},{name:"completeNative",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"config",isMut:!1,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"endpoint",isMut:!1,isSigner:!1},{name:"to",isMut:!0,isSigner:!1},{name:"toFees",isMut:!0,isSigner:!1},{name:"custody",isMut:!0,isSigner:!1},{name:"mint",isMut:!1,isSigner:!1},{name:"custodySigner",isMut:!1,isSigner:!1},{name:"rent",isMut:!0,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1}],args:[]},{name:"completeWrapped",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"config",isMut:!1,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"endpoint",isMut:!1,isSigner:!1},{name:"to",isMut:!0,isSigner:!1},{name:"toFees",isMut:!0,isSigner:!1},{name:"mint",isMut:!0,isSigner:!1},{name:"wrappedMeta",isMut:!1,isSigner:!1},{name:"mintAuthority",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1}],args:[]},{name:"transferWrapped",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"config",isMut:!1,isSigner:!1},{name:"from",isMut:!0,isSigner:!1},{name:"fromOwner",isMut:!0,isSigner:!0},{name:"mint",isMut:!0,isSigner:!1},{name:"wrappedMeta",isMut:!1,isSigner:!1},{name:"authoritySigner",isMut:!1,isSigner:!1},{name:"wormholeBridge",isMut:!0,isSigner:!1},{name:"wormholeMessage",isMut:!0,isSigner:!0},{name:"wormholeEmitter",isMut:!1,isSigner:!1},{name:"wormholeSequence",isMut:!0,isSigner:!1},{name:"wormholeFeeCollector",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1}],args:[{name:"nonce",type:"u32"},{name:"amount",type:"u64"},{name:"fee",type:"u64"},{name:"targetAddress",type:{array:["u8",32]}},{name:"targetChain",type:"u16"}]},{name:"transferNative",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"config",isMut:!1,isSigner:!1},{name:"from",isMut:!0,isSigner:!1},{name:"mint",isMut:!0,isSigner:!1},{name:"custody",isMut:!0,isSigner:!1},{name:"authoritySigner",isMut:!1,isSigner:!1},{name:"custodySigner",isMut:!1,isSigner:!1},{name:"wormholeBridge",isMut:!0,isSigner:!1},{name:"wormholeMessage",isMut:!0,isSigner:!0},{name:"wormholeEmitter",isMut:!1,isSigner:!1},{name:"wormholeSequence",isMut:!0,isSigner:!1},{name:"wormholeFeeCollector",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1}],args:[{name:"nonce",type:"u32"},{name:"amount",type:"u64"},{name:"fee",type:"u64"},{name:"targetAddress",type:{array:["u8",32]}},{name:"targetChain",type:"u16"}]},{name:"registerChain",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"config",isMut:!1,isSigner:!1},{name:"endpoint",isMut:!0,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1}],args:[]},{name:"createWrapped",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"config",isMut:!1,isSigner:!1},{name:"endpoint",isMut:!1,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"mint",isMut:!0,isSigner:!1},{name:"wrappedMeta",isMut:!0,isSigner:!1},{name:"splMetadata",isMut:!0,isSigner:!1},{name:"mintAuthority",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"splMetadataProgram",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1}],args:[]},{name:"upgradeContract",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"upgradeAuthority",isMut:!1,isSigner:!1},{name:"spill",isMut:!0,isSigner:!1},{name:"implementation",isMut:!0,isSigner:!1},{name:"programData",isMut:!0,isSigner:!1},{name:"tokenBridgeProgram",isMut:!0,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"bpfLoaderUpgradeable",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[]},{name:"transferWrappedWithPayload",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"config",isMut:!1,isSigner:!1},{name:"from",isMut:!0,isSigner:!1},{name:"fromOwner",isMut:!0,isSigner:!0},{name:"mint",isMut:!0,isSigner:!1},{name:"wrappedMeta",isMut:!1,isSigner:!1},{name:"authoritySigner",isMut:!1,isSigner:!1},{name:"wormholeBridge",isMut:!0,isSigner:!1},{name:"wormholeMessage",isMut:!0,isSigner:!0},{name:"wormholeEmitter",isMut:!1,isSigner:!1},{name:"wormholeSequence",isMut:!0,isSigner:!1},{name:"wormholeFeeCollector",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"sender",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1}],args:[{name:"nonce",type:"u32"},{name:"amount",type:"u64"},{name:"targetAddress",type:{array:["u8",32]}},{name:"targetChain",type:"u16"},{name:"payload",type:"bytes"},{name:"cpiProgramId",type:{option:"publicKey"}}]},{name:"transferNativeWithPayload",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"config",isMut:!1,isSigner:!1},{name:"from",isMut:!0,isSigner:!1},{name:"mint",isMut:!0,isSigner:!1},{name:"custody",isMut:!0,isSigner:!1},{name:"authoritySigner",isMut:!1,isSigner:!1},{name:"custodySigner",isMut:!1,isSigner:!1},{name:"wormholeBridge",isMut:!0,isSigner:!1},{name:"wormholeMessage",isMut:!0,isSigner:!0},{name:"wormholeEmitter",isMut:!1,isSigner:!1},{name:"wormholeSequence",isMut:!0,isSigner:!1},{name:"wormholeFeeCollector",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"sender",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1}],args:[{name:"nonce",type:"u32"},{name:"amount",type:"u64"},{name:"targetAddress",type:{array:["u8",32]}},{name:"targetChain",type:"u16"},{name:"payload",type:"bytes"},{name:"cpiProgramId",type:{option:"publicKey"}}]}],accounts:[]};function ar(e,t){return new lt(vt,new c(e),t===void 0?{connection:null}:t,sr())}function W(e,t){return ar(e,zt(t))}function sr(){return new ir(vt)}const ue=class ue{constructor(t,r,n){f(this,"address");f(this,"verified");f(this,"share");this.address=new c(t),this.verified=r,this.share=n}serialize(){const t=l.Buffer.alloc(ue.size);return t.write(this.address.toBuffer().toString("hex"),0,"hex"),this.verified&&t.writeUInt8(1,32),t.writeUInt8(this.share,33),t}static deserialize(t){const r=t.subarray(0,32),n=t.readUInt8(32)>0,i=t.readUInt8(33);return new ue(r,n,i)}};f(ue,"size",34);let K=ue;class be{constructor(t,r,n,i,a){f(this,"name");f(this,"symbol");f(this,"uri");f(this,"sellerFeeBasisPoints");f(this,"creators");this.name=t,this.symbol=r,this.uri=n,this.sellerFeeBasisPoints=i,this.creators=a}serialize(){const t=this.name.length,r=this.symbol.length,n=this.uri.length,i=this.creators,[a,o]=(()=>{if(i===null)return[0,0];const d=i.length;return[d,4+d*K.size]})(),s=l.Buffer.alloc(15+t+r+n+o);if(s.writeUInt32LE(t,0),s.write(this.name,4),s.writeUInt32LE(r,4+t),s.write(this.symbol,8+t),s.writeUInt32LE(n,8+t+r),s.write(this.uri,12+t+r),s.writeUInt16LE(this.sellerFeeBasisPoints,12+t+r+n),i===null)s.writeUInt8(0,14+t+r+n);else{s.writeUInt8(1,14+t+r+n),s.writeUInt32LE(a,15+t+r+n);for(let d=0;d<a;++d){const u=i.at(d),m=19+t+r+n+d*K.size;s.write(u.serialize().toString("hex"),m,"hex")}}return s}static deserialize(t){const r=t.readUInt32LE(0),n=t.subarray(4,4+r).toString(),i=t.readUInt32LE(4+r),a=t.subarray(8+r,8+r+i).toString(),o=t.readUInt32LE(8+r+i),s=t.subarray(12+r+i,12+r+i+o).toString(),d=t.readUInt16LE(12+r+i+o),u=t.readUInt8(14+r+i+o),m=(()=>{if(u==0)return null;const h=[],g=t.readUInt32LE(15+r+i+o);for(let w=0;w<g;++w){const p=19+r+i+o+w*K.size;h.push(K.deserialize(t.subarray(p,p+K.size)))}return h})();return new be(n,a,s,d,m)}}class pe extends be{constructor(r,n,i,a,o,s){super(r,n,i,a,o);f(this,"isMutable");this.isMutable=s}static serialize(r,n,i,a,o,s){return new pe(r,n,i,a,o,s).serialize()}static serializeInstructionData(r,n,i,a,o,s){return l.Buffer.concat([l.Buffer.alloc(1,0),pe.serialize(r,n,i,a,o,s)])}serialize(){return l.Buffer.concat([super.serialize(),l.Buffer.alloc(1,this.isMutable?1:0)])}}const we=class we{constructor(){}static createMetadataAccounts(t,r,n,i,a,o,s=!1,d,u,m,h=!1,g=Te(r)){const w=[Ot(g,!1),Q(r,!1),Q(n,!0),Q(t,!0),Q(o,s),Q(E.programId,!1),Q(O,!1)],p=pe.serializeInstructionData(i,a,d===void 0?"":d,m===void 0?0:m,u===void 0?null:u,h);return{programId:we.programId,keys:w,data:p}}};f(we,"programId",new c("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"));let de=we;function Te(e){return T([l.Buffer.from("metadata"),de.programId.toBuffer(),new c(e).toBuffer()],de.programId)}var at;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.EditionV1=1]="EditionV1",e[e.MasterEditionV1=2]="MasterEditionV1",e[e.ReservationListV1=3]="ReservationListV1",e[e.MetadataV1=4]="MetadataV1",e[e.ReservationListV2=5]="ReservationListV2",e[e.MasterEditionV2=6]="MasterEditionV2",e[e.EditionMarker=7]="EditionMarker"})(at||(at={}));class Le{constructor(t,r,n,i,a,o){f(this,"key");f(this,"updateAuthority");f(this,"mint");f(this,"data");f(this,"primarySaleHappened");f(this,"isMutable");this.key=t,this.updateAuthority=new c(r),this.mint=new c(n),this.data=i,this.primarySaleHappened=a,this.isMutable=o}static deserialize(t){const r=t.readUInt8(0),n=t.subarray(1,33),i=t.subarray(33,65),a=be.deserialize(t.subarray(65)),o=a.serialize().length,s=t.readUInt8(65+o)>0,d=t.readUInt8(66+o)>0;return new Le(r,n,i,a,s,d)}}async function Pr(e,t,r){return e.getAccountInfo(Te(t),r).then(n=>Le.deserialize(ye(n)))}function or(e,t,r,n,i,a,o){const s=W(t,e).methods.attestToken(o);return console.log(st(t,r,n,i,a)),s._ixFn(...s._args,{accounts:st(t,r,n,i,a),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function st(e,t,r,n,i){const{bridge:a,emitter:o,sequence:s,feeCollector:d,clock:u,rent:m,systemProgram:h}=Lt(t,r,i,e);return{payer:new c(r),config:B(e),mint:new c(n),wrappedMeta:Y(e,n),splMetadata:Te(n),wormholeBridge:a,wormholeMessage:new c(i),wormholeEmitter:o,wormholeSequence:s,wormholeFeeCollector:d,clock:u,rent:m,systemProgram:h,wormholeProgram:new c(t)}}function ot(e,t,r,n,i,a){const o=W(t,e).methods.completeNative();return o._ixFn(...o._args,{accounts:cr(t,r,n,i,a),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function cr(e,t,r,n,i){const a=new c(n.payload.token.address.toUint8Array());return{payer:new c(r),config:B(e),vaa:Z(t,l.Buffer.from(n.hash)),claim:H(e,n.emitterAddress.toUint8Array(),y(n.emitterChain),n.sequence),endpoint:te(e,y(n.emitterChain),n.emitterAddress.toUint8Array()),to:new c(n.payload.to.address.toUint8Array()),toFees:new c(i===void 0?n.payload.to.address.toUint8Array():i),custody:Me(e,a),mint:a,custodySigner:fe(e),rent:O,systemProgram:E.programId,tokenProgram:M,wormholeProgram:new c(t)}}function ur(e,t,r,n,i,a){const o=W(t,e).methods.completeWrapped();return o._ixFn(...o._args,{accounts:dr(t,r,n,i,a),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function dr(e,t,r,n,i){const a=re(e,y(n.payload.token.chain),n.payload.token.address.toUint8Array());return{payer:new c(r),config:B(e),vaa:Z(t,l.Buffer.from(n.hash)),claim:H(e,n.emitterAddress.toUint8Array(),y(n.emitterChain),n.sequence),endpoint:te(e,y(n.emitterChain),n.emitterAddress.toUint8Array()),to:new c(n.payload.to.address.toUint8Array()),toFees:new c(i===void 0?n.payload.to.address.toUint8Array():i),mint:a,wrappedMeta:Y(e,a),mintAuthority:ke(e),rent:O,systemProgram:E.programId,tokenProgram:M,wormholeProgram:new c(t)}}function lr(e,t,r,n,i){const a=W(t,e).methods.createWrapped();return a._ixFn(...a._args,{accounts:fr(t,r,n,i),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function fr(e,t,r,n){const i=re(e,y(n.payload.token.chain),n.payload.token.address.toUint8Array());return{payer:new c(r),config:B(e),endpoint:te(e,y(n.emitterChain),n.emitterAddress.toUint8Array()),vaa:Z(t,l.Buffer.from(n.hash)),claim:H(e,n.emitterAddress.toUint8Array(),y(n.emitterChain),n.sequence),mint:i,wrappedMeta:Y(e,i),splMetadata:Te(i),mintAuthority:ke(e),rent:O,systemProgram:E.programId,tokenProgram:M,splMetadataProgram:de.programId,wormholeProgram:new c(t)}}function _r(e,t,r){const n=W(e).methods.initialize(r);return n._ixFn(...n._args,{accounts:mr(e,t),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function mr(e,t){return{payer:new c(t),config:B(e),rent:O,systemProgram:E.programId}}function Wr(e,t,r,n){const i=W(e).methods.registerChain();return i._ixFn(...i._args,{accounts:gr(e,t,r,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function gr(e,t,r,n){return{payer:new c(r),config:B(e),endpoint:te(e,y(n.payload.actionArgs.foreignChain),n.payload.actionArgs.foreignAddress.toUint8Array()),vaa:Z(t,l.Buffer.from(n.hash)),claim:H(e,n.emitterAddress.toUint8Array(),y(n.emitterChain),n.sequence),rent:O,systemProgram:E.programId,wormholeProgram:new c(t)}}function Ir(e,t,r,n,i){const a=W(e).methods.upgradeContract();return a._ixFn(...a._args,{accounts:hr(e,t,r,n,i),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function hr(e,t,r,n,i){return{payer:new c(r),vaa:Z(t,l.Buffer.from(n.hash)),claim:H(e,n.emitterAddress.toUint8Array(),y(n.emitterChain),n.sequence),upgradeAuthority:Vt(e),spill:new c(i===void 0?r:i),implementation:new c(n.payload.actionArgs.newContract),programData:Kt(e),tokenBridgeProgram:new c(e),rent:O,clock:qt,bpfLoaderUpgradeable:Dt,systemProgram:E.programId}}function ct(e,t,r,n,i,a,o,s,d,u,m,h){const g=W(t,e).methods.transferNative(s,d,u,l.Buffer.from(m),h);return g._ixFn(...g._args,{accounts:pr(t,r,n,i,a,o),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function pr(e,t,r,n,i,a){const{wormholeBridge:o,wormholeMessage:s,wormholeEmitter:d,wormholeSequence:u,wormholeFeeCollector:m,clock:h,rent:g,systemProgram:w}=Se(e,t,r,n);return{payer:new c(r),config:B(e),from:new c(i),mint:new c(a),custody:Me(e,a),authoritySigner:ne(e),custodySigner:fe(e),wormholeBridge:o,wormholeMessage:s,wormholeEmitter:d,wormholeSequence:u,wormholeFeeCollector:m,clock:h,rent:g,systemProgram:w,tokenProgram:M,wormholeProgram:new c(t)}}function ut(e,t,r,n,i,a,o,s,d,u,m,h){const g=W(t,e).methods.transferNativeWithPayload(s,d,l.Buffer.from(u),m,l.Buffer.from(h),null);return g._ixFn(...g._args,{accounts:Bt(t,r,n,i,a,o),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function Bt(e,t,r,n,i,a,o){const{wormholeBridge:s,wormholeMessage:d,wormholeEmitter:u,wormholeSequence:m,wormholeFeeCollector:h,clock:g,rent:w,systemProgram:p}=Se(e,t,r,n);return{payer:new c(r),config:B(e),from:new c(i),mint:new c(a),custody:Me(e,a),authoritySigner:ne(e),custodySigner:fe(e),wormholeBridge:s,wormholeMessage:d,wormholeEmitter:u,wormholeSequence:m,wormholeFeeCollector:h,clock:g,sender:new c(o===void 0?r:xe(o)),rent:w,systemProgram:p,tokenProgram:M,wormholeProgram:new c(t)}}function wr(e,t,r,n,i,a,o,s,d,u,m,h,g,w){const p=W(t,e).methods.transferWrapped(u,m,h,l.Buffer.from(g),w);return p._ixFn(...p._args,{accounts:yr(t,r,n,i,a,o,s,d),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function yr(e,t,r,n,i,a,o,s){const d=re(e,o,s),{wormholeBridge:u,wormholeMessage:m,wormholeEmitter:h,wormholeSequence:g,wormholeFeeCollector:w,clock:p,rent:C,systemProgram:R}=Se(e,t,r,n);return{payer:new c(r),config:B(e),from:new c(i),fromOwner:new c(a),mint:d,wrappedMeta:Y(e,d),authoritySigner:ne(e),wormholeBridge:u,wormholeMessage:m,wormholeEmitter:h,wormholeSequence:g,wormholeFeeCollector:w,clock:p,rent:C,systemProgram:R,wormholeProgram:new c(t),tokenProgram:M}}function Sr(e,t,r,n,i,a,o,s,d,u,m,h,g,w){const p=W(t,e).methods.transferWrappedWithPayload(u,m,l.Buffer.from(h),g,l.Buffer.from(w),null);return p._ixFn(...p._args,{accounts:Rt(t,r,n,i,a,o,s,d),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function Rt(e,t,r,n,i,a,o,s,d){const u=re(e,o,s),{wormholeBridge:m,wormholeMessage:h,wormholeEmitter:g,wormholeSequence:w,wormholeFeeCollector:p,clock:C,rent:R,systemProgram:F}=Se(e,t,r,n);return{payer:new c(r),config:B(e),from:new c(i),fromOwner:new c(a),mint:u,wrappedMeta:Y(e,u),authoritySigner:ne(e),wormholeBridge:m,wormholeMessage:h,wormholeEmitter:g,wormholeSequence:w,wormholeFeeCollector:p,clock:C,sender:new c(d===void 0?r:xe(d)),rent:R,systemProgram:F,wormholeProgram:new c(t),tokenProgram:M}}function Ur(e,t,r){const{wormholeEmitter:n,wormholeBridge:i,wormholeFeeCollector:a,wormholeSequence:o}=Gt(t,r);return{tokenBridgeConfig:B(t),tokenBridgeAuthoritySigner:ne(t),tokenBridgeCustodySigner:fe(t),tokenBridgeMintAuthority:ke(t),tokenBridgeSender:xe(e),tokenBridgeRedeemer:ze(e),wormholeBridge:i,tokenBridgeEmitter:n,wormholeFeeCollector:a,tokenBridgeSequence:o}}function Ar(e,t,r,n,i,a,o){const s=Bt(t,r,n,i,a,o,e);return{payer:s.payer,tokenBridgeConfig:s.config,fromTokenAccount:s.from,mint:s.mint,tokenBridgeCustody:s.custody,tokenBridgeAuthoritySigner:s.authoritySigner,tokenBridgeCustodySigner:s.custodySigner,wormholeBridge:s.wormholeBridge,wormholeMessage:s.wormholeMessage,tokenBridgeEmitter:s.wormholeEmitter,tokenBridgeSequence:s.wormholeSequence,wormholeFeeCollector:s.wormholeFeeCollector,clock:s.clock,tokenBridgeSender:s.sender,rent:s.rent,systemProgram:s.systemProgram,tokenProgram:s.tokenProgram,wormholeProgram:s.wormholeProgram}}function Mr(e,t,r,n,i,a,o,s,d){const u=Rt(t,r,n,i,a,d===void 0?e:d,o,s,e);return{payer:u.payer,tokenBridgeConfig:u.config,fromTokenAccount:u.from,fromTokenAccountOwner:u.fromOwner,tokenBridgeWrappedMint:u.mint,tokenBridgeWrappedMeta:u.wrappedMeta,tokenBridgeAuthoritySigner:u.authoritySigner,wormholeBridge:u.wormholeBridge,wormholeMessage:u.wormholeMessage,tokenBridgeEmitter:u.wormholeEmitter,tokenBridgeSequence:u.wormholeSequence,wormholeFeeCollector:u.wormholeFeeCollector,clock:u.clock,tokenBridgeSender:u.sender,rent:u.rent,systemProgram:u.systemProgram,tokenProgram:u.tokenProgram,wormholeProgram:u.wormholeProgram}}function Nr(e,t,r,n,i){const a=new c(n.payload.token.address.toUint8Array()),o=new c(n.payload.to.address.toUint8Array());return{payer:new c(r),tokenBridgeConfig:B(e),vaa:Z(t,l.Buffer.from(n.hash)),tokenBridgeClaim:H(e,n.emitterAddress.toUint8Array(),y(n.emitterChain),n.sequence),tokenBridgeForeignEndpoint:te(e,y(n.emitterChain),n.emitterAddress.toUint8Array()),toTokenAccount:new c(i),tokenBridgeRedeemer:ze(o),toFeesTokenAccount:new c(i),tokenBridgeCustody:Me(e,a),mint:a,tokenBridgeCustodySigner:fe(e),rent:O,systemProgram:E.programId,tokenProgram:M,wormholeProgram:new c(t)}}function Fr(e,t,r,n,i){const a=re(e,y(n.payload.token.chain),n.payload.token.address.toUint8Array()),o=new c(n.payload.to.address.toUint8Array());return{payer:new c(r),tokenBridgeConfig:B(e),vaa:Z(t,l.Buffer.from(n.hash)),tokenBridgeClaim:H(e,n.emitterAddress.toUint8Array(),y(n.emitterChain),n.sequence),tokenBridgeForeignEndpoint:te(e,y(n.emitterChain),n.emitterAddress.toUint8Array()),toTokenAccount:new c(i),tokenBridgeRedeemer:ze(o),toFeesTokenAccount:new c(i),tokenBridgeWrappedMint:a,tokenBridgeWrappedMeta:Y(e,a),tokenBridgeMintAuthority:ke(e),rent:O,systemProgram:E.programId,tokenProgram:M,wormholeProgram:new c(t)}}const kr={version:"0.1.0",name:"token_bridge_relayer",constants:[{name:"SEED_PREFIX_BRIDGED",type:"bytes",value:"[98, 114, 105, 100, 103, 101, 100]"},{name:"SEED_PREFIX_TMP",type:"bytes",value:"[116, 109, 112]"},{name:"SWAP_RATE_PRECISION",type:"u32",value:"100_000_000"}],instructions:[{name:"initialize",docs:["This instruction is be used to generate your program's config.","And for convenience, we will store Wormhole-related PDAs in the","config so we can verify these accounts with a simple == constraint.","# Arguments","","* `ctx` - `Initialize` context","* `fee_recipient` - Recipient of all relayer fees and swap proceeds","* `assistant` - Privileged key to manage certain accounts"],accounts:[{name:"owner",isMut:!0,isSigner:!0,docs:["Deployer of the program."]},{name:"senderConfig",isMut:!0,isSigner:!1,docs:["Sender Config account, which saves program data useful for other","instructions, specifically for outbound transfers. Also saves the payer","of the [`initialize`](crate::initialize) instruction as the program's","owner."]},{name:"redeemerConfig",isMut:!0,isSigner:!1,docs:["Redeemer Config account, which saves program data useful for other","instructions, specifically for inbound transfers. Also saves the payer","of the [`initialize`](crate::initialize) instruction as the program's","owner."]},{name:"ownerConfig",isMut:!0,isSigner:!1,docs:["Owner config account, which saves the owner, assistant and","pending owner keys. This account is used to manage the ownership of the","program."]},{name:"tokenBridgeEmitter",isMut:!1,isSigner:!1,docs:["that holds data; it is purely just a signer for posting Wormhole","messages on behalf of the Token Bridge program."]},{name:"tokenBridgeSequence",isMut:!1,isSigner:!1,docs:["Token Bridge emitter's sequence account. Like with all Wormhole","emitters, this account keeps track of the sequence number of the last","posted message."]},{name:"systemProgram",isMut:!1,isSigner:!1,docs:["System program."]},{name:"programData",isMut:!0,isSigner:!1,docs:["upgrade authority. We check this PDA address just in case there is another program that this","deployer has deployed.","","NOTE: Set upgrade authority is scary because any public key can be used to set as the","authority."]},{name:"bpfLoaderUpgradeableProgram",isMut:!1,isSigner:!1}],args:[{name:"feeRecipient",type:"publicKey"},{name:"assistant",type:"publicKey"}]},{name:"registerForeignContract",docs:["This instruction registers a new foreign contract (from another","network) and saves the emitter information in a ForeignEmitter account.","This instruction is owner-only, meaning that only the owner of the","program (defined in the [Config] account) can add and update foreign","contracts.","","# Arguments","","* `ctx` - `RegisterForeignContract` context","* `chain` - Wormhole Chain ID","* `address` - Wormhole Emitter Address","* `relayer_fee` - Relayer fee scaled by the `relayer_fee_precision`"],accounts:[{name:"owner",isMut:!0,isSigner:!0,docs:["Owner of the program set in the [`SenderConfig`] account. Signer for","creating [`ForeignContract`] account."]},{name:"config",isMut:!1,isSigner:!1,docs:["Sender Config account. This program requires that the `owner` specified","in the context equals the pubkey specified in this account. Read-only."]},{name:"foreignContract",isMut:!0,isSigner:!1,docs:["Foreign Contract account. Create this account if an emitter has not been","registered yet for this Wormhole chain ID. If there already is a","contract address saved in this account, overwrite it."]},{name:"tokenBridgeForeignEndpoint",isMut:!1,isSigner:!1,docs:["Token Bridge foreign endpoint. This account should really be one","endpoint per chain, but Token Bridge's PDA allows for multiple","endpoints for each chain. We store the proper endpoint for the","emitter chain."]},{name:"tokenBridgeProgram",isMut:!1,isSigner:!1,docs:["Token Bridge program."]},{name:"systemProgram",isMut:!1,isSigner:!1,docs:["System program."]}],args:[{name:"chain",type:"u16"},{name:"address",type:{array:["u8",32]}},{name:"relayerFee",type:"u64"}]},{name:"registerToken",docs:["This instruction registers a new token and saves the initial `swap_rate`","and `max_native_token_amount` in a RegisteredToken account.","This instruction is owner-only, meaning that only the owner of the","program (defined in the [Config] account) can register a token.","","# Arguments","","* `ctx` - `RegisterToken` context","* `swap_rate`:","- USD conversion rate scaled by the `swap_rate_precision`. For example,","- if the conversion rate is $15 and the `swap_rate_precision` is","- 1000000, the `swap_rate` should be set to 15000000.","* `max_native_swap_amount`:","- Maximum amount of native tokens that can be swapped for this token","- on this chain."],accounts:[{name:"owner",isMut:!0,isSigner:!0,docs:["Owner of the program set in the [`SenderConfig`] account. Signer for","creating [`ForeignContract`] account."]},{name:"config",isMut:!1,isSigner:!1,docs:["Sender Config account. This program requires that the `owner` specified","in the context equals the pubkey specified in this account. Read-only."]},{name:"registeredToken",isMut:!0,isSigner:!1,docs:["Registered Token account. This account stores information about the","token, including the swap rate and max native swap amount. Create this","account if the mint has not been registered yet. Mutable."]},{name:"mint",isMut:!1,isSigner:!1,docs:["Mint info. This is the SPL token that will be bridged over to the","foreign contract."]},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1,docs:["System program."]}],args:[{name:"swapRate",type:"u64"},{name:"maxNativeSwapAmount",type:"u64"}]},{name:"deregisterToken",docs:["This instruction deregisters a token by closing the existing","`RegisteredToken` account for a particular mint. This instruction is","owner-only, meaning that only the owner of the program (defined in the","[Config] account) can deregister a token."],accounts:[{name:"owner",isMut:!1,isSigner:!0,docs:["Owner of the program set in the [`SenderConfig`] account. Signer for","closing [`RegisteredToken`] account."]},{name:"config",isMut:!1,isSigner:!1,docs:["Sender Config account. This program requires that the `owner` specified","in the context equals the pubkey specified in this account. Read-only."]},{name:"mint",isMut:!1,isSigner:!1,docs:["Mint info. This is the SPL token that will be bridged over to the","foreign contract."]},{name:"registeredToken",isMut:!0,isSigner:!1,docs:["Registered Token account. This account stores information about the","token, including the swap rate and max native swap amount. This account","also determines if a mint is registered or not."]}],args:[]},{name:"updateRelayerFee",docs:["This instruction updates the `relayer_fee` in the `ForeignContract` account.","The `relayer_fee` is scaled by the `relayer_fee_precision`. For example,","if the `relayer_fee` is $15 and the `relayer_fee_precision` is 1000000,","the `relayer_fee` should be set to 15000000. This instruction can","only be called by the owner or assistant, which are defined in the","[OwnerConfig] account.","","# Arguments","","* `ctx` - `UpdateRelayerFee` context","* `chain` - Wormhole Chain ID","* `fee` - Relayer fee scaled by the `relayer_fee_precision`"],accounts:[{name:"payer",isMut:!0,isSigner:!0,docs:["Signer of the transaction. Must be the owner or assistant."]},{name:"ownerConfig",isMut:!1,isSigner:!1,docs:["The owner_config is used when updating the swap rate","so that the assistant key can be used in addition to the","owner key."]},{name:"foreignContract",isMut:!0,isSigner:!1,docs:["This account holds the USD denominated relayer fee for the specified","`chain`. This account is used to determine the cost of relaying","a transfer to a target chain. If there already is a relayer fee","saved in this account, overwrite it."]},{name:"systemProgram",isMut:!1,isSigner:!1,docs:["System program."]}],args:[{name:"chain",type:"u16"},{name:"fee",type:"u64"}]},{name:"updateRelayerFeePrecision",docs:["This instruction updates the `relayer_fee_precision` in the","`SenderConfig` and `RedeemerConfig` accounts. The `relayer_fee_precision`","is used to scale the `relayer_fee`. This instruction is owner-only,","meaning that only the owner of the program (defined in the [Config]","account) can register a token.","","# Arguments","","* `ctx` - `UpdatePrecision` context","* `relayer_fee_precision` - Precision used to scale the relayer fee."],accounts:[{name:"owner",isMut:!1,isSigner:!0,docs:["Owner of the program set in the [`RedeemerConfig`] and [`SenderConfig`] account."]},{name:"redeemerConfig",isMut:!0,isSigner:!1,docs:["Redeemer Config account. This program requires that the `owner`","specified in the context equals the pubkey specified in this account.","Mutable."]},{name:"senderConfig",isMut:!0,isSigner:!1,docs:["Sender Config account. This program requires that the `owner`","specified in the context equals the pubkey specified in this account.","Mutable. The `owner` check is redundant here, but we keep it as an","extra protection for future changes to the context. Mutable."]}],args:[{name:"relayerFeePrecision",type:"u32"}]},{name:"updateSwapRate",docs:["This instruction updates the `swap_rate` in the `RegisteredToken`","account. This instruction can only be called by the owner or","assistant, which are defined in the [OwnerConfig] account.","","# Arguments","","* `ctx` - `UpdateSwapRate` context","* `swap_rate` - USD conversion rate for the specified token."],accounts:[{name:"owner",isMut:!1,isSigner:!0,docs:["The signer of the transaction. Must be the owner or assistant."]},{name:"ownerConfig",isMut:!1,isSigner:!1,docs:["The owner_config is used when updating the swap rate so that the","assistant key can be used in additional to the owner key."]},{name:"registeredToken",isMut:!0,isSigner:!1,docs:["Registered Token account. This account stores information about the","token, including the swap rate and max native swap amount. The program","will modify this account to update the swap rate. Mutable."]},{name:"mint",isMut:!1,isSigner:!1,docs:["Mint info. This is the SPL token that will be bridged over to the","foreign contract."]}],args:[{name:"swapRate",type:"u64"}]},{name:"updateMaxNativeSwapAmount",docs:["This instruction updates the `max_native_swap_amount` in the","`RegisteredToken` account. This instruction is owner-only,","meaning that only the owner of the program (defined in the [Config]","account) can register a token.","","# Arguments","","* `ctx` - `UpdateMaxNativeSwapAmount` context","* `max_native_swap_amount`:","- Maximum amount of native tokens that can be swapped for this token","- on this chain."],accounts:[{name:"owner",isMut:!1,isSigner:!0,docs:["Owner of the program set in the [`SenderConfig`] account. Signer for","creating [`ForeignContract`] account."]},{name:"config",isMut:!1,isSigner:!1,docs:["Sender Config account. This program requires that the `owner` specified","in the context equals the pubkey specified in this account. Read-only."]},{name:"registeredToken",isMut:!0,isSigner:!1,docs:["Registered Token account. This account stores information about the","token, including the swap rate and max native swap amount. The program","will modify this account when the swap rate or max native swap amount","changes. Mutable."]},{name:"mint",isMut:!1,isSigner:!1,docs:["Mint info. This is the SPL token that will be bridged over to the","foreign contract."]}],args:[{name:"maxNativeSwapAmount",type:"u64"}]},{name:"setPauseForTransfers",docs:["This instruction updates the `paused` boolean in the `SenderConfig`","account. This instruction is owner-only, meaning that only the owner","of the program (defined in the [Config] account) can pause outbound","transfers.","","# Arguments","","* `ctx` - `PauseOutboundTransfers` context","* `paused` - Boolean indicating whether outbound transfers are paused."],accounts:[{name:"owner",isMut:!1,isSigner:!0,docs:["Owner of the program set in the [`SenderConfig`] account."]},{name:"config",isMut:!0,isSigner:!1,docs:["Sender Config account. This program requires that the `owner` specified","in the context equals the pubkey specified in this account. Mutable."]}],args:[{name:"paused",type:"bool"}]},{name:"submitOwnershipTransferRequest",docs:["This instruction sets the `pending_owner` field in the `OwnerConfig`","account. This instruction is owner-only, meaning that only the owner","of the program (defined in the [Config] account) can submit an","ownership transfer request.","","# Arguments","","* `ctx` - `ManageOwnership` context","* `new_owner` - Pubkey of the pending owner."],accounts:[{name:"owner",isMut:!1,isSigner:!0,docs:["Owner of the program set in the [`OwnerConfig`] account."]},{name:"ownerConfig",isMut:!0,isSigner:!1,docs:["Owner Config account. This program requires that the `owner` specified","in the context equals the pubkey specified in this account. Mutable."]}],args:[{name:"newOwner",type:"publicKey"}]},{name:"confirmOwnershipTransferRequest",docs:["This instruction confirms that the `pending_owner` is the signer of","the transaction and updates the `owner` field in the `SenderConfig`,","`RedeemerConfig`, and `OwnerConfig` accounts."],accounts:[{name:"pendingOwner",isMut:!1,isSigner:!0,docs:["Must be the pending owner of the program set in the [`OwnerConfig`]","account."]},{name:"ownerConfig",isMut:!0,isSigner:!1,docs:["Owner Config account. This program requires that the `pending_owner`","specified in the context equals the pubkey specified in this account."]},{name:"senderConfig",isMut:!0,isSigner:!1,docs:["Sender Config account. This instruction will update the `owner`","specified in this account to the `pending_owner` specified in the","[`OwnerConfig`] account. Mutable."]},{name:"redeemerConfig",isMut:!0,isSigner:!1,docs:["Redeemer Config account. This instruction will update the `owner`","specified in this account to the `pending_owner` specified in the","[`OwnerConfig`] account. Mutable."]}],args:[]},{name:"cancelOwnershipTransferRequest",docs:["This instruction cancels the ownership transfer request by setting","the `pending_owner` field in the `OwnerConfig` account to `None`.","This instruction is owner-only, meaning that only the owner of the","program (defined in the [Config] account) can cancel an ownership","transfer request."],accounts:[{name:"owner",isMut:!1,isSigner:!0,docs:["Owner of the program set in the [`OwnerConfig`] account."]},{name:"ownerConfig",isMut:!0,isSigner:!1,docs:["Owner Config account. This program requires that the `owner` specified","in the context equals the pubkey specified in this account. Mutable."]}],args:[]},{name:"updateAssistant",docs:["This instruction updates the `assistant` field in the `OwnerConfig`","account. This instruction is owner-only, meaning that only the owner","of the program (defined in the [Config] account) can update the","assistant.","","# Arguments","","* `ctx` - `ManageOwnership` context","* `new_assistant` - Pubkey of the new assistant."],accounts:[{name:"owner",isMut:!1,isSigner:!0,docs:["Owner of the program set in the [`OwnerConfig`] account."]},{name:"ownerConfig",isMut:!0,isSigner:!1,docs:["Owner Config account. This program requires that the `owner` specified","in the context equals the pubkey specified in this account. Mutable."]}],args:[{name:"newAssistant",type:"publicKey"}]},{name:"updateFeeRecipient",docs:["This instruction updates the `fee_recipient` field in the `RedeemerConfig`","account. This instruction is owner-only, meaning that only the owner","of the program (defined in the [Config] account) can update the","fee recipient.","","# Arguments","","* `ctx` - `UpdateFeeRecipient` context","* `new_fee_recipient` - Pubkey of the new fee recipient."],accounts:[{name:"owner",isMut:!1,isSigner:!0,docs:["Owner of the program set in the [`RedeemerConfig`] account."]},{name:"redeemerConfig",isMut:!0,isSigner:!1,docs:["Redeemer Config account, which saves program data useful for other","instructions, specifically for inbound transfers. Also saves the payer","of the [`initialize`](crate::initialize) instruction as the program's","owner."]}],args:[{name:"newFeeRecipient",type:"publicKey"}]},{name:"transferNativeTokensWithRelay",docs:["This instruction is used to transfer native tokens from Solana to a","foreign blockchain. The user can optionally specify a","`to_native_token_amount` to swap some of the tokens for the native","asset on the target chain. For a fee, an off-chain relayer will redeem","the transfer on the target chain. If the user is transferring native","SOL, the contract will automatically wrap the lamports into a WSOL.","","# Arguments","","* `ctx` - `TransferNativeWithRelay` context","* `amount` - Amount of tokens to send","* `to_native_token_amount`:","- Amount of tokens to swap for native assets on the target chain","* `recipient_chain` - Chain ID of the target chain","* `recipient_address` - Address of the target wallet on the target chain","* `batch_id` - Nonce of Wormhole message","* `wrap_native` - Whether to wrap native SOL"],accounts:[{name:"payer",isMut:!0,isSigner:!0,docs:["Payer will pay Wormhole fee to transfer tokens and create temporary","token account."]},{name:"payerSequence",isMut:!0,isSigner:!1,docs:["Used to keep track of payer's Wormhole sequence number."]},{name:"config",isMut:!1,isSigner:!1,docs:["Sender Config account. Acts as the signer for the Token Bridge token","transfer. Read-only."]},{name:"foreignContract",isMut:!1,isSigner:!1,docs:["Foreign Contract account. Send tokens to the contract specified in this","account. Funnily enough, the Token Bridge program does not have any","requirements for outbound transfers for the recipient chain to be","registered. This account provides extra protection against sending","tokens to an unregistered Wormhole chain ID. Read-only."]},{name:"mint",isMut:!0,isSigner:!1,docs:["Mint info. This is the SPL token that will be bridged over to the","foreign contract. Mutable."]},{name:"fromTokenAccount",isMut:!0,isSigner:!1,docs:["Payer's associated token account. We may want to make this a generic","token account in the future."]},{name:"registeredToken",isMut:!1,isSigner:!1},{name:"tmpTokenAccount",isMut:!0,isSigner:!1,docs:["Program's temporary token account. This account is created before the","instruction is invoked to temporarily take custody of the payer's","tokens. When the tokens are finally bridged out, the token account","will have zero balance and can be closed."]},{name:"tokenBridgeConfig",isMut:!1,isSigner:!1},{name:"tokenBridgeCustody",isMut:!0,isSigner:!1,docs:["account that holds this mint's balance. This account needs to be","unchecked because a token account may not have been created for this","mint yet. Mutable."]},{name:"tokenBridgeAuthoritySigner",isMut:!1,isSigner:!1},{name:"tokenBridgeCustodySigner",isMut:!1,isSigner:!1},{name:"wormholeBridge",isMut:!0,isSigner:!1},{name:"wormholeMessage",isMut:!0,isSigner:!1,docs:["tokens transferred in this account for our program. Mutable."]},{name:"tokenBridgeEmitter",isMut:!1,isSigner:!1},{name:"tokenBridgeSequence",isMut:!0,isSigner:!1},{name:"wormholeFeeCollector",isMut:!0,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1},{name:"tokenBridgeProgram",isMut:!1,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1}],args:[{name:"amount",type:"u64"},{name:"toNativeTokenAmount",type:"u64"},{name:"recipientChain",type:"u16"},{name:"recipientAddress",type:{array:["u8",32]}},{name:"batchId",type:"u32"},{name:"wrapNative",type:"bool"}]},{name:"transferWrappedTokensWithRelay",docs:["This instruction is used to transfer wrapped tokens from Solana to a","foreign blockchain. The user can optionally specify a","`to_native_token_amount` to swap some of the tokens for the native","assets on the target chain. For a fee, an off-chain relayer will redeem","the transfer on the target chain. This instruction should only be called","when the user is transferring a wrapped token.","","# Arguments","","* `ctx` - `TransferWrappedWithRelay` context","* `amount` - Amount of tokens to send","* `to_native_token_amount`:","- Amount of tokens to swap for native assets on the target chain","* `recipient_chain` - Chain ID of the target chain","* `recipient_address` - Address of the target wallet on the target chain","* `batch_id` - Nonce of Wormhole message"],accounts:[{name:"payer",isMut:!0,isSigner:!0,docs:["Payer will pay Wormhole fee to transfer tokens."]},{name:"payerSequence",isMut:!0,isSigner:!1,docs:["Used to keep track of payer's Wormhole sequence number."]},{name:"config",isMut:!1,isSigner:!1,docs:["Sender Config account. Acts as the Token Bridge sender PDA. Mutable."]},{name:"foreignContract",isMut:!1,isSigner:!1,docs:["Foreign Contract account. Send tokens to the contract specified in this","account. Funnily enough, the Token Bridge program does not have any","requirements for outbound transfers for the recipient chain to be","registered. This account provides extra protection against sending","tokens to an unregistered Wormhole chain ID. Read-only."]},{name:"tokenBridgeWrappedMint",isMut:!0,isSigner:!1,docs:["Token Bridge wrapped mint info. This is the SPL token that will be","bridged to the foreign contract. The wrapped mint PDA must agree","with the native token's metadata. Mutable."]},{name:"fromTokenAccount",isMut:!0,isSigner:!1,docs:["Payer's associated token account. We may want to make this a generic","token account in the future."]},{name:"registeredToken",isMut:!1,isSigner:!1},{name:"tmpTokenAccount",isMut:!0,isSigner:!1,docs:["Program's temporary token account. This account is created before the","instruction is invoked to temporarily take custody of the payer's","tokens. When the tokens are finally bridged out, the token account","will have zero balance and can be closed."]},{name:"tokenBridgeWrappedMeta",isMut:!1,isSigner:!1,docs:["about the token from its native chain:","* Wormhole Chain ID","* Token's native contract address","* Token's native decimals"]},{name:"tokenBridgeConfig",isMut:!1,isSigner:!1},{name:"tokenBridgeAuthoritySigner",isMut:!1,isSigner:!1},{name:"wormholeBridge",isMut:!0,isSigner:!1},{name:"wormholeMessage",isMut:!0,isSigner:!1,docs:["tokens transferred in this account."]},{name:"tokenBridgeEmitter",isMut:!1,isSigner:!1},{name:"tokenBridgeSequence",isMut:!0,isSigner:!1},{name:"wormholeFeeCollector",isMut:!0,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1},{name:"tokenBridgeProgram",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1}],args:[{name:"amount",type:"u64"},{name:"toNativeTokenAmount",type:"u64"},{name:"recipientChain",type:"u16"},{name:"recipientAddress",type:{array:["u8",32]}},{name:"batchId",type:"u32"}]},{name:"completeNativeTransferWithRelay",docs:["This instruction is used to redeem token transfers from foreign emitters.","It takes custody of the released native tokens and sends the tokens to the","encoded `recipient`. It pays the `fee_recipient` in the token","denomination. If requested by the user, it will perform a swap with the","off-chain relayer to provide the user with lamports. If the token","being transferred is WSOL, the contract will unwrap the WSOL and send","the lamports to the recipient and pay the relayer in lamports.","","# Arguments","","* `ctx` - `CompleteNativeWithRelay` context","* `vaa_hash` - Hash of the VAA that triggered the transfer"],accounts:[{name:"payer",isMut:!0,isSigner:!0,docs:["Payer will pay Wormhole fee to transfer tokens and create temporary","token account."]},{name:"config",isMut:!1,isSigner:!1,docs:["Redeemer Config account. Acts as the Token Bridge redeemer, which signs","for the complete transfer instruction. Read-only."]},{name:"feeRecipientTokenAccount",isMut:!0,isSigner:!1,docs:["Fee recipient's token account. Must be an associated token account. Mutable."]},{name:"foreignContract",isMut:!1,isSigner:!1,docs:["Foreign Contract account. The registered contract specified in this","account must agree with the target address for the Token Bridge's token","transfer. Read-only."]},{name:"mint",isMut:!1,isSigner:!1,docs:["Mint info. This is the SPL token that will be bridged over from the","foreign contract. This must match the token address specified in the","signed Wormhole message. Read-only."]},{name:"recipientTokenAccount",isMut:!0,isSigner:!1,docs:["Recipient associated token account. The recipient authority check","is necessary to ensure that the recipient is the intended recipient","of the bridged tokens. Mutable."]},{name:"recipient",isMut:!0,isSigner:!1,docs:["transaction. This instruction verifies that the recipient key","passed in this context matches the intended recipient in the vaa."]},{name:"registeredToken",isMut:!1,isSigner:!1},{name:"nativeRegisteredToken",isMut:!1,isSigner:!1},{name:"tmpTokenAccount",isMut:!0,isSigner:!1,docs:["Program's temporary token account. This account is created before the","instruction is invoked to temporarily take custody of the payer's","tokens. When the tokens are finally bridged in, the tokens will be","transferred to the destination token accounts. This account will have","zero balance and can be closed."]},{name:"tokenBridgeConfig",isMut:!1,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1,docs:["Verified Wormhole message account. The Wormhole program verified","signatures and posted the account data here. Read-only."]},{name:"tokenBridgeClaim",isMut:!0,isSigner:!1,docs:["is true if the bridged assets have been claimed. If the transfer has","not been redeemed, this account will not exist yet.","","NOTE: The Token Bridge program's claim account is only initialized when","a transfer is redeemed (and the boolean value `true` is written as","its data).","","The Token Bridge program will automatically fail if this transfer","is redeemed again. But we choose to short-circuit the failure as the","first evaluation of this instruction."]},{name:"tokenBridgeForeignEndpoint",isMut:!1,isSigner:!1,docs:["endpoint per chain, but the PDA allows for multiple endpoints for each","chain! We store the proper endpoint for the emitter chain."]},{name:"tokenBridgeCustody",isMut:!0,isSigner:!1,docs:["account that holds this mint's balance."]},{name:"tokenBridgeCustodySigner",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1},{name:"tokenBridgeProgram",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1}],args:[{name:"vaaHash",type:{array:["u8",32]}}]},{name:"completeWrappedTransferWithRelay",docs:["This instruction is used to redeem token transfers from foreign emitters.","It takes custody of the minted wrapped tokens and sends the tokens to the","encoded `recipient`. It pays the `fee_recipient` in the wrapped-token","denomination. If requested by the user, it will perform a swap with the","off-chain relayer to provide the user with lamports.","","# Arguments","","* `ctx` - `CompleteWrappedWithRelay` context","* `vaa_hash` - Hash of the VAA that triggered the transfer"],accounts:[{name:"payer",isMut:!0,isSigner:!0,docs:["Payer will pay Wormhole fee to transfer tokens and create temporary","token account."]},{name:"config",isMut:!1,isSigner:!1,docs:["Redeemer Config account. Acts as the Token Bridge redeemer, which signs","for the complete transfer instruction. Read-only."]},{name:"feeRecipientTokenAccount",isMut:!0,isSigner:!1,docs:["Fee recipient's token account. Must be an associated token account. Mutable."]},{name:"foreignContract",isMut:!1,isSigner:!1,docs:["Foreign Contract account. The registered contract specified in this","account must agree with the target address for the Token Bridge's token","transfer. Read-only."]},{name:"tokenBridgeWrappedMint",isMut:!0,isSigner:!1,docs:["Token Bridge wrapped mint info. This is the SPL token that will be","bridged from the foreign contract. The wrapped mint PDA must agree","with the native token's metadata in the wormhole message. Mutable."]},{name:"recipientTokenAccount",isMut:!0,isSigner:!1,docs:["Recipient associated token account. The recipient authority check","is necessary to ensure that the recipient is the intended recipient","of the bridged tokens. Mutable."]},{name:"recipient",isMut:!0,isSigner:!1,docs:["transaction. This instruction verifies that the recipient key","passed in this context matches the intended recipient in the vaa."]},{name:"registeredToken",isMut:!1,isSigner:!1},{name:"nativeRegisteredToken",isMut:!1,isSigner:!1},{name:"tmpTokenAccount",isMut:!0,isSigner:!1,docs:["Program's temporary token account. This account is created before the","instruction is invoked to temporarily take custody of the payer's","tokens. When the tokens are finally bridged in, the tokens will be","transferred to the destination token accounts. This account will have","zero balance and can be closed."]},{name:"tokenBridgeWrappedMeta",isMut:!1,isSigner:!1,docs:["about the token from its native chain:","* Wormhole Chain ID","* Token's native contract address","* Token's native decimals"]},{name:"tokenBridgeConfig",isMut:!1,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1,docs:["Verified Wormhole message account. The Wormhole program verified","signatures and posted the account data here. Read-only."]},{name:"tokenBridgeClaim",isMut:!0,isSigner:!1,docs:["is true if the bridged assets have been claimed. If the transfer has","not been redeemed, this account will not exist yet.","","NOTE: The Token Bridge program's claim account is only initialized when","a transfer is redeemed (and the boolean value `true` is written as","its data).","","The Token Bridge program will automatically fail if this transfer","is redeemed again. But we choose to short-circuit the failure as the","first evaluation of this instruction."]},{name:"tokenBridgeForeignEndpoint",isMut:!1,isSigner:!1,docs:["endpoint per chain, but the PDA allows for multiple endpoints for each","chain! We store the proper endpoint for the emitter chain."]},{name:"tokenBridgeMintAuthority",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1},{name:"tokenBridgeProgram",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1}],args:[{name:"vaaHash",type:{array:["u8",32]}}]}],accounts:[{name:"foreignContract",docs:["Foreign emitter account data."],type:{kind:"struct",fields:[{name:"chain",docs:["Emitter chain. Cannot equal `1` (Solana's Chain ID)."],type:"u16"},{name:"address",docs:["Emitter address. Cannot be zero address."],type:{array:["u8",32]}},{name:"tokenBridgeForeignEndpoint",docs:["Token Bridge program's foreign endpoint account key."],type:"publicKey"},{name:"fee",docs:["The fee that is paid to the `fee_recipient` upon redeeming a transfer.","This value is set in terms of USD and scaled by the `relayer_fee_precision`.","For example, if the `relayer_fee_precision` is `100000000` and the intended","fee is $5, then the `fee` value should be `500000000`."],type:"u64"}]}},{name:"ownerConfig",docs:["Owner account data."],type:{kind:"struct",fields:[{name:"owner",docs:["Program's owner."],type:"publicKey"},{name:"assistant",docs:["Program's assistant. Can be used to update the relayer fee and swap rate."],type:"publicKey"},{name:"pendingOwner",docs:["Intermediate storage for the pending owner. Is used to transfer ownership."],type:{option:"publicKey"}}]}},{name:"redeemerConfig",type:{kind:"struct",fields:[{name:"owner",docs:["Program's owner."],type:"publicKey"},{name:"bump",docs:["PDA bump."],type:"u8"},{name:"relayerFeePrecision",docs:["Relayer fee and swap rate precision."],type:"u32"},{name:"feeRecipient",docs:["Recipient of all relayer fees and swap proceeds."],type:"publicKey"}]}},{name:"registeredToken",docs:["Registered token account data."],type:{kind:"struct",fields:[{name:"swapRate",docs:["Token swap rate. The swap rate is the USD conversion rate of the token."],type:"u64"},{name:"maxNativeSwapAmount",docs:["Maximum amount of native SOL the contract will swap for each transfer."],type:"u64"}]}},{name:"senderConfig",type:{kind:"struct",fields:[{name:"owner",docs:["Program's owner."],type:"publicKey"},{name:"bump",docs:["PDA bump."],type:"u8"},{name:"tokenBridge",docs:["Token Bridge program's relevant addresses."],type:{defined:"OutboundTokenBridgeAddresses"}},{name:"relayerFeePrecision",docs:["Relayer fee and swap rate precision."],type:"u32"},{name:"paused",docs:["Boolean indicating whether outbound transfers are paused."],type:"bool"}]}},{name:"signerSequence",type:{kind:"struct",fields:[{name:"value",type:"u64"}]}}],types:[{name:"OutboundTokenBridgeAddresses",type:{kind:"struct",fields:[{name:"sequence",type:"publicKey"}]}},{name:"TokenBridgeRelayerMessage",docs:["Expected message types for this program. Only valid payloads are:","* `TransferWithRelay`: Payload ID == 1.","","Payload IDs are encoded as u8."],type:{kind:"enum",variants:[{name:"TransferWithRelay",fields:[{name:"target_relayer_fee",type:"u64"},{name:"to_native_token_amount",type:"u64"},{name:"recipient",type:{array:["u8",32]}}]}]}}],errors:[{code:6e3,name:"InvalidWormholeBridge",msg:"InvalidWormholeBridge"},{code:6001,name:"InvalidWormholeFeeCollector",msg:"InvalidWormholeFeeCollector"},{code:6002,name:"OwnerOnly",msg:"OwnerOnly"},{code:6003,name:"OutboundTransfersPaused",msg:"OutboundTransfersPaused"},{code:6004,name:"OwnerOrAssistantOnly",msg:"OwnerOrAssistantOnly"},{code:6005,name:"NotPendingOwner",msg:"NotPendingOwner"},{code:6006,name:"AlreadyTheOwner",msg:"AlreadyTheOwner"},{code:6007,name:"AlreadyTheAssistant",msg:"AlreadyTheAssistant"},{code:6008,name:"AlreadyTheFeeRecipient",msg:"AlreadyTheFeeRecipient"},{code:6009,name:"BumpNotFound",msg:"BumpNotFound"},{code:6010,name:"FailedToMakeImmutable",msg:"FailedToMakeImmutable"},{code:6011,name:"InvalidForeignContract",msg:"InvalidForeignContract"},{code:6012,name:"ZeroBridgeAmount",msg:"ZeroBridgeAmount"},{code:6013,name:"InvalidToNativeAmount",msg:"InvalidToNativeAmount"},{code:6014,name:"NativeMintRequired",msg:"NativeMintRequired"},{code:6015,name:"SwapsNotAllowedForNativeMint",msg:"SwapsNotAllowedForNativeMint"},{code:6016,name:"InvalidTokenBridgeConfig",msg:"InvalidTokenBridgeConfig"},{code:6017,name:"InvalidTokenBridgeAuthoritySigner",msg:"InvalidTokenBridgeAuthoritySigner"},{code:6018,name:"InvalidTokenBridgeCustodySigner",msg:"InvalidTokenBridgeCustodySigner"},{code:6019,name:"InvalidTokenBridgeEmitter",msg:"InvalidTokenBridgeEmitter"},{code:6020,name:"InvalidTokenBridgeSequence",msg:"InvalidTokenBridgeSequence"},{code:6021,name:"InvalidRecipient",msg:"InvalidRecipient"},{code:6022,name:"InvalidTransferToChain",msg:"InvalidTransferToChain"},{code:6023,name:"InvalidTransferTokenChain",msg:"InvalidTransferTokenChain"},{code:6024,name:"InvalidPrecision",msg:"InvalidPrecision"},{code:6025,name:"InvalidTransferToAddress",msg:"InvalidTransferToAddress"},{code:6026,name:"AlreadyRedeemed",msg:"AlreadyRedeemed"},{code:6027,name:"InvalidTokenBridgeForeignEndpoint",msg:"InvalidTokenBridgeForeignEndpoint"},{code:6028,name:"InvalidTokenBridgeMintAuthority",msg:"InvalidTokenBridgeMintAuthority"},{code:6029,name:"InvalidPublicKey",msg:"InvalidPublicKey"},{code:6030,name:"ZeroSwapRate",msg:"ZeroSwapRate"},{code:6031,name:"TokenNotRegistered",msg:"TokenNotRegistered"},{code:6032,name:"ChainNotRegistered",msg:"ChainNotRegistered"},{code:6033,name:"TokenAlreadyRegistered",msg:"TokenAlreadyRegistered"},{code:6034,name:"FeeCalculationError",msg:"TokenFeeCalculationError"},{code:6035,name:"InvalidSwapCalculation",msg:"InvalidSwapCalculation"},{code:6036,name:"InsufficientFunds",msg:"InsufficientFunds"}]};function De(e,t){return new lt(kr,new c(e),{connection:t})}function Et(e,t){return T([l.Buffer.from("seq"),new c(t).toBuffer()],e)}async function br(e,t,r,n,i,a,o,s,d,u,m,h){const{methods:{transferNativeTokensWithRelay:g},account:{signerSequence:w}}=De(t,e),p=Et(t,r),C=await w.fetch(p).then(({value:x})=>x).catch(x=>{var q;if((q=x.message)!=null&&q.includes("Account does not exist"))return new v(0);throw x}),R=bt(t,r,C),F=We(new c(a),new c(r)),I=kt(t,a),ie=Ar(t,n,i,r,R,F,a);return g(new v(o.toString()),new v(s.toString()),y(u),[...d],m,h).accounts({config:Mt(t),payerSequence:p,foreignContract:Ie(t,u),registeredToken:Ue(t,a),tmpTokenAccount:I,tokenBridgeProgram:new c(n),...ie}).instruction()}async function Tr(e,t,r,n,i,a,o,s,d,u,m){const{methods:{transferWrappedTokensWithRelay:h},account:{signerSequence:g}}=De(t,e),w=Et(t,r),p=await g.fetch(w).then(({value:q})=>q).catch(q=>{var Ve;if((Ve=q.message)!=null&&Ve.includes("Account does not exist"))return new v(0);throw q}),C=bt(t,r,p),R=We(new c(a),new c(r)),{chain:F,tokenAddress:I}=await me(e,n,a),ie=kt(t,a),x=Mr(t,n,i,r,C,R,F,I);return h(new v(o.toString()),new v(s.toString()),y(u),[...d],m).accounts({config:Mt(t),payerSequence:w,foreignContract:Ie(t,u),registeredToken:Ue(t,new c(a)),tmpTokenAccount:ie,tokenBridgeProgram:new c(n),...x}).instruction()}class qe{constructor(t,r,n,i){f(this,"network");f(this,"chain");f(this,"connection");f(this,"contracts");f(this,"chainId");f(this,"coreBridge");f(this,"tokenBridge");this.network=t,this.chain=r,this.connection=n,this.contracts=i,this.chainId=y(r);const a=i.tokenBridge;if(!a)throw new Error(`TokenBridge contract Address for chain ${r} not found`);this.tokenBridge=W(a,n),this.coreBridge=new Ht(t,r,n,i)}static async fromRpc(t,r){const[n,i]=await oe.chainFromRpc(t),a=r[i];if(a.network!==n)throw new Error(`Network mismatch for chain ${i}: ${a.network} != ${n}`);return new qe(n,i,t,a.contracts)}async isWrappedAsset(t){return me(this.connection,this.tokenBridge.programId,new k(t).toUint8Array()).catch(r=>null).then(r=>r!=null)}async getOriginalAsset(t){if(!await this.isWrappedAsset(t))throw Ce(t.toString());const r=new k(t).toUint8Array(),n=new c(r);try{const i=await me(this.connection,this.tokenBridge.programId,r);return i===null?{chain:this.chain,address:new k(n.toBytes()).toUniversalAddress()}:{chain:Zt(i.chain),address:new dt(new Uint8Array(i.tokenAddress))}}catch{throw Ce(t.toString())}}async getTokenUniversalAddress(t){return new k(t).toUniversalAddress()}async getTokenNativeAddress(t,r){return new k(r).toNative()}async hasWrappedAsset(t){try{return await this.getWrappedAsset(t),!0}catch{}return!1}async getWrappedAsset(t){if(j(t.address))throw new Error("Native cannot be a wrapped asset");const r=re(this.tokenBridge.programId,y(t.chain),t.address.toUniversalAddress().toUint8Array());try{return await me(this.connection,this.tokenBridge.programId,r),Be(this.chain,r.toBase58())}catch{}throw Ce(`${r}: ${t.address.toUniversalAddress().toString()}`)}async isTransferCompleted(t){return Yt(this.connection,this.tokenBridge.programId,t.emitterAddress.toUint8Array(),y(t.emitterChain),t.sequence,this.connection.commitment).catch(()=>!1)}async getWrappedNative(){return Be(this.chain,D.toBase58())}async*createAttestation(t,r){if(!r)throw new Error("Payer required to create attestation");const n=new k(r).unwrap(),i=0,a=await this.coreBridge.getMessageFee(),o=Qt(this.coreBridge.coreBridge.programId,n,a),s=ae.generate(),d=or(this.connection,this.tokenBridge.programId,this.coreBridge.address,n,new k(t).unwrap(),s.publicKey,i),u=new L().add(o,d);u.feePayer=n,yield this.createUnsignedTx({transaction:u,signers:[s]},"Solana.AttestToken")}async*submitAttestation(t,r){if(!r)throw new Error("Payer required to create attestation");const n=new k(r).unwrap();yield*this.coreBridge.postVaa(n,t);const i=new L().add(lr(this.connection,this.tokenBridge.programId,this.coreBridge.address,n,t));i.feePayer=n,yield this.createUnsignedTx({transaction:i},"Solana.CreateWrapped")}async transferSol(t,r,n,i){const a=new k(t).unwrap(),o=a,s=r.address.toUniversalAddress().toUint8Array(),d=y(r.chain),u=0,m=0n,h=ae.generate(),g=ae.generate(),w=await Xe(this.connection),p=E.createAccount({fromPubkey:o,newAccountPubkey:g.publicKey,lamports:w,space:_,programId:M}),C=E.transfer({fromPubkey:o,lamports:n,toPubkey:g.publicKey}),R=nt(g.publicKey,D,o),F=it(this.tokenBridge.programId,g.publicKey,o,n),I=i?ut(this.connection,this.tokenBridge.programId,this.coreBridge.address,a,h.publicKey,g.publicKey,D,u,n,s,d,i):ct(this.connection,this.tokenBridge.programId,this.coreBridge.address,a,h.publicKey,g.publicKey,D,u,n,m,s,d),ie=Qe(g.publicKey,o,o),x=new L;return x.feePayer=o,x.add(p,C,R,F,I,ie),this.createUnsignedTx({transaction:x,signers:[h,g]},"TokenBridge.TransferNative")}async*transfer(t,r,n,i,a){if(j(n)){yield await this.transferSol(t,r,i,a);return}const o=new k(n).unwrap(),s=new k(t).unwrap(),d=await Je(o,s),u=r.address.toUniversalAddress().toUint8Array(),m=y(r.chain),h=0,g=0n,w=!await this.isWrappedAsset(n),p=ae.generate();let C;if(w)C=a?ut(this.connection,this.tokenBridge.programId,this.coreBridge.address,s,p.publicKey,d,o,h,i,u,m,a):ct(this.connection,this.tokenBridge.programId,this.coreBridge.address,s,p.publicKey,d,o,h,i,g,u,m);else{const I=await this.getOriginalAsset(n);if(j(I.address))throw new Error("Native cannot be an original asset");C=a?Sr(this.connection,this.tokenBridge.programId,this.coreBridge.address,s,p.publicKey,d,s,y(I.chain),I.address.toUint8Array(),h,i,u,m,a):wr(this.connection,this.tokenBridge.programId,this.coreBridge.address,s,p.publicKey,d,s,y(I.chain),I.address.toUint8Array(),h,i,g,u,m)}const R=it(this.tokenBridge.programId,d,s,i),F=new L().add(R,C);F.feePayer=s,yield this.createUnsignedTx({transaction:F,signers:[p]},"TokenBridge.TransferTokens")}async*redeemAndUnwrap(t,r){const n=new k(t).unwrap(),i=new k(r.payload.to.address).unwrap(),a=await an(this.connection,D).then(p=>r.payload.token.amount*BigInt(Math.pow(10,p.decimals-8))),o=await Xe(this.connection),s=ae.generate(),d=ot(this.connection,this.tokenBridge.programId,this.coreBridge.address,n,r),u=E.createAccount({fromPubkey:n,newAccountPubkey:s.publicKey,lamports:o,space:_,programId:M}),m=nt(s.publicKey,D,n),h=Ln(i,s.publicKey,n,a.valueOf()),g=Qe(s.publicKey,n,n),w=new L;w.feePayer=n,w.add(d,u,m,h,g),yield this.createUnsignedTx({transaction:w,signers:[s]},"TokenBridge.RedeemAndUnwrap")}async*createAta(t,r){const n=new k(t).unwrap(),i=new k(r).unwrap(),a=await Je(i,n);if(await this.connection.getAccountInfo(a)===null){const s=new L().add(At(n,a,n,i));s.feePayer=n,yield this.createUnsignedTx({transaction:s},"Redeem.CreateATA")}}async*redeem(t,r,n=!0){const i=r.payload.token.chain===this.chain?r.payload.token.address:(await this.getWrappedAsset(r.payload.token)).toUniversalAddress();if(yield*this.createAta(t,i),yield*this.coreBridge.postVaa(t,r),n){const d=new k(await this.getWrappedNative());if(Xt.equals(i.toUint8Array(),d.toUint8Array())){yield*this.redeemAndUnwrap(t,r);return}}const a=new k(t).unwrap(),o=r.payload.token.chain==this.chain?ot:ur,s=new L().add(o(this.connection,this.tokenBridge.programId,this.coreBridge.address,a,r));s.feePayer=a,yield this.createUnsignedTx({transaction:s},"Solana.RedeemTransfer")}createUnsignedTx(t,r,n=!1){return new ft(t,this.network,this.chain,r,n)}}const Cr={Testnet:["7VPWjBhCXrpYYBiRKZh1ubh9tLZZNkZGp2ReRphEV4Mc","3WK3mEDNPrNuQReBvM28NcsqrExMnPxD9pPJmgrUeKKH","BaGfF51MQ3a61papTRDYaNefBgTQ9ywnVne5fCff4bxT","ACbmcQxbbhiXWM1GmapUSMmBYKMvnFLfAAXKqdo8xKwo","GQtMXZxnuacCFTXVeTvyHi6P9F6chbtzhVc8JgD8hv7c","3Ftc5hTz9sG4huk79onufGiebJNDMZNL8HYgdMJ9E7JR","DMw2tLaq1bVoAEKtkoUtieSk9bfCPUvubYLatTMsSVop","84F2QX9278ToDmA98u4A86xSV9hz1ovazr8zwGaX6qjS","So11111111111111111111111111111111111111112","8987WGkYa5viiZ9DD8sS3PB5XghKmWjkEgmzvwDuoAEc","BJZ72CjPQojVoH68mzrd4VQ4nr6KuhbAGnhZEZCujKxY"],Mainnet:["7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs","A9mUU4qviSctJVPJdBJWkb28deg915LYJKrzQ19ji3FM","Dn4noZ5jgGfkntzcQSUZ8czkreiZ1ForXYoV2H8Dm7S1","3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh","9gP2kCy3wA1ctvYWQk75guqXuHfrEomqydHLtcTCqiLa","Gz7VkD4MacbEB6yC5XD3HcumEiYx2EtDYYrfikGsvopG","KgV1GvrHQmRBY8sHQQeUKwTm2r2h8t4C8qt12Cw1HVE","DRQBDBEWmwWGK13fRTLhSPzjbvMSUavhV6nW4RUH8W6T","9kvAcwQbqejuJMd59mKuw2bfSsLRaQ7zuvaTVHEeBBec","7ixSaXGsHAFy34wogPk2YXiUX3BMmQMFdercdaHLnBby","G1vJEgzepqhnVu35BN4jrkv3wVwkujYWFFCxhbEZ1CZr","So11111111111111111111111111111111111111112"],Devnet:[]},X=9,se=new v(10),J=new v(1e8);class Ke{constructor(t,r,n,i){f(this,"network");f(this,"chain");f(this,"connection");f(this,"contracts");f(this,"chainId");f(this,"coreBridgeProgramId");f(this,"tokenBridgeProgramId");f(this,"tokenBridgeRelayer");this.network=t,this.chain=r,this.connection=n,this.contracts=i,this.chainId=y(r);const a=i.tokenBridgeRelayer;if(!a)throw new Error(`TokenBridge contract Address for chain ${r} not found`);this.tokenBridgeRelayer=De(a,n),this.tokenBridgeProgramId=new c(i.tokenBridge),this.coreBridgeProgramId=new c(i.coreBridge)}static async fromRpc(t,r){const[n,i]=await oe.chainFromRpc(t),a=r[i];if(a.network!==n)throw new Error(`Network mismatch for chain ${i}: ${a.network} != ${n}`);return new Ke(n,i,t,a.contracts)}async*transfer(t,r,n,i,a){const s=new k(t).unwrap(),d=r.address.toUniversalAddress().toUint8Array(),u=this.mintAddress(n),m=new L;if(j(n)){const p=We(u,s);try{await tn(this.connection,p)}catch(C){if(C instanceof Re){const R=At(s,p,s,u);m.add(R)}else throw C}}const h=a||0n,g=j(n),w=g?await br(this.connection,this.tokenBridgeRelayer.programId,s,this.tokenBridgeProgramId,this.coreBridgeProgramId,u,i,h,d,r.chain,0,g):await Tr(this.connection,this.tokenBridgeRelayer.programId,s,this.tokenBridgeProgramId,this.coreBridgeProgramId,u,i,h,d,r.chain,0);m.add(w),m.feePayer=s,yield this.createUnsignedTx({transaction:m},"AutomaticTokenBridge.Transfer")}async*redeem(t,r){const n=new L;throw yield this.createUnsignedTx({transaction:n},"AutomaticTokenBridge.Redeem"),new Error("Method not implemented.")}async getRelayerFee(t,r){const n=this.mintAddress(r),[{fee:i},{swapRate:a},{relayerFeePrecision:o}]=await Promise.all([this.getForeignContract(t),this.getRegisteredToken(n),this.getRedeemerConfig()]),s=Number(await oe.getDecimals(this.chain,this.connection,r)),d=se.pow(new v(s)).mul(i).mul(J).div(new v(o).mul(a));return BigInt(d.toString())}async maxSwapAmount(t){const r=this.mintAddress(t),[{swapRate:n,maxNativeSwapAmount:i},{swapRate:a}]=await Promise.all([this.getRegisteredToken(r),this.getRegisteredToken(D)]),o=Number(await oe.getDecimals(this.chain,this.connection,t)),s=this.calculateNativeSwapRate(a,n),d=o>X?i.mul(s).mul(se.pow(new v(o-X))).div(J):i.mul(s).div(se.pow(new v(X-o)).mul(J));return BigInt(d.toString())}async nativeTokenAmount(t,r){if(r===0n)return 0n;const n=this.mintAddress(t),i=Number(await oe.getDecimals(this.chain,this.connection,t)),[{swapRate:a},{swapRate:o}]=await Promise.all([this.getRegisteredToken(n),this.getRegisteredToken(D)]),s=this.calculateNativeSwapRate(o,a),d=i>X?J.mul(new v(r.toString())).div(s.mul(se.pow(new v(i-X)))):J.mul(new v(r.toString())).mul(se.pow(new v(X-i))).div(s);return BigInt(d.toString())}async isRegisteredToken(t){var n;const r=this.mintAddress(t);try{return await this.getRegisteredToken(r),!0}catch(i){if((n=i.message)!=null&&n.includes("Account does not exist"))return!1;throw i}}mintAddress(t){return j(t)?new c(D):new k(t).unwrap()}async getRegisteredTokens(){return Cr[this.network].map(t=>Be(this.chain,t))}calculateNativeSwapRate(t,r){return J.mul(t).div(r)}async getForeignContract(t){return await this.tokenBridgeRelayer.account.foreignContract.fetch(Ie(this.tokenBridgeRelayer.programId,t))}async getRegisteredToken(t){return await this.tokenBridgeRelayer.account.registeredToken.fetch(Ue(this.tokenBridgeRelayer.programId,t))}async getRedeemerConfig(){return await this.tokenBridgeRelayer.account.redeemerConfig.fetch(Dn(this.tokenBridgeRelayer.programId))}createUnsignedTx(t,r,n=!1){return new ft(t,this.network,this.chain,r,n)}}mt(gt,"TokenBridge",qe);mt(gt,"AutomaticTokenBridge",Ke);export{pe as CreateMetadataAccountArgs,K as Creator,be as Data,Fe as EndpointRegistration,at as Key,Le as Metadata,Ke as SolanaAutomaticTokenBridge,qe as SolanaTokenBridge,de as SplTokenMetadataProgram,vt as TOKEN_BRIDGE_IDL,kr as TOKEN_BRIDGE_RELAYER_IDL,Ne as TokenBridgeConfig,Oe as WrappedMeta,sr as coder,it as createApproveAuthoritySignerInstruction,or as createAttestTokenInstruction,ot as createCompleteTransferNativeInstruction,ur as createCompleteTransferWrappedInstruction,lr as createCreateWrappedInstruction,_r as createInitializeInstruction,W as createReadOnlyTokenBridgeProgramInterface,Wr as createRegisterChainInstruction,ar as createTokenBridgeProgramInterface,De as createTokenBridgeRelayerProgramInterface,ct as createTransferNativeInstruction,br as createTransferNativeTokensWithRelayInstruction,ut as createTransferNativeWithPayloadInstruction,wr as createTransferWrappedInstruction,Tr as createTransferWrappedTokensWithRelayInstruction,Sr as createTransferWrappedWithPayloadInstruction,Ir as createUpgradeContractInstruction,ne as deriveAuthoritySignerKey,Me as deriveCustodyKey,fe as deriveCustodySignerKey,te as deriveEndpointKey,Ie as deriveForeignContractAddress,ke as deriveMintAuthorityKey,ze as deriveRedeemerAccountKey,Dn as deriveRedeemerConfigAddress,Ue as deriveRegisteredTokenAddress,xe as deriveSenderAccountKey,Mt as deriveSenderConfigAddress,Te as deriveSplTokenMetadataKey,kt as deriveTmpTokenAccountAddress,B as deriveTokenBridgeConfigKey,bt as deriveTokenTransferMessageAddress,Y as deriveWrappedMetaKey,re as deriveWrappedMintKey,st as getAttestTokenAccounts,cr as getCompleteTransferNativeAccounts,Nr as getCompleteTransferNativeWithPayloadCpiAccounts,dr as getCompleteTransferWrappedAccounts,Fr as getCompleteTransferWrappedWithPayloadCpiAccounts,fr as getCreateWrappedAccounts,Er as getEndpointRegistration,mr as getInitializeAccounts,Pr as getMetadata,gr as getRegisterChainAccounts,Rr as getTokenBridgeConfig,Ur as getTokenBridgeDerivedAccounts,pr as getTransferNativeAccounts,Bt as getTransferNativeWithPayloadAccounts,Ar as getTransferNativeWithPayloadCpiAccounts,yr as getTransferWrappedAccounts,Rt as getTransferWrappedWithPayloadAccounts,Mr as getTransferWrappedWithPayloadCpiAccounts,hr as getUpgradeContractAccounts,me as getWrappedMeta};
1
+ var Pt=Object.defineProperty;var _t=(e,t,r)=>t in e?Pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var f=(e,t,r)=>_t(e,typeof t!="symbol"?t+"":t,r);import{P as c,i as l,bf as A,cj as le,bj as z,bi as U,bk as G,bh as S,bg as V,cA as Ge,cB as He,cC as Wt,cD as It,cE as Ut,cF as Nt,cu as O,ci as E,bJ as y,cG as T,cH as Ft,cI as ye,cb as dt,cJ as xt,ck as lt,cl as zt,cK as Ot,cL as Y,cM as Lt,cy as H,cz as Z,cN as Dt,cv as qt,cO as Kt,cP as Vt,cQ as Se,cR as Gt,bv as v,cx as Ht,a6 as oe,a7 as k,ca as Ce,bQ as Zt,an as j,cg as Be,cS as Qt,cT as Yt,ab as ae,T as L,cU as Jt,cn as ft,bW as mt,a8 as gt}from"../main.js";const M=new c("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");new c("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");const Ae=new c("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),D=new c("So11111111111111111111111111111111111111112");new c("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP");class ee extends Error{constructor(t){super(t)}}class Re extends ee{constructor(){super(...arguments),this.name="TokenAccountNotFoundError"}}class Xt extends ee{constructor(){super(...arguments),this.name="TokenInvalidAccountError"}}class ht extends ee{constructor(){super(...arguments),this.name="TokenInvalidAccountOwnerError"}}class ce extends ee{constructor(){super(...arguments),this.name="TokenInvalidAccountSizeError"}}class jt extends ee{constructor(){super(...arguments),this.name="TokenInvalidMintError"}}class pt extends ee{constructor(){super(...arguments),this.name="TokenOwnerOffCurveError"}}var $;(function(e){e[e.InitializeMint=0]="InitializeMint",e[e.InitializeAccount=1]="InitializeAccount",e[e.InitializeMultisig=2]="InitializeMultisig",e[e.Transfer=3]="Transfer",e[e.Approve=4]="Approve",e[e.Revoke=5]="Revoke",e[e.SetAuthority=6]="SetAuthority",e[e.MintTo=7]="MintTo",e[e.Burn=8]="Burn",e[e.CloseAccount=9]="CloseAccount",e[e.FreezeAccount=10]="FreezeAccount",e[e.ThawAccount=11]="ThawAccount",e[e.TransferChecked=12]="TransferChecked",e[e.ApproveChecked=13]="ApproveChecked",e[e.MintToChecked=14]="MintToChecked",e[e.BurnChecked=15]="BurnChecked",e[e.InitializeAccount2=16]="InitializeAccount2",e[e.SyncNative=17]="SyncNative",e[e.InitializeAccount3=18]="InitializeAccount3",e[e.InitializeMultisig2=19]="InitializeMultisig2",e[e.InitializeMint2=20]="InitializeMint2",e[e.GetAccountDataSize=21]="GetAccountDataSize",e[e.InitializeImmutableOwner=22]="InitializeImmutableOwner",e[e.AmountToUiAmount=23]="AmountToUiAmount",e[e.UiAmountToAmount=24]="UiAmountToAmount",e[e.InitializeMintCloseAuthority=25]="InitializeMintCloseAuthority",e[e.TransferFeeExtension=26]="TransferFeeExtension",e[e.ConfidentialTransferExtension=27]="ConfidentialTransferExtension",e[e.DefaultAccountStateExtension=28]="DefaultAccountStateExtension",e[e.Reallocate=29]="Reallocate",e[e.MemoTransferExtension=30]="MemoTransferExtension",e[e.CreateNativeMint=31]="CreateNativeMint",e[e.InitializeNonTransferableMint=32]="InitializeNonTransferableMint",e[e.InterestBearingMintExtension=33]="InterestBearingMintExtension",e[e.CpiGuardExtension=34]="CpiGuardExtension",e[e.InitializePermanentDelegate=35]="InitializePermanentDelegate",e[e.TransferHookExtension=36]="TransferHookExtension",e[e.MetadataPointerExtension=39]="MetadataPointerExtension"})($||($={}));function Ee(e,t,r){if(r.length){e.push({pubkey:t,isSigner:!1,isWritable:!1});for(const n of r)e.push({pubkey:n instanceof c?n:n.publicKey,isSigner:!0,isWritable:!1})}else e.push({pubkey:t,isSigner:!0,isWritable:!1});return e}const Ze=A([z("instruction"),U("amount")]);function $t(e,t,r,n,i=[],a=M){const o=Ee([{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t,isSigner:!1,isWritable:!1}],r,i),s=l.Buffer.alloc(Ze.span);return Ze.encode({instruction:$.Approve,amount:BigInt(n)},s),new le({keys:o,programId:a,data:s})}const Qe=A([z("instruction")]);function Ye(e,t,r,n=[],i=M){const a=Ee([{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t,isSigner:!1,isWritable:!0}],r,n),o=l.Buffer.alloc(Qe.span);return Qe.encode({instruction:$.CloseAccount},o),new le({keys:a,programId:i,data:o})}var ge;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Mint=1]="Mint",e[e.Account=2]="Account"})(ge||(ge={}));const Pe=1,en=A([z("m"),z("n"),G("isInitialized"),S("signer1"),S("signer2"),S("signer3"),S("signer4"),S("signer5"),S("signer6"),S("signer7"),S("signer8"),S("signer9"),S("signer10"),S("signer11")]),_e=en.span;var he;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initialized=1]="Initialized",e[e.Frozen=2]="Frozen"})(he||(he={}));const wt=A([S("mint"),S("owner"),U("amount"),V("delegateOption"),S("delegate"),z("state"),V("isNativeOption"),U("isNative"),U("delegatedAmount"),V("closeAuthorityOption"),S("closeAuthority")]),_=wt.span;async function tn(e,t,r,n=M){const i=await e.getAccountInfo(t,r);return rn(t,i,n)}async function Je(e,t){return await nn(e,[],t)}async function nn(e,t,r){const n=zn(t);return await e.getMinimumBalanceForRentExemption(n,r)}function rn(e,t,r=M){if(!t)throw new Re;if(!t.owner.equals(r))throw new ht;if(t.data.length<_)throw new ce;const n=wt.decode(t.data.slice(0,_));let i=l.Buffer.alloc(0);if(t.data.length>_){if(t.data.length===_e)throw new ce;if(t.data[_]!=ge.Account)throw new Xt;i=t.data.slice(_+Pe)}return{address:e,mint:n.mint,owner:n.owner,amount:n.amount,delegate:n.delegateOption?n.delegate:null,delegatedAmount:n.delegatedAmount,isInitialized:n.state!==he.Uninitialized,isFrozen:n.state===he.Frozen,isNative:!!n.isNativeOption,rentExemptReserve:n.isNativeOption?n.isNative:null,closeAuthority:n.closeAuthorityOption?n.closeAuthority:null,tlvData:i}}const yt=A([V("mintAuthorityOption"),S("mintAuthority"),U("supply"),z("decimals"),G("isInitialized"),V("freezeAuthorityOption"),S("freezeAuthority")]),ve=yt.span;async function an(e,t,r,n=M){const i=await e.getAccountInfo(t,r);return sn(t,i,n)}function sn(e,t,r=M){if(!t)throw new Re;if(!t.owner.equals(r))throw new ht;if(t.data.length<ve)throw new ce;const n=yt.decode(t.data.slice(0,ve));let i=l.Buffer.alloc(0);if(t.data.length>ve){if(t.data.length<=_)throw new ce;if(t.data.length===_e)throw new ce;if(t.data[_]!=ge.Mint)throw new jt;i=t.data.slice(_+Pe)}return{address:e,mintAuthority:n.mintAuthorityOption?n.mintAuthority:null,supply:n.supply,decimals:n.decimals,isInitialized:n.isInitialized,freezeAuthority:n.freezeAuthorityOption?n.freezeAuthority:null,tlvData:i}}async function Xe(e,t,r=!1,n=M,i=Ae){if(!r&&!c.isOnCurve(t.toBuffer()))throw new pt;const[a]=await c.findProgramAddress([t.toBuffer(),n.toBuffer(),e.toBuffer()],i);return a}function We(e,t,r=!1,n=M,i=Ae){if(!r&&!c.isOnCurve(t.toBuffer()))throw new pt;const[a]=c.findProgramAddressSync([t.toBuffer(),n.toBuffer(),e.toBuffer()],i);return a}const on=A([G("lockCpi")]),cn=on.span,un=A([z("state")]),dn=un.span,ln=A([]),fn=ln.span,mn=A([S("rateAuthority"),Ge("initializationTimestamp"),He("preUpdateAverageRate"),Ge("lastUpdateTimestamp"),He("currentRate")]),gn=mn.span,hn=A([G("requireIncomingTransferMemos")]),pn=hn.span,wn=A([S("authority"),S("metadataAddress")]),yn=wn.span,Sn=A([S("closeAuthority")]),An=Sn.span,St=A([]),Mn=St.span,kn=St.span,bn=A([S("delegate")]),Tn=bn.span,Cn=1e4;BigInt(Cn);function je(e){return A([U("epoch"),U("maximumFee"),Wt("transferFeeBasisPoints")],e)}const vn=A([S("transferFeeConfigAuthority"),S("withdrawWithheldAuthority"),U("withheldAmount"),je("olderTransferFee"),je("newerTransferFee")]),Bn=vn.span,Rn=A([U("withheldAmount")]),En=Rn.span,Pn=A([S("authority"),S("programId")]),_n=Pn.span,Wn=A([G("transferring")]),In=Wn.span,$e=A([z("discriminator"),It(32,"addressConfig"),G("isSigner"),G("isWritable")]),Un=A([V("count"),Ut($e,Nt($e.span),"extraAccounts")]);A([U("instructionDiscriminator"),V("length"),Un.replicate("extraAccountsList")]);var b;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.TransferFeeConfig=1]="TransferFeeConfig",e[e.TransferFeeAmount=2]="TransferFeeAmount",e[e.MintCloseAuthority=3]="MintCloseAuthority",e[e.ConfidentialTransferMint=4]="ConfidentialTransferMint",e[e.ConfidentialTransferAccount=5]="ConfidentialTransferAccount",e[e.DefaultAccountState=6]="DefaultAccountState",e[e.ImmutableOwner=7]="ImmutableOwner",e[e.MemoTransfer=8]="MemoTransfer",e[e.NonTransferable=9]="NonTransferable",e[e.InterestBearingConfig=10]="InterestBearingConfig",e[e.CpiGuard=11]="CpiGuard",e[e.PermanentDelegate=12]="PermanentDelegate",e[e.NonTransferableAccount=13]="NonTransferableAccount",e[e.TransferHook=14]="TransferHook",e[e.TransferHookAccount=15]="TransferHookAccount",e[e.MetadataPointer=18]="MetadataPointer"})(b||(b={}));const et=2,Nn=2;function Fn(e){switch(e){case b.Uninitialized:return 0;case b.TransferFeeConfig:return Bn;case b.TransferFeeAmount:return En;case b.MintCloseAuthority:return An;case b.ConfidentialTransferMint:return 97;case b.ConfidentialTransferAccount:return 286;case b.CpiGuard:return cn;case b.DefaultAccountState:return dn;case b.ImmutableOwner:return fn;case b.MemoTransfer:return pn;case b.MetadataPointer:return yn;case b.NonTransferable:return Mn;case b.InterestBearingConfig:return gn;case b.PermanentDelegate:return Tn;case b.NonTransferableAccount:return kn;case b.TransferHook:return _n;case b.TransferHookAccount:return In;default:throw Error(`Unknown extension type: ${e}`)}}function xn(e,t){if(e.length===0)return t;{const r=_+Pe+e.filter((n,i)=>i===e.indexOf(n)).map(n=>Fn(n)+et+Nn).reduce((n,i)=>n+i);return r===_e?r+et:r}}function zn(e){return xn(e,_)}const tt=A([z("instruction")]);function nt(e,t,r,n=M){const i=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:O,isSigner:!1,isWritable:!1}],a=l.Buffer.alloc(tt.span);return tt.encode({instruction:$.InitializeAccount},a),new le({keys:i,programId:n,data:a})}function At(e,t,r,n,i=M,a=Ae){return On(e,t,r,n,l.Buffer.alloc(0),i,a)}function On(e,t,r,n,i,a=M,o=Ae){const s=[{pubkey:e,isSigner:!0,isWritable:!0},{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:E.programId,isSigner:!1,isWritable:!1},{pubkey:a,isSigner:!1,isWritable:!1}];return new le({keys:s,programId:o,data:i})}const rt=A([z("instruction"),U("amount")]);function Ln(e,t,r,n,i=[],a=M){const o=Ee([{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t,isSigner:!1,isWritable:!0}],r,i),s=l.Buffer.alloc(rt.span);return rt.encode({instruction:$.Transfer,amount:BigInt(n)},s),new le({keys:o,programId:a,data:s})}function Ie(e,t){const r=l.Buffer.alloc(2);return r.writeUInt16BE(y(t)),T([l.Buffer.from("foreign_contract"),r],e)}function Dn(e){return T([l.Buffer.from("redeemer")],e)}function Ue(e,t){return T([l.Buffer.from("mint"),new c(t).toBuffer()],e)}function Mt(e){return T([l.Buffer.from("sender")],e)}function kt(e,t){return T([l.Buffer.from("tmp"),new c(t).toBuffer()],e)}function bt(e,t,r){return T([l.Buffer.from("bridged"),new c(t).toBuffer(),l.Buffer.from(Ft.toBytes(BigInt(r.toString()),8))],e)}function B(e){return T([l.Buffer.from("config")],e)}async function Rr(e,t,r){return e.getAccountInfo(B(t),r).then(n=>Ne.deserialize(ye(n)))}class Ne{constructor(t){f(this,"wormhole");this.wormhole=new c(t)}static deserialize(t){if(t.length!=32)throw new Error("data.length != 32");const r=t.subarray(0,32);return new Ne(r)}}function Me(e,t){return T([new c(t).toBuffer()],e)}function te(e,t,r){if(t==y("Solana"))throw new Error("emitterChain == CHAIN_ID_SOLANA cannot exist as foreign token bridge emitter");const n=typeof r=="string"?new dt(r).toUint8Array():r;return T([(()=>{const i=l.Buffer.alloc(2);return i.writeUInt16BE(t),i})(),n],e)}async function Er(e,t,r){return e.getAccountInfo(new c(t),r).then(n=>Fe.deserialize(ye(n)))}class Fe{constructor(t,r){f(this,"chain");f(this,"contract");this.chain=t,this.contract=r}static deserialize(t){if(t.length!=34)throw new Error("data.length != 34");const r=t.readUInt16LE(0),n=t.subarray(2,34);return new Fe(r,n)}}function xe(e){return T([l.Buffer.from("sender")],e)}function ze(e){return T([l.Buffer.from("redeemer")],e)}function ne(e){return T([l.Buffer.from("authority_signer")],e)}function fe(e){return T([l.Buffer.from("custody_signer")],e)}function ke(e){return T([l.Buffer.from("mint_signer")],e)}function re(e,t,r){if(t==y("Solana"))throw new Error("tokenChain == CHAIN_ID_SOLANA does not have wrapped mint key");return T([l.Buffer.from("wrapped"),(()=>{const n=l.Buffer.alloc(2);return n.writeUInt16BE(t),n})(),r],e)}function Q(e,t){return T([l.Buffer.from("meta"),new c(t).toBuffer()],e)}async function me(e,t,r,n){return e.getAccountInfo(Q(t,r),n).then(i=>Oe.deserialize(ye(i)))}class Oe{constructor(t,r,n,i){f(this,"chain");f(this,"tokenAddress");f(this,"originalDecimals");f(this,"lastUpdatedSequence");this.chain=t,this.tokenAddress=r,this.originalDecimals=n,this.lastUpdatedSequence=i}static deserialize(t){if(t.length!==35&&t.length!==43)throw new Error(`invalid wrapped meta length: ${t.length}`);const r=t.readUInt16LE(0),n=t.subarray(2,34),i=t.readUInt8(34),a=t.length===43?t.readBigUInt64LE(35):void 0;return new Oe(r,n,i,a)}}function it(e,t,r,n){return $t(new c(t),ne(e),new c(r),n)}class qn{constructor(t){f(this,"idl");this.idl=t}async encode(t,r){switch(t){default:throw new Error(`Invalid account name: ${t}`)}}decode(t,r){return this.decodeUnchecked(t,r)}decodeUnchecked(t,r){switch(t){default:throw new Error(`Invalid account name: ${t}`)}}memcmp(t,r){switch(t){default:throw new Error(`Invalid account name: ${t}`)}}size(t){return xt(this.idl,t)??0}}class Kn{constructor(t){}decode(t){throw new Error("Token Bridge program does not have events")}}class Vn{constructor(t){}encode(t,r){switch(t){case"initialize":return Gn(r);case"attestToken":return Hn(r);case"completeNative":return Zn(r);case"completeWrapped":return Qn(r);case"transferWrapped":return Yn(r);case"transferNative":return Jn(r);case"registerChain":return Xn(r);case"createWrapped":return jn(r);case"upgradeContract":return $n(r);case"transferWrappedWithPayload":return er(r);case"transferNativeWithPayload":return tr(r);default:throw new Error(`Invalid instruction: ${t}`)}}encodeState(t,r){throw new Error("Token Bridge program does not have state")}}var P;(function(e){e[e.Initialize=0]="Initialize",e[e.AttestToken=1]="AttestToken",e[e.CompleteNative=2]="CompleteNative",e[e.CompleteWrapped=3]="CompleteWrapped",e[e.TransferWrapped=4]="TransferWrapped",e[e.TransferNative=5]="TransferNative",e[e.RegisterChain=6]="RegisterChain",e[e.CreateWrapped=7]="CreateWrapped",e[e.UpgradeContract=8]="UpgradeContract",e[e.CompleteNativeWithPayload=9]="CompleteNativeWithPayload",e[e.CompleteWrappedWithPayload=10]="CompleteWrappedWithPayload",e[e.TransferWrappedWithPayload=11]="TransferWrappedWithPayload",e[e.TransferNativeWithPayload=12]="TransferNativeWithPayload"})(P||(P={}));function N(e,t){const r=t===void 0?0:t.length,n=l.Buffer.alloc(1+r);return n.writeUInt8(e,0),r>0&&n.write(t.toString("hex"),1,"hex"),n}function Gn({wormhole:e}){const t=l.Buffer.alloc(32);return t.write(new c(e).toBuffer().toString("hex"),0,"hex"),N(P.Initialize,t)}function Hn({nonce:e}){const t=l.Buffer.alloc(4);return t.writeUInt32LE(e,0),N(P.AttestToken,t)}function Zn({}){return N(P.CompleteNative)}function Qn({}){return N(P.CompleteWrapped)}function Tt({nonce:e,amount:t,fee:r,targetAddress:n,targetChain:i}){if(typeof t!="bigint"&&(t=BigInt(t)),typeof r!="bigint"&&(r=BigInt(r)),!l.Buffer.isBuffer(n))throw new Error("targetAddress must be Buffer");const a=l.Buffer.alloc(54);return a.writeUInt32LE(e,0),a.writeBigUInt64LE(t,4),a.writeBigUInt64LE(r,12),a.write(n.toString("hex"),20,"hex"),a.writeUInt16LE(i,52),a}function Yn({nonce:e,amount:t,fee:r,targetAddress:n,targetChain:i}){return N(P.TransferWrapped,Tt({nonce:e,amount:t,fee:r,targetAddress:n,targetChain:i}))}function Jn({nonce:e,amount:t,fee:r,targetAddress:n,targetChain:i}){return N(P.TransferNative,Tt({nonce:e,amount:t,fee:r,targetAddress:n,targetChain:i}))}function Xn({}){return N(P.RegisterChain)}function jn({}){return N(P.CreateWrapped)}function $n({}){return N(P.UpgradeContract)}function Ct({nonce:e,amount:t,targetAddress:r,targetChain:n,payload:i}){if(typeof t!="bigint"&&(t=BigInt(t)),!l.Buffer.isBuffer(r))throw new Error("targetAddress must be Buffer");if(!l.Buffer.isBuffer(i))throw new Error("payload must be Buffer");const a=l.Buffer.alloc(50);return a.writeUInt32LE(e,0),a.writeBigUInt64LE(t,4),a.write(r.toString("hex"),12,"hex"),a.writeUInt16LE(n,44),a.writeUInt32LE(i.length,46),l.Buffer.concat([a,i,l.Buffer.alloc(1)])}function er({nonce:e,amount:t,fee:r,targetAddress:n,targetChain:i,payload:a}){return N(P.TransferWrappedWithPayload,Ct({nonce:e,amount:t,targetAddress:n,targetChain:i,payload:a}))}function tr({nonce:e,amount:t,fee:r,targetAddress:n,targetChain:i,payload:a}){return N(P.TransferNativeWithPayload,Ct({nonce:e,amount:t,targetAddress:n,targetChain:i,payload:a}))}class nr{constructor(t){}encode(t,r){throw new Error("Token Bridge program does not have state")}decode(t){throw new Error("Token Bridge program does not have state")}}class rr{constructor(t){}encode(t,r){throw new Error("Token Bridge program does not have user-defined types")}decode(t,r){throw new Error("Token Bridge program does not have user-defined types")}}class ir{constructor(t){f(this,"instruction");f(this,"accounts");f(this,"state");f(this,"events");f(this,"types");this.instruction=new Vn(t),this.accounts=new qn(t),this.state=new nr(t),this.events=new Kn(t),this.types=new rr(t)}}const vt={version:"0.1.0",name:"wormhole",instructions:[{name:"initialize",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"config",isMut:!0,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"wormhole",type:"publicKey"}]},{name:"attestToken",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"config",isMut:!0,isSigner:!1},{name:"mint",isMut:!1,isSigner:!1},{name:"wrappedMeta",isMut:!1,isSigner:!1},{name:"splMetadata",isMut:!1,isSigner:!1},{name:"wormholeBridge",isMut:!0,isSigner:!1},{name:"wormholeMessage",isMut:!0,isSigner:!0},{name:"wormholeEmitter",isMut:!1,isSigner:!1},{name:"wormholeSequence",isMut:!0,isSigner:!1},{name:"wormholeFeeCollector",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1}],args:[{name:"nonce",type:"u32"}]},{name:"completeNative",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"config",isMut:!1,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"endpoint",isMut:!1,isSigner:!1},{name:"to",isMut:!0,isSigner:!1},{name:"toFees",isMut:!0,isSigner:!1},{name:"custody",isMut:!0,isSigner:!1},{name:"mint",isMut:!1,isSigner:!1},{name:"custodySigner",isMut:!1,isSigner:!1},{name:"rent",isMut:!0,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1}],args:[]},{name:"completeWrapped",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"config",isMut:!1,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"endpoint",isMut:!1,isSigner:!1},{name:"to",isMut:!0,isSigner:!1},{name:"toFees",isMut:!0,isSigner:!1},{name:"mint",isMut:!0,isSigner:!1},{name:"wrappedMeta",isMut:!1,isSigner:!1},{name:"mintAuthority",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1}],args:[]},{name:"transferWrapped",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"config",isMut:!1,isSigner:!1},{name:"from",isMut:!0,isSigner:!1},{name:"fromOwner",isMut:!0,isSigner:!0},{name:"mint",isMut:!0,isSigner:!1},{name:"wrappedMeta",isMut:!1,isSigner:!1},{name:"authoritySigner",isMut:!1,isSigner:!1},{name:"wormholeBridge",isMut:!0,isSigner:!1},{name:"wormholeMessage",isMut:!0,isSigner:!0},{name:"wormholeEmitter",isMut:!1,isSigner:!1},{name:"wormholeSequence",isMut:!0,isSigner:!1},{name:"wormholeFeeCollector",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1}],args:[{name:"nonce",type:"u32"},{name:"amount",type:"u64"},{name:"fee",type:"u64"},{name:"targetAddress",type:{array:["u8",32]}},{name:"targetChain",type:"u16"}]},{name:"transferNative",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"config",isMut:!1,isSigner:!1},{name:"from",isMut:!0,isSigner:!1},{name:"mint",isMut:!0,isSigner:!1},{name:"custody",isMut:!0,isSigner:!1},{name:"authoritySigner",isMut:!1,isSigner:!1},{name:"custodySigner",isMut:!1,isSigner:!1},{name:"wormholeBridge",isMut:!0,isSigner:!1},{name:"wormholeMessage",isMut:!0,isSigner:!0},{name:"wormholeEmitter",isMut:!1,isSigner:!1},{name:"wormholeSequence",isMut:!0,isSigner:!1},{name:"wormholeFeeCollector",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1}],args:[{name:"nonce",type:"u32"},{name:"amount",type:"u64"},{name:"fee",type:"u64"},{name:"targetAddress",type:{array:["u8",32]}},{name:"targetChain",type:"u16"}]},{name:"registerChain",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"config",isMut:!1,isSigner:!1},{name:"endpoint",isMut:!0,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1}],args:[]},{name:"createWrapped",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"config",isMut:!1,isSigner:!1},{name:"endpoint",isMut:!1,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"mint",isMut:!0,isSigner:!1},{name:"wrappedMeta",isMut:!0,isSigner:!1},{name:"splMetadata",isMut:!0,isSigner:!1},{name:"mintAuthority",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"splMetadataProgram",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1}],args:[]},{name:"upgradeContract",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"upgradeAuthority",isMut:!1,isSigner:!1},{name:"spill",isMut:!0,isSigner:!1},{name:"implementation",isMut:!0,isSigner:!1},{name:"programData",isMut:!0,isSigner:!1},{name:"tokenBridgeProgram",isMut:!0,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"bpfLoaderUpgradeable",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[]},{name:"transferWrappedWithPayload",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"config",isMut:!1,isSigner:!1},{name:"from",isMut:!0,isSigner:!1},{name:"fromOwner",isMut:!0,isSigner:!0},{name:"mint",isMut:!0,isSigner:!1},{name:"wrappedMeta",isMut:!1,isSigner:!1},{name:"authoritySigner",isMut:!1,isSigner:!1},{name:"wormholeBridge",isMut:!0,isSigner:!1},{name:"wormholeMessage",isMut:!0,isSigner:!0},{name:"wormholeEmitter",isMut:!1,isSigner:!1},{name:"wormholeSequence",isMut:!0,isSigner:!1},{name:"wormholeFeeCollector",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"sender",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1}],args:[{name:"nonce",type:"u32"},{name:"amount",type:"u64"},{name:"targetAddress",type:{array:["u8",32]}},{name:"targetChain",type:"u16"},{name:"payload",type:"bytes"},{name:"cpiProgramId",type:{option:"publicKey"}}]},{name:"transferNativeWithPayload",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"config",isMut:!1,isSigner:!1},{name:"from",isMut:!0,isSigner:!1},{name:"mint",isMut:!0,isSigner:!1},{name:"custody",isMut:!0,isSigner:!1},{name:"authoritySigner",isMut:!1,isSigner:!1},{name:"custodySigner",isMut:!1,isSigner:!1},{name:"wormholeBridge",isMut:!0,isSigner:!1},{name:"wormholeMessage",isMut:!0,isSigner:!0},{name:"wormholeEmitter",isMut:!1,isSigner:!1},{name:"wormholeSequence",isMut:!0,isSigner:!1},{name:"wormholeFeeCollector",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"sender",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1}],args:[{name:"nonce",type:"u32"},{name:"amount",type:"u64"},{name:"targetAddress",type:{array:["u8",32]}},{name:"targetChain",type:"u16"},{name:"payload",type:"bytes"},{name:"cpiProgramId",type:{option:"publicKey"}}]}],accounts:[]};function ar(e,t){return new lt(vt,new c(e),t===void 0?{connection:null}:t,sr())}function W(e,t){return ar(e,zt(t))}function sr(){return new ir(vt)}const ue=class ue{constructor(t,r,n){f(this,"address");f(this,"verified");f(this,"share");this.address=new c(t),this.verified=r,this.share=n}serialize(){const t=l.Buffer.alloc(ue.size);return t.write(this.address.toBuffer().toString("hex"),0,"hex"),this.verified&&t.writeUInt8(1,32),t.writeUInt8(this.share,33),t}static deserialize(t){const r=t.subarray(0,32),n=t.readUInt8(32)>0,i=t.readUInt8(33);return new ue(r,n,i)}};f(ue,"size",34);let K=ue;class be{constructor(t,r,n,i,a){f(this,"name");f(this,"symbol");f(this,"uri");f(this,"sellerFeeBasisPoints");f(this,"creators");this.name=t,this.symbol=r,this.uri=n,this.sellerFeeBasisPoints=i,this.creators=a}serialize(){const t=this.name.length,r=this.symbol.length,n=this.uri.length,i=this.creators,[a,o]=(()=>{if(i===null)return[0,0];const d=i.length;return[d,4+d*K.size]})(),s=l.Buffer.alloc(15+t+r+n+o);if(s.writeUInt32LE(t,0),s.write(this.name,4),s.writeUInt32LE(r,4+t),s.write(this.symbol,8+t),s.writeUInt32LE(n,8+t+r),s.write(this.uri,12+t+r),s.writeUInt16LE(this.sellerFeeBasisPoints,12+t+r+n),i===null)s.writeUInt8(0,14+t+r+n);else{s.writeUInt8(1,14+t+r+n),s.writeUInt32LE(a,15+t+r+n);for(let d=0;d<a;++d){const u=i.at(d),m=19+t+r+n+d*K.size;s.write(u.serialize().toString("hex"),m,"hex")}}return s}static deserialize(t){const r=t.readUInt32LE(0),n=t.subarray(4,4+r).toString(),i=t.readUInt32LE(4+r),a=t.subarray(8+r,8+r+i).toString(),o=t.readUInt32LE(8+r+i),s=t.subarray(12+r+i,12+r+i+o).toString(),d=t.readUInt16LE(12+r+i+o),u=t.readUInt8(14+r+i+o),m=(()=>{if(u==0)return null;const h=[],g=t.readUInt32LE(15+r+i+o);for(let w=0;w<g;++w){const p=19+r+i+o+w*K.size;h.push(K.deserialize(t.subarray(p,p+K.size)))}return h})();return new be(n,a,s,d,m)}}class pe extends be{constructor(r,n,i,a,o,s){super(r,n,i,a,o);f(this,"isMutable");this.isMutable=s}static serialize(r,n,i,a,o,s){return new pe(r,n,i,a,o,s).serialize()}static serializeInstructionData(r,n,i,a,o,s){return l.Buffer.concat([l.Buffer.alloc(1,0),pe.serialize(r,n,i,a,o,s)])}serialize(){return l.Buffer.concat([super.serialize(),l.Buffer.alloc(1,this.isMutable?1:0)])}}const we=class we{constructor(){}static createMetadataAccounts(t,r,n,i,a,o,s=!1,d,u,m,h=!1,g=Te(r)){const w=[Ot(g,!1),Y(r,!1),Y(n,!0),Y(t,!0),Y(o,s),Y(E.programId,!1),Y(O,!1)],p=pe.serializeInstructionData(i,a,d===void 0?"":d,m===void 0?0:m,u===void 0?null:u,h);return{programId:we.programId,keys:w,data:p}}};f(we,"programId",new c("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"));let de=we;function Te(e){return T([l.Buffer.from("metadata"),de.programId.toBuffer(),new c(e).toBuffer()],de.programId)}var at;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.EditionV1=1]="EditionV1",e[e.MasterEditionV1=2]="MasterEditionV1",e[e.ReservationListV1=3]="ReservationListV1",e[e.MetadataV1=4]="MetadataV1",e[e.ReservationListV2=5]="ReservationListV2",e[e.MasterEditionV2=6]="MasterEditionV2",e[e.EditionMarker=7]="EditionMarker"})(at||(at={}));class Le{constructor(t,r,n,i,a,o){f(this,"key");f(this,"updateAuthority");f(this,"mint");f(this,"data");f(this,"primarySaleHappened");f(this,"isMutable");this.key=t,this.updateAuthority=new c(r),this.mint=new c(n),this.data=i,this.primarySaleHappened=a,this.isMutable=o}static deserialize(t){const r=t.readUInt8(0),n=t.subarray(1,33),i=t.subarray(33,65),a=be.deserialize(t.subarray(65)),o=a.serialize().length,s=t.readUInt8(65+o)>0,d=t.readUInt8(66+o)>0;return new Le(r,n,i,a,s,d)}}async function Pr(e,t,r){return e.getAccountInfo(Te(t),r).then(n=>Le.deserialize(ye(n)))}function or(e,t,r,n,i,a,o){const s=W(t,e).methods.attestToken(o);return console.log(st(t,r,n,i,a)),s._ixFn(...s._args,{accounts:st(t,r,n,i,a),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function st(e,t,r,n,i){const{bridge:a,emitter:o,sequence:s,feeCollector:d,clock:u,rent:m,systemProgram:h}=Lt(t,r,i,e);return{payer:new c(r),config:B(e),mint:new c(n),wrappedMeta:Q(e,n),splMetadata:Te(n),wormholeBridge:a,wormholeMessage:new c(i),wormholeEmitter:o,wormholeSequence:s,wormholeFeeCollector:d,clock:u,rent:m,systemProgram:h,wormholeProgram:new c(t)}}function ot(e,t,r,n,i,a){const o=W(t,e).methods.completeNative();return o._ixFn(...o._args,{accounts:cr(t,r,n,i,a),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function cr(e,t,r,n,i){const a=new c(n.payload.token.address.toUint8Array());return{payer:new c(r),config:B(e),vaa:Z(t,l.Buffer.from(n.hash)),claim:H(e,n.emitterAddress.toUint8Array(),y(n.emitterChain),n.sequence),endpoint:te(e,y(n.emitterChain),n.emitterAddress.toUint8Array()),to:new c(n.payload.to.address.toUint8Array()),toFees:new c(i===void 0?n.payload.to.address.toUint8Array():i),custody:Me(e,a),mint:a,custodySigner:fe(e),rent:O,systemProgram:E.programId,tokenProgram:M,wormholeProgram:new c(t)}}function ur(e,t,r,n,i,a){const o=W(t,e).methods.completeWrapped();return o._ixFn(...o._args,{accounts:dr(t,r,n,i,a),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function dr(e,t,r,n,i){const a=re(e,y(n.payload.token.chain),n.payload.token.address.toUint8Array());return{payer:new c(r),config:B(e),vaa:Z(t,l.Buffer.from(n.hash)),claim:H(e,n.emitterAddress.toUint8Array(),y(n.emitterChain),n.sequence),endpoint:te(e,y(n.emitterChain),n.emitterAddress.toUint8Array()),to:new c(n.payload.to.address.toUint8Array()),toFees:new c(i===void 0?n.payload.to.address.toUint8Array():i),mint:a,wrappedMeta:Q(e,a),mintAuthority:ke(e),rent:O,systemProgram:E.programId,tokenProgram:M,wormholeProgram:new c(t)}}function lr(e,t,r,n,i){const a=W(t,e).methods.createWrapped();return a._ixFn(...a._args,{accounts:fr(t,r,n,i),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function fr(e,t,r,n){const i=re(e,y(n.payload.token.chain),n.payload.token.address.toUint8Array());return{payer:new c(r),config:B(e),endpoint:te(e,y(n.emitterChain),n.emitterAddress.toUint8Array()),vaa:Z(t,l.Buffer.from(n.hash)),claim:H(e,n.emitterAddress.toUint8Array(),y(n.emitterChain),n.sequence),mint:i,wrappedMeta:Q(e,i),splMetadata:Te(i),mintAuthority:ke(e),rent:O,systemProgram:E.programId,tokenProgram:M,splMetadataProgram:de.programId,wormholeProgram:new c(t)}}function _r(e,t,r){const n=W(e).methods.initialize(r);return n._ixFn(...n._args,{accounts:mr(e,t),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function mr(e,t){return{payer:new c(t),config:B(e),rent:O,systemProgram:E.programId}}function Wr(e,t,r,n){const i=W(e).methods.registerChain();return i._ixFn(...i._args,{accounts:gr(e,t,r,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function gr(e,t,r,n){return{payer:new c(r),config:B(e),endpoint:te(e,y(n.payload.actionArgs.foreignChain),n.payload.actionArgs.foreignAddress.toUint8Array()),vaa:Z(t,l.Buffer.from(n.hash)),claim:H(e,n.emitterAddress.toUint8Array(),y(n.emitterChain),n.sequence),rent:O,systemProgram:E.programId,wormholeProgram:new c(t)}}function Ir(e,t,r,n,i){const a=W(e).methods.upgradeContract();return a._ixFn(...a._args,{accounts:hr(e,t,r,n,i),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function hr(e,t,r,n,i){return{payer:new c(r),vaa:Z(t,l.Buffer.from(n.hash)),claim:H(e,n.emitterAddress.toUint8Array(),y(n.emitterChain),n.sequence),upgradeAuthority:Vt(e),spill:new c(i===void 0?r:i),implementation:new c(n.payload.actionArgs.newContract),programData:Kt(e),tokenBridgeProgram:new c(e),rent:O,clock:qt,bpfLoaderUpgradeable:Dt,systemProgram:E.programId}}function ct(e,t,r,n,i,a,o,s,d,u,m,h){const g=W(t,e).methods.transferNative(s,d,u,l.Buffer.from(m),h);return g._ixFn(...g._args,{accounts:pr(t,r,n,i,a,o),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function pr(e,t,r,n,i,a){const{wormholeBridge:o,wormholeMessage:s,wormholeEmitter:d,wormholeSequence:u,wormholeFeeCollector:m,clock:h,rent:g,systemProgram:w}=Se(e,t,r,n);return{payer:new c(r),config:B(e),from:new c(i),mint:new c(a),custody:Me(e,a),authoritySigner:ne(e),custodySigner:fe(e),wormholeBridge:o,wormholeMessage:s,wormholeEmitter:d,wormholeSequence:u,wormholeFeeCollector:m,clock:h,rent:g,systemProgram:w,tokenProgram:M,wormholeProgram:new c(t)}}function ut(e,t,r,n,i,a,o,s,d,u,m,h){const g=W(t,e).methods.transferNativeWithPayload(s,d,l.Buffer.from(u),m,l.Buffer.from(h),null);return g._ixFn(...g._args,{accounts:Bt(t,r,n,i,a,o),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function Bt(e,t,r,n,i,a,o){const{wormholeBridge:s,wormholeMessage:d,wormholeEmitter:u,wormholeSequence:m,wormholeFeeCollector:h,clock:g,rent:w,systemProgram:p}=Se(e,t,r,n);return{payer:new c(r),config:B(e),from:new c(i),mint:new c(a),custody:Me(e,a),authoritySigner:ne(e),custodySigner:fe(e),wormholeBridge:s,wormholeMessage:d,wormholeEmitter:u,wormholeSequence:m,wormholeFeeCollector:h,clock:g,sender:new c(o===void 0?r:xe(o)),rent:w,systemProgram:p,tokenProgram:M,wormholeProgram:new c(t)}}function wr(e,t,r,n,i,a,o,s,d,u,m,h,g,w){const p=W(t,e).methods.transferWrapped(u,m,h,l.Buffer.from(g),w);return p._ixFn(...p._args,{accounts:yr(t,r,n,i,a,o,s,d),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function yr(e,t,r,n,i,a,o,s){const d=re(e,o,s),{wormholeBridge:u,wormholeMessage:m,wormholeEmitter:h,wormholeSequence:g,wormholeFeeCollector:w,clock:p,rent:C,systemProgram:R}=Se(e,t,r,n);return{payer:new c(r),config:B(e),from:new c(i),fromOwner:new c(a),mint:d,wrappedMeta:Q(e,d),authoritySigner:ne(e),wormholeBridge:u,wormholeMessage:m,wormholeEmitter:h,wormholeSequence:g,wormholeFeeCollector:w,clock:p,rent:C,systemProgram:R,wormholeProgram:new c(t),tokenProgram:M}}function Sr(e,t,r,n,i,a,o,s,d,u,m,h,g,w){const p=W(t,e).methods.transferWrappedWithPayload(u,m,l.Buffer.from(h),g,l.Buffer.from(w),null);return p._ixFn(...p._args,{accounts:Rt(t,r,n,i,a,o,s,d),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function Rt(e,t,r,n,i,a,o,s,d){const u=re(e,o,s),{wormholeBridge:m,wormholeMessage:h,wormholeEmitter:g,wormholeSequence:w,wormholeFeeCollector:p,clock:C,rent:R,systemProgram:F}=Se(e,t,r,n);return{payer:new c(r),config:B(e),from:new c(i),fromOwner:new c(a),mint:u,wrappedMeta:Q(e,u),authoritySigner:ne(e),wormholeBridge:m,wormholeMessage:h,wormholeEmitter:g,wormholeSequence:w,wormholeFeeCollector:p,clock:C,sender:new c(d===void 0?r:xe(d)),rent:R,systemProgram:F,wormholeProgram:new c(t),tokenProgram:M}}function Ur(e,t,r){const{wormholeEmitter:n,wormholeBridge:i,wormholeFeeCollector:a,wormholeSequence:o}=Gt(t,r);return{tokenBridgeConfig:B(t),tokenBridgeAuthoritySigner:ne(t),tokenBridgeCustodySigner:fe(t),tokenBridgeMintAuthority:ke(t),tokenBridgeSender:xe(e),tokenBridgeRedeemer:ze(e),wormholeBridge:i,tokenBridgeEmitter:n,wormholeFeeCollector:a,tokenBridgeSequence:o}}function Ar(e,t,r,n,i,a,o){const s=Bt(t,r,n,i,a,o,e);return{payer:s.payer,tokenBridgeConfig:s.config,fromTokenAccount:s.from,mint:s.mint,tokenBridgeCustody:s.custody,tokenBridgeAuthoritySigner:s.authoritySigner,tokenBridgeCustodySigner:s.custodySigner,wormholeBridge:s.wormholeBridge,wormholeMessage:s.wormholeMessage,tokenBridgeEmitter:s.wormholeEmitter,tokenBridgeSequence:s.wormholeSequence,wormholeFeeCollector:s.wormholeFeeCollector,clock:s.clock,tokenBridgeSender:s.sender,rent:s.rent,systemProgram:s.systemProgram,tokenProgram:s.tokenProgram,wormholeProgram:s.wormholeProgram}}function Mr(e,t,r,n,i,a,o,s,d){const u=Rt(t,r,n,i,a,d===void 0?e:d,o,s,e);return{payer:u.payer,tokenBridgeConfig:u.config,fromTokenAccount:u.from,fromTokenAccountOwner:u.fromOwner,tokenBridgeWrappedMint:u.mint,tokenBridgeWrappedMeta:u.wrappedMeta,tokenBridgeAuthoritySigner:u.authoritySigner,wormholeBridge:u.wormholeBridge,wormholeMessage:u.wormholeMessage,tokenBridgeEmitter:u.wormholeEmitter,tokenBridgeSequence:u.wormholeSequence,wormholeFeeCollector:u.wormholeFeeCollector,clock:u.clock,tokenBridgeSender:u.sender,rent:u.rent,systemProgram:u.systemProgram,tokenProgram:u.tokenProgram,wormholeProgram:u.wormholeProgram}}function Nr(e,t,r,n,i){const a=new c(n.payload.token.address.toUint8Array()),o=new c(n.payload.to.address.toUint8Array());return{payer:new c(r),tokenBridgeConfig:B(e),vaa:Z(t,l.Buffer.from(n.hash)),tokenBridgeClaim:H(e,n.emitterAddress.toUint8Array(),y(n.emitterChain),n.sequence),tokenBridgeForeignEndpoint:te(e,y(n.emitterChain),n.emitterAddress.toUint8Array()),toTokenAccount:new c(i),tokenBridgeRedeemer:ze(o),toFeesTokenAccount:new c(i),tokenBridgeCustody:Me(e,a),mint:a,tokenBridgeCustodySigner:fe(e),rent:O,systemProgram:E.programId,tokenProgram:M,wormholeProgram:new c(t)}}function Fr(e,t,r,n,i){const a=re(e,y(n.payload.token.chain),n.payload.token.address.toUint8Array()),o=new c(n.payload.to.address.toUint8Array());return{payer:new c(r),tokenBridgeConfig:B(e),vaa:Z(t,l.Buffer.from(n.hash)),tokenBridgeClaim:H(e,n.emitterAddress.toUint8Array(),y(n.emitterChain),n.sequence),tokenBridgeForeignEndpoint:te(e,y(n.emitterChain),n.emitterAddress.toUint8Array()),toTokenAccount:new c(i),tokenBridgeRedeemer:ze(o),toFeesTokenAccount:new c(i),tokenBridgeWrappedMint:a,tokenBridgeWrappedMeta:Q(e,a),tokenBridgeMintAuthority:ke(e),rent:O,systemProgram:E.programId,tokenProgram:M,wormholeProgram:new c(t)}}const kr={version:"0.1.0",name:"token_bridge_relayer",constants:[{name:"SEED_PREFIX_BRIDGED",type:"bytes",value:"[98, 114, 105, 100, 103, 101, 100]"},{name:"SEED_PREFIX_TMP",type:"bytes",value:"[116, 109, 112]"},{name:"SWAP_RATE_PRECISION",type:"u32",value:"100_000_000"}],instructions:[{name:"initialize",docs:["This instruction is be used to generate your program's config.","And for convenience, we will store Wormhole-related PDAs in the","config so we can verify these accounts with a simple == constraint.","# Arguments","","* `ctx` - `Initialize` context","* `fee_recipient` - Recipient of all relayer fees and swap proceeds","* `assistant` - Privileged key to manage certain accounts"],accounts:[{name:"owner",isMut:!0,isSigner:!0,docs:["Deployer of the program."]},{name:"senderConfig",isMut:!0,isSigner:!1,docs:["Sender Config account, which saves program data useful for other","instructions, specifically for outbound transfers. Also saves the payer","of the [`initialize`](crate::initialize) instruction as the program's","owner."]},{name:"redeemerConfig",isMut:!0,isSigner:!1,docs:["Redeemer Config account, which saves program data useful for other","instructions, specifically for inbound transfers. Also saves the payer","of the [`initialize`](crate::initialize) instruction as the program's","owner."]},{name:"ownerConfig",isMut:!0,isSigner:!1,docs:["Owner config account, which saves the owner, assistant and","pending owner keys. This account is used to manage the ownership of the","program."]},{name:"tokenBridgeEmitter",isMut:!1,isSigner:!1,docs:["that holds data; it is purely just a signer for posting Wormhole","messages on behalf of the Token Bridge program."]},{name:"tokenBridgeSequence",isMut:!1,isSigner:!1,docs:["Token Bridge emitter's sequence account. Like with all Wormhole","emitters, this account keeps track of the sequence number of the last","posted message."]},{name:"systemProgram",isMut:!1,isSigner:!1,docs:["System program."]},{name:"programData",isMut:!0,isSigner:!1,docs:["upgrade authority. We check this PDA address just in case there is another program that this","deployer has deployed.","","NOTE: Set upgrade authority is scary because any public key can be used to set as the","authority."]},{name:"bpfLoaderUpgradeableProgram",isMut:!1,isSigner:!1}],args:[{name:"feeRecipient",type:"publicKey"},{name:"assistant",type:"publicKey"}]},{name:"registerForeignContract",docs:["This instruction registers a new foreign contract (from another","network) and saves the emitter information in a ForeignEmitter account.","This instruction is owner-only, meaning that only the owner of the","program (defined in the [Config] account) can add and update foreign","contracts.","","# Arguments","","* `ctx` - `RegisterForeignContract` context","* `chain` - Wormhole Chain ID","* `address` - Wormhole Emitter Address","* `relayer_fee` - Relayer fee scaled by the `relayer_fee_precision`"],accounts:[{name:"owner",isMut:!0,isSigner:!0,docs:["Owner of the program set in the [`SenderConfig`] account. Signer for","creating [`ForeignContract`] account."]},{name:"config",isMut:!1,isSigner:!1,docs:["Sender Config account. This program requires that the `owner` specified","in the context equals the pubkey specified in this account. Read-only."]},{name:"foreignContract",isMut:!0,isSigner:!1,docs:["Foreign Contract account. Create this account if an emitter has not been","registered yet for this Wormhole chain ID. If there already is a","contract address saved in this account, overwrite it."]},{name:"tokenBridgeForeignEndpoint",isMut:!1,isSigner:!1,docs:["Token Bridge foreign endpoint. This account should really be one","endpoint per chain, but Token Bridge's PDA allows for multiple","endpoints for each chain. We store the proper endpoint for the","emitter chain."]},{name:"tokenBridgeProgram",isMut:!1,isSigner:!1,docs:["Token Bridge program."]},{name:"systemProgram",isMut:!1,isSigner:!1,docs:["System program."]}],args:[{name:"chain",type:"u16"},{name:"address",type:{array:["u8",32]}},{name:"relayerFee",type:"u64"}]},{name:"registerToken",docs:["This instruction registers a new token and saves the initial `swap_rate`","and `max_native_token_amount` in a RegisteredToken account.","This instruction is owner-only, meaning that only the owner of the","program (defined in the [Config] account) can register a token.","","# Arguments","","* `ctx` - `RegisterToken` context","* `swap_rate`:","- USD conversion rate scaled by the `swap_rate_precision`. For example,","- if the conversion rate is $15 and the `swap_rate_precision` is","- 1000000, the `swap_rate` should be set to 15000000.","* `max_native_swap_amount`:","- Maximum amount of native tokens that can be swapped for this token","- on this chain."],accounts:[{name:"owner",isMut:!0,isSigner:!0,docs:["Owner of the program set in the [`SenderConfig`] account. Signer for","creating [`ForeignContract`] account."]},{name:"config",isMut:!1,isSigner:!1,docs:["Sender Config account. This program requires that the `owner` specified","in the context equals the pubkey specified in this account. Read-only."]},{name:"registeredToken",isMut:!0,isSigner:!1,docs:["Registered Token account. This account stores information about the","token, including the swap rate and max native swap amount. Create this","account if the mint has not been registered yet. Mutable."]},{name:"mint",isMut:!1,isSigner:!1,docs:["Mint info. This is the SPL token that will be bridged over to the","foreign contract."]},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1,docs:["System program."]}],args:[{name:"swapRate",type:"u64"},{name:"maxNativeSwapAmount",type:"u64"}]},{name:"deregisterToken",docs:["This instruction deregisters a token by closing the existing","`RegisteredToken` account for a particular mint. This instruction is","owner-only, meaning that only the owner of the program (defined in the","[Config] account) can deregister a token."],accounts:[{name:"owner",isMut:!1,isSigner:!0,docs:["Owner of the program set in the [`SenderConfig`] account. Signer for","closing [`RegisteredToken`] account."]},{name:"config",isMut:!1,isSigner:!1,docs:["Sender Config account. This program requires that the `owner` specified","in the context equals the pubkey specified in this account. Read-only."]},{name:"mint",isMut:!1,isSigner:!1,docs:["Mint info. This is the SPL token that will be bridged over to the","foreign contract."]},{name:"registeredToken",isMut:!0,isSigner:!1,docs:["Registered Token account. This account stores information about the","token, including the swap rate and max native swap amount. This account","also determines if a mint is registered or not."]}],args:[]},{name:"updateRelayerFee",docs:["This instruction updates the `relayer_fee` in the `ForeignContract` account.","The `relayer_fee` is scaled by the `relayer_fee_precision`. For example,","if the `relayer_fee` is $15 and the `relayer_fee_precision` is 1000000,","the `relayer_fee` should be set to 15000000. This instruction can","only be called by the owner or assistant, which are defined in the","[OwnerConfig] account.","","# Arguments","","* `ctx` - `UpdateRelayerFee` context","* `chain` - Wormhole Chain ID","* `fee` - Relayer fee scaled by the `relayer_fee_precision`"],accounts:[{name:"payer",isMut:!0,isSigner:!0,docs:["Signer of the transaction. Must be the owner or assistant."]},{name:"ownerConfig",isMut:!1,isSigner:!1,docs:["The owner_config is used when updating the swap rate","so that the assistant key can be used in addition to the","owner key."]},{name:"foreignContract",isMut:!0,isSigner:!1,docs:["This account holds the USD denominated relayer fee for the specified","`chain`. This account is used to determine the cost of relaying","a transfer to a target chain. If there already is a relayer fee","saved in this account, overwrite it."]},{name:"systemProgram",isMut:!1,isSigner:!1,docs:["System program."]}],args:[{name:"chain",type:"u16"},{name:"fee",type:"u64"}]},{name:"updateRelayerFeePrecision",docs:["This instruction updates the `relayer_fee_precision` in the","`SenderConfig` and `RedeemerConfig` accounts. The `relayer_fee_precision`","is used to scale the `relayer_fee`. This instruction is owner-only,","meaning that only the owner of the program (defined in the [Config]","account) can register a token.","","# Arguments","","* `ctx` - `UpdatePrecision` context","* `relayer_fee_precision` - Precision used to scale the relayer fee."],accounts:[{name:"owner",isMut:!1,isSigner:!0,docs:["Owner of the program set in the [`RedeemerConfig`] and [`SenderConfig`] account."]},{name:"redeemerConfig",isMut:!0,isSigner:!1,docs:["Redeemer Config account. This program requires that the `owner`","specified in the context equals the pubkey specified in this account.","Mutable."]},{name:"senderConfig",isMut:!0,isSigner:!1,docs:["Sender Config account. This program requires that the `owner`","specified in the context equals the pubkey specified in this account.","Mutable. The `owner` check is redundant here, but we keep it as an","extra protection for future changes to the context. Mutable."]}],args:[{name:"relayerFeePrecision",type:"u32"}]},{name:"updateSwapRate",docs:["This instruction updates the `swap_rate` in the `RegisteredToken`","account. This instruction can only be called by the owner or","assistant, which are defined in the [OwnerConfig] account.","","# Arguments","","* `ctx` - `UpdateSwapRate` context","* `swap_rate` - USD conversion rate for the specified token."],accounts:[{name:"owner",isMut:!1,isSigner:!0,docs:["The signer of the transaction. Must be the owner or assistant."]},{name:"ownerConfig",isMut:!1,isSigner:!1,docs:["The owner_config is used when updating the swap rate so that the","assistant key can be used in additional to the owner key."]},{name:"registeredToken",isMut:!0,isSigner:!1,docs:["Registered Token account. This account stores information about the","token, including the swap rate and max native swap amount. The program","will modify this account to update the swap rate. Mutable."]},{name:"mint",isMut:!1,isSigner:!1,docs:["Mint info. This is the SPL token that will be bridged over to the","foreign contract."]}],args:[{name:"swapRate",type:"u64"}]},{name:"updateMaxNativeSwapAmount",docs:["This instruction updates the `max_native_swap_amount` in the","`RegisteredToken` account. This instruction is owner-only,","meaning that only the owner of the program (defined in the [Config]","account) can register a token.","","# Arguments","","* `ctx` - `UpdateMaxNativeSwapAmount` context","* `max_native_swap_amount`:","- Maximum amount of native tokens that can be swapped for this token","- on this chain."],accounts:[{name:"owner",isMut:!1,isSigner:!0,docs:["Owner of the program set in the [`SenderConfig`] account. Signer for","creating [`ForeignContract`] account."]},{name:"config",isMut:!1,isSigner:!1,docs:["Sender Config account. This program requires that the `owner` specified","in the context equals the pubkey specified in this account. Read-only."]},{name:"registeredToken",isMut:!0,isSigner:!1,docs:["Registered Token account. This account stores information about the","token, including the swap rate and max native swap amount. The program","will modify this account when the swap rate or max native swap amount","changes. Mutable."]},{name:"mint",isMut:!1,isSigner:!1,docs:["Mint info. This is the SPL token that will be bridged over to the","foreign contract."]}],args:[{name:"maxNativeSwapAmount",type:"u64"}]},{name:"setPauseForTransfers",docs:["This instruction updates the `paused` boolean in the `SenderConfig`","account. This instruction is owner-only, meaning that only the owner","of the program (defined in the [Config] account) can pause outbound","transfers.","","# Arguments","","* `ctx` - `PauseOutboundTransfers` context","* `paused` - Boolean indicating whether outbound transfers are paused."],accounts:[{name:"owner",isMut:!1,isSigner:!0,docs:["Owner of the program set in the [`SenderConfig`] account."]},{name:"config",isMut:!0,isSigner:!1,docs:["Sender Config account. This program requires that the `owner` specified","in the context equals the pubkey specified in this account. Mutable."]}],args:[{name:"paused",type:"bool"}]},{name:"submitOwnershipTransferRequest",docs:["This instruction sets the `pending_owner` field in the `OwnerConfig`","account. This instruction is owner-only, meaning that only the owner","of the program (defined in the [Config] account) can submit an","ownership transfer request.","","# Arguments","","* `ctx` - `ManageOwnership` context","* `new_owner` - Pubkey of the pending owner."],accounts:[{name:"owner",isMut:!1,isSigner:!0,docs:["Owner of the program set in the [`OwnerConfig`] account."]},{name:"ownerConfig",isMut:!0,isSigner:!1,docs:["Owner Config account. This program requires that the `owner` specified","in the context equals the pubkey specified in this account. Mutable."]}],args:[{name:"newOwner",type:"publicKey"}]},{name:"confirmOwnershipTransferRequest",docs:["This instruction confirms that the `pending_owner` is the signer of","the transaction and updates the `owner` field in the `SenderConfig`,","`RedeemerConfig`, and `OwnerConfig` accounts."],accounts:[{name:"pendingOwner",isMut:!1,isSigner:!0,docs:["Must be the pending owner of the program set in the [`OwnerConfig`]","account."]},{name:"ownerConfig",isMut:!0,isSigner:!1,docs:["Owner Config account. This program requires that the `pending_owner`","specified in the context equals the pubkey specified in this account."]},{name:"senderConfig",isMut:!0,isSigner:!1,docs:["Sender Config account. This instruction will update the `owner`","specified in this account to the `pending_owner` specified in the","[`OwnerConfig`] account. Mutable."]},{name:"redeemerConfig",isMut:!0,isSigner:!1,docs:["Redeemer Config account. This instruction will update the `owner`","specified in this account to the `pending_owner` specified in the","[`OwnerConfig`] account. Mutable."]}],args:[]},{name:"cancelOwnershipTransferRequest",docs:["This instruction cancels the ownership transfer request by setting","the `pending_owner` field in the `OwnerConfig` account to `None`.","This instruction is owner-only, meaning that only the owner of the","program (defined in the [Config] account) can cancel an ownership","transfer request."],accounts:[{name:"owner",isMut:!1,isSigner:!0,docs:["Owner of the program set in the [`OwnerConfig`] account."]},{name:"ownerConfig",isMut:!0,isSigner:!1,docs:["Owner Config account. This program requires that the `owner` specified","in the context equals the pubkey specified in this account. Mutable."]}],args:[]},{name:"updateAssistant",docs:["This instruction updates the `assistant` field in the `OwnerConfig`","account. This instruction is owner-only, meaning that only the owner","of the program (defined in the [Config] account) can update the","assistant.","","# Arguments","","* `ctx` - `ManageOwnership` context","* `new_assistant` - Pubkey of the new assistant."],accounts:[{name:"owner",isMut:!1,isSigner:!0,docs:["Owner of the program set in the [`OwnerConfig`] account."]},{name:"ownerConfig",isMut:!0,isSigner:!1,docs:["Owner Config account. This program requires that the `owner` specified","in the context equals the pubkey specified in this account. Mutable."]}],args:[{name:"newAssistant",type:"publicKey"}]},{name:"updateFeeRecipient",docs:["This instruction updates the `fee_recipient` field in the `RedeemerConfig`","account. This instruction is owner-only, meaning that only the owner","of the program (defined in the [Config] account) can update the","fee recipient.","","# Arguments","","* `ctx` - `UpdateFeeRecipient` context","* `new_fee_recipient` - Pubkey of the new fee recipient."],accounts:[{name:"owner",isMut:!1,isSigner:!0,docs:["Owner of the program set in the [`RedeemerConfig`] account."]},{name:"redeemerConfig",isMut:!0,isSigner:!1,docs:["Redeemer Config account, which saves program data useful for other","instructions, specifically for inbound transfers. Also saves the payer","of the [`initialize`](crate::initialize) instruction as the program's","owner."]}],args:[{name:"newFeeRecipient",type:"publicKey"}]},{name:"transferNativeTokensWithRelay",docs:["This instruction is used to transfer native tokens from Solana to a","foreign blockchain. The user can optionally specify a","`to_native_token_amount` to swap some of the tokens for the native","asset on the target chain. For a fee, an off-chain relayer will redeem","the transfer on the target chain. If the user is transferring native","SOL, the contract will automatically wrap the lamports into a WSOL.","","# Arguments","","* `ctx` - `TransferNativeWithRelay` context","* `amount` - Amount of tokens to send","* `to_native_token_amount`:","- Amount of tokens to swap for native assets on the target chain","* `recipient_chain` - Chain ID of the target chain","* `recipient_address` - Address of the target wallet on the target chain","* `batch_id` - Nonce of Wormhole message","* `wrap_native` - Whether to wrap native SOL"],accounts:[{name:"payer",isMut:!0,isSigner:!0,docs:["Payer will pay Wormhole fee to transfer tokens and create temporary","token account."]},{name:"payerSequence",isMut:!0,isSigner:!1,docs:["Used to keep track of payer's Wormhole sequence number."]},{name:"config",isMut:!1,isSigner:!1,docs:["Sender Config account. Acts as the signer for the Token Bridge token","transfer. Read-only."]},{name:"foreignContract",isMut:!1,isSigner:!1,docs:["Foreign Contract account. Send tokens to the contract specified in this","account. Funnily enough, the Token Bridge program does not have any","requirements for outbound transfers for the recipient chain to be","registered. This account provides extra protection against sending","tokens to an unregistered Wormhole chain ID. Read-only."]},{name:"mint",isMut:!0,isSigner:!1,docs:["Mint info. This is the SPL token that will be bridged over to the","foreign contract. Mutable."]},{name:"fromTokenAccount",isMut:!0,isSigner:!1,docs:["Payer's associated token account. We may want to make this a generic","token account in the future."]},{name:"registeredToken",isMut:!1,isSigner:!1},{name:"tmpTokenAccount",isMut:!0,isSigner:!1,docs:["Program's temporary token account. This account is created before the","instruction is invoked to temporarily take custody of the payer's","tokens. When the tokens are finally bridged out, the token account","will have zero balance and can be closed."]},{name:"tokenBridgeConfig",isMut:!1,isSigner:!1},{name:"tokenBridgeCustody",isMut:!0,isSigner:!1,docs:["account that holds this mint's balance. This account needs to be","unchecked because a token account may not have been created for this","mint yet. Mutable."]},{name:"tokenBridgeAuthoritySigner",isMut:!1,isSigner:!1},{name:"tokenBridgeCustodySigner",isMut:!1,isSigner:!1},{name:"wormholeBridge",isMut:!0,isSigner:!1},{name:"wormholeMessage",isMut:!0,isSigner:!1,docs:["tokens transferred in this account for our program. Mutable."]},{name:"tokenBridgeEmitter",isMut:!1,isSigner:!1},{name:"tokenBridgeSequence",isMut:!0,isSigner:!1},{name:"wormholeFeeCollector",isMut:!0,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1},{name:"tokenBridgeProgram",isMut:!1,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1}],args:[{name:"amount",type:"u64"},{name:"toNativeTokenAmount",type:"u64"},{name:"recipientChain",type:"u16"},{name:"recipientAddress",type:{array:["u8",32]}},{name:"batchId",type:"u32"},{name:"wrapNative",type:"bool"}]},{name:"transferWrappedTokensWithRelay",docs:["This instruction is used to transfer wrapped tokens from Solana to a","foreign blockchain. The user can optionally specify a","`to_native_token_amount` to swap some of the tokens for the native","assets on the target chain. For a fee, an off-chain relayer will redeem","the transfer on the target chain. This instruction should only be called","when the user is transferring a wrapped token.","","# Arguments","","* `ctx` - `TransferWrappedWithRelay` context","* `amount` - Amount of tokens to send","* `to_native_token_amount`:","- Amount of tokens to swap for native assets on the target chain","* `recipient_chain` - Chain ID of the target chain","* `recipient_address` - Address of the target wallet on the target chain","* `batch_id` - Nonce of Wormhole message"],accounts:[{name:"payer",isMut:!0,isSigner:!0,docs:["Payer will pay Wormhole fee to transfer tokens."]},{name:"payerSequence",isMut:!0,isSigner:!1,docs:["Used to keep track of payer's Wormhole sequence number."]},{name:"config",isMut:!1,isSigner:!1,docs:["Sender Config account. Acts as the Token Bridge sender PDA. Mutable."]},{name:"foreignContract",isMut:!1,isSigner:!1,docs:["Foreign Contract account. Send tokens to the contract specified in this","account. Funnily enough, the Token Bridge program does not have any","requirements for outbound transfers for the recipient chain to be","registered. This account provides extra protection against sending","tokens to an unregistered Wormhole chain ID. Read-only."]},{name:"tokenBridgeWrappedMint",isMut:!0,isSigner:!1,docs:["Token Bridge wrapped mint info. This is the SPL token that will be","bridged to the foreign contract. The wrapped mint PDA must agree","with the native token's metadata. Mutable."]},{name:"fromTokenAccount",isMut:!0,isSigner:!1,docs:["Payer's associated token account. We may want to make this a generic","token account in the future."]},{name:"registeredToken",isMut:!1,isSigner:!1},{name:"tmpTokenAccount",isMut:!0,isSigner:!1,docs:["Program's temporary token account. This account is created before the","instruction is invoked to temporarily take custody of the payer's","tokens. When the tokens are finally bridged out, the token account","will have zero balance and can be closed."]},{name:"tokenBridgeWrappedMeta",isMut:!1,isSigner:!1,docs:["about the token from its native chain:","* Wormhole Chain ID","* Token's native contract address","* Token's native decimals"]},{name:"tokenBridgeConfig",isMut:!1,isSigner:!1},{name:"tokenBridgeAuthoritySigner",isMut:!1,isSigner:!1},{name:"wormholeBridge",isMut:!0,isSigner:!1},{name:"wormholeMessage",isMut:!0,isSigner:!1,docs:["tokens transferred in this account."]},{name:"tokenBridgeEmitter",isMut:!1,isSigner:!1},{name:"tokenBridgeSequence",isMut:!0,isSigner:!1},{name:"wormholeFeeCollector",isMut:!0,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1},{name:"tokenBridgeProgram",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1}],args:[{name:"amount",type:"u64"},{name:"toNativeTokenAmount",type:"u64"},{name:"recipientChain",type:"u16"},{name:"recipientAddress",type:{array:["u8",32]}},{name:"batchId",type:"u32"}]},{name:"completeNativeTransferWithRelay",docs:["This instruction is used to redeem token transfers from foreign emitters.","It takes custody of the released native tokens and sends the tokens to the","encoded `recipient`. It pays the `fee_recipient` in the token","denomination. If requested by the user, it will perform a swap with the","off-chain relayer to provide the user with lamports. If the token","being transferred is WSOL, the contract will unwrap the WSOL and send","the lamports to the recipient and pay the relayer in lamports.","","# Arguments","","* `ctx` - `CompleteNativeWithRelay` context","* `vaa_hash` - Hash of the VAA that triggered the transfer"],accounts:[{name:"payer",isMut:!0,isSigner:!0,docs:["Payer will pay Wormhole fee to transfer tokens and create temporary","token account."]},{name:"config",isMut:!1,isSigner:!1,docs:["Redeemer Config account. Acts as the Token Bridge redeemer, which signs","for the complete transfer instruction. Read-only."]},{name:"feeRecipientTokenAccount",isMut:!0,isSigner:!1,docs:["Fee recipient's token account. Must be an associated token account. Mutable."]},{name:"foreignContract",isMut:!1,isSigner:!1,docs:["Foreign Contract account. The registered contract specified in this","account must agree with the target address for the Token Bridge's token","transfer. Read-only."]},{name:"mint",isMut:!1,isSigner:!1,docs:["Mint info. This is the SPL token that will be bridged over from the","foreign contract. This must match the token address specified in the","signed Wormhole message. Read-only."]},{name:"recipientTokenAccount",isMut:!0,isSigner:!1,docs:["Recipient associated token account. The recipient authority check","is necessary to ensure that the recipient is the intended recipient","of the bridged tokens. Mutable."]},{name:"recipient",isMut:!0,isSigner:!1,docs:["transaction. This instruction verifies that the recipient key","passed in this context matches the intended recipient in the vaa."]},{name:"registeredToken",isMut:!1,isSigner:!1},{name:"nativeRegisteredToken",isMut:!1,isSigner:!1},{name:"tmpTokenAccount",isMut:!0,isSigner:!1,docs:["Program's temporary token account. This account is created before the","instruction is invoked to temporarily take custody of the payer's","tokens. When the tokens are finally bridged in, the tokens will be","transferred to the destination token accounts. This account will have","zero balance and can be closed."]},{name:"tokenBridgeConfig",isMut:!1,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1,docs:["Verified Wormhole message account. The Wormhole program verified","signatures and posted the account data here. Read-only."]},{name:"tokenBridgeClaim",isMut:!0,isSigner:!1,docs:["is true if the bridged assets have been claimed. If the transfer has","not been redeemed, this account will not exist yet.","","NOTE: The Token Bridge program's claim account is only initialized when","a transfer is redeemed (and the boolean value `true` is written as","its data).","","The Token Bridge program will automatically fail if this transfer","is redeemed again. But we choose to short-circuit the failure as the","first evaluation of this instruction."]},{name:"tokenBridgeForeignEndpoint",isMut:!1,isSigner:!1,docs:["endpoint per chain, but the PDA allows for multiple endpoints for each","chain! We store the proper endpoint for the emitter chain."]},{name:"tokenBridgeCustody",isMut:!0,isSigner:!1,docs:["account that holds this mint's balance."]},{name:"tokenBridgeCustodySigner",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1},{name:"tokenBridgeProgram",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1}],args:[{name:"vaaHash",type:{array:["u8",32]}}]},{name:"completeWrappedTransferWithRelay",docs:["This instruction is used to redeem token transfers from foreign emitters.","It takes custody of the minted wrapped tokens and sends the tokens to the","encoded `recipient`. It pays the `fee_recipient` in the wrapped-token","denomination. If requested by the user, it will perform a swap with the","off-chain relayer to provide the user with lamports.","","# Arguments","","* `ctx` - `CompleteWrappedWithRelay` context","* `vaa_hash` - Hash of the VAA that triggered the transfer"],accounts:[{name:"payer",isMut:!0,isSigner:!0,docs:["Payer will pay Wormhole fee to transfer tokens and create temporary","token account."]},{name:"config",isMut:!1,isSigner:!1,docs:["Redeemer Config account. Acts as the Token Bridge redeemer, which signs","for the complete transfer instruction. Read-only."]},{name:"feeRecipientTokenAccount",isMut:!0,isSigner:!1,docs:["Fee recipient's token account. Must be an associated token account. Mutable."]},{name:"foreignContract",isMut:!1,isSigner:!1,docs:["Foreign Contract account. The registered contract specified in this","account must agree with the target address for the Token Bridge's token","transfer. Read-only."]},{name:"tokenBridgeWrappedMint",isMut:!0,isSigner:!1,docs:["Token Bridge wrapped mint info. This is the SPL token that will be","bridged from the foreign contract. The wrapped mint PDA must agree","with the native token's metadata in the wormhole message. Mutable."]},{name:"recipientTokenAccount",isMut:!0,isSigner:!1,docs:["Recipient associated token account. The recipient authority check","is necessary to ensure that the recipient is the intended recipient","of the bridged tokens. Mutable."]},{name:"recipient",isMut:!0,isSigner:!1,docs:["transaction. This instruction verifies that the recipient key","passed in this context matches the intended recipient in the vaa."]},{name:"registeredToken",isMut:!1,isSigner:!1},{name:"nativeRegisteredToken",isMut:!1,isSigner:!1},{name:"tmpTokenAccount",isMut:!0,isSigner:!1,docs:["Program's temporary token account. This account is created before the","instruction is invoked to temporarily take custody of the payer's","tokens. When the tokens are finally bridged in, the tokens will be","transferred to the destination token accounts. This account will have","zero balance and can be closed."]},{name:"tokenBridgeWrappedMeta",isMut:!1,isSigner:!1,docs:["about the token from its native chain:","* Wormhole Chain ID","* Token's native contract address","* Token's native decimals"]},{name:"tokenBridgeConfig",isMut:!1,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1,docs:["Verified Wormhole message account. The Wormhole program verified","signatures and posted the account data here. Read-only."]},{name:"tokenBridgeClaim",isMut:!0,isSigner:!1,docs:["is true if the bridged assets have been claimed. If the transfer has","not been redeemed, this account will not exist yet.","","NOTE: The Token Bridge program's claim account is only initialized when","a transfer is redeemed (and the boolean value `true` is written as","its data).","","The Token Bridge program will automatically fail if this transfer","is redeemed again. But we choose to short-circuit the failure as the","first evaluation of this instruction."]},{name:"tokenBridgeForeignEndpoint",isMut:!1,isSigner:!1,docs:["endpoint per chain, but the PDA allows for multiple endpoints for each","chain! We store the proper endpoint for the emitter chain."]},{name:"tokenBridgeMintAuthority",isMut:!1,isSigner:!1},{name:"wormholeProgram",isMut:!1,isSigner:!1},{name:"tokenBridgeProgram",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1}],args:[{name:"vaaHash",type:{array:["u8",32]}}]}],accounts:[{name:"foreignContract",docs:["Foreign emitter account data."],type:{kind:"struct",fields:[{name:"chain",docs:["Emitter chain. Cannot equal `1` (Solana's Chain ID)."],type:"u16"},{name:"address",docs:["Emitter address. Cannot be zero address."],type:{array:["u8",32]}},{name:"tokenBridgeForeignEndpoint",docs:["Token Bridge program's foreign endpoint account key."],type:"publicKey"},{name:"fee",docs:["The fee that is paid to the `fee_recipient` upon redeeming a transfer.","This value is set in terms of USD and scaled by the `relayer_fee_precision`.","For example, if the `relayer_fee_precision` is `100000000` and the intended","fee is $5, then the `fee` value should be `500000000`."],type:"u64"}]}},{name:"ownerConfig",docs:["Owner account data."],type:{kind:"struct",fields:[{name:"owner",docs:["Program's owner."],type:"publicKey"},{name:"assistant",docs:["Program's assistant. Can be used to update the relayer fee and swap rate."],type:"publicKey"},{name:"pendingOwner",docs:["Intermediate storage for the pending owner. Is used to transfer ownership."],type:{option:"publicKey"}}]}},{name:"redeemerConfig",type:{kind:"struct",fields:[{name:"owner",docs:["Program's owner."],type:"publicKey"},{name:"bump",docs:["PDA bump."],type:"u8"},{name:"relayerFeePrecision",docs:["Relayer fee and swap rate precision."],type:"u32"},{name:"feeRecipient",docs:["Recipient of all relayer fees and swap proceeds."],type:"publicKey"}]}},{name:"registeredToken",docs:["Registered token account data."],type:{kind:"struct",fields:[{name:"swapRate",docs:["Token swap rate. The swap rate is the USD conversion rate of the token."],type:"u64"},{name:"maxNativeSwapAmount",docs:["Maximum amount of native SOL the contract will swap for each transfer."],type:"u64"}]}},{name:"senderConfig",type:{kind:"struct",fields:[{name:"owner",docs:["Program's owner."],type:"publicKey"},{name:"bump",docs:["PDA bump."],type:"u8"},{name:"tokenBridge",docs:["Token Bridge program's relevant addresses."],type:{defined:"OutboundTokenBridgeAddresses"}},{name:"relayerFeePrecision",docs:["Relayer fee and swap rate precision."],type:"u32"},{name:"paused",docs:["Boolean indicating whether outbound transfers are paused."],type:"bool"}]}},{name:"signerSequence",type:{kind:"struct",fields:[{name:"value",type:"u64"}]}}],types:[{name:"OutboundTokenBridgeAddresses",type:{kind:"struct",fields:[{name:"sequence",type:"publicKey"}]}},{name:"TokenBridgeRelayerMessage",docs:["Expected message types for this program. Only valid payloads are:","* `TransferWithRelay`: Payload ID == 1.","","Payload IDs are encoded as u8."],type:{kind:"enum",variants:[{name:"TransferWithRelay",fields:[{name:"target_relayer_fee",type:"u64"},{name:"to_native_token_amount",type:"u64"},{name:"recipient",type:{array:["u8",32]}}]}]}}],errors:[{code:6e3,name:"InvalidWormholeBridge",msg:"InvalidWormholeBridge"},{code:6001,name:"InvalidWormholeFeeCollector",msg:"InvalidWormholeFeeCollector"},{code:6002,name:"OwnerOnly",msg:"OwnerOnly"},{code:6003,name:"OutboundTransfersPaused",msg:"OutboundTransfersPaused"},{code:6004,name:"OwnerOrAssistantOnly",msg:"OwnerOrAssistantOnly"},{code:6005,name:"NotPendingOwner",msg:"NotPendingOwner"},{code:6006,name:"AlreadyTheOwner",msg:"AlreadyTheOwner"},{code:6007,name:"AlreadyTheAssistant",msg:"AlreadyTheAssistant"},{code:6008,name:"AlreadyTheFeeRecipient",msg:"AlreadyTheFeeRecipient"},{code:6009,name:"BumpNotFound",msg:"BumpNotFound"},{code:6010,name:"FailedToMakeImmutable",msg:"FailedToMakeImmutable"},{code:6011,name:"InvalidForeignContract",msg:"InvalidForeignContract"},{code:6012,name:"ZeroBridgeAmount",msg:"ZeroBridgeAmount"},{code:6013,name:"InvalidToNativeAmount",msg:"InvalidToNativeAmount"},{code:6014,name:"NativeMintRequired",msg:"NativeMintRequired"},{code:6015,name:"SwapsNotAllowedForNativeMint",msg:"SwapsNotAllowedForNativeMint"},{code:6016,name:"InvalidTokenBridgeConfig",msg:"InvalidTokenBridgeConfig"},{code:6017,name:"InvalidTokenBridgeAuthoritySigner",msg:"InvalidTokenBridgeAuthoritySigner"},{code:6018,name:"InvalidTokenBridgeCustodySigner",msg:"InvalidTokenBridgeCustodySigner"},{code:6019,name:"InvalidTokenBridgeEmitter",msg:"InvalidTokenBridgeEmitter"},{code:6020,name:"InvalidTokenBridgeSequence",msg:"InvalidTokenBridgeSequence"},{code:6021,name:"InvalidRecipient",msg:"InvalidRecipient"},{code:6022,name:"InvalidTransferToChain",msg:"InvalidTransferToChain"},{code:6023,name:"InvalidTransferTokenChain",msg:"InvalidTransferTokenChain"},{code:6024,name:"InvalidPrecision",msg:"InvalidPrecision"},{code:6025,name:"InvalidTransferToAddress",msg:"InvalidTransferToAddress"},{code:6026,name:"AlreadyRedeemed",msg:"AlreadyRedeemed"},{code:6027,name:"InvalidTokenBridgeForeignEndpoint",msg:"InvalidTokenBridgeForeignEndpoint"},{code:6028,name:"InvalidTokenBridgeMintAuthority",msg:"InvalidTokenBridgeMintAuthority"},{code:6029,name:"InvalidPublicKey",msg:"InvalidPublicKey"},{code:6030,name:"ZeroSwapRate",msg:"ZeroSwapRate"},{code:6031,name:"TokenNotRegistered",msg:"TokenNotRegistered"},{code:6032,name:"ChainNotRegistered",msg:"ChainNotRegistered"},{code:6033,name:"TokenAlreadyRegistered",msg:"TokenAlreadyRegistered"},{code:6034,name:"FeeCalculationError",msg:"TokenFeeCalculationError"},{code:6035,name:"InvalidSwapCalculation",msg:"InvalidSwapCalculation"},{code:6036,name:"InsufficientFunds",msg:"InsufficientFunds"}]};function De(e,t){return new lt(kr,new c(e),{connection:t})}function Et(e,t){return T([l.Buffer.from("seq"),new c(t).toBuffer()],e)}async function br(e,t,r,n,i,a,o,s,d,u,m,h){const{methods:{transferNativeTokensWithRelay:g},account:{signerSequence:w}}=De(t,e),p=Et(t,r),C=await w.fetch(p).then(({value:x})=>x).catch(x=>{var q;if((q=x.message)!=null&&q.includes("Account does not exist"))return new v(0);throw x}),R=bt(t,r,C),F=We(new c(a),new c(r)),I=kt(t,a),ie=Ar(t,n,i,r,R,F,a);return g(new v(o.toString()),new v(s.toString()),y(u),[...d],m,h).accounts({config:Mt(t),payerSequence:p,foreignContract:Ie(t,u),registeredToken:Ue(t,a),tmpTokenAccount:I,tokenBridgeProgram:new c(n),...ie}).instruction()}async function Tr(e,t,r,n,i,a,o,s,d,u,m){const{methods:{transferWrappedTokensWithRelay:h},account:{signerSequence:g}}=De(t,e),w=Et(t,r),p=await g.fetch(w).then(({value:q})=>q).catch(q=>{var Ve;if((Ve=q.message)!=null&&Ve.includes("Account does not exist"))return new v(0);throw q}),C=bt(t,r,p),R=We(new c(a),new c(r)),{chain:F,tokenAddress:I}=await me(e,n,a),ie=kt(t,a),x=Mr(t,n,i,r,C,R,F,I);return h(new v(o.toString()),new v(s.toString()),y(u),[...d],m).accounts({config:Mt(t),payerSequence:w,foreignContract:Ie(t,u),registeredToken:Ue(t,new c(a)),tmpTokenAccount:ie,tokenBridgeProgram:new c(n),...x}).instruction()}class qe{constructor(t,r,n,i){f(this,"network");f(this,"chain");f(this,"connection");f(this,"contracts");f(this,"chainId");f(this,"coreBridge");f(this,"tokenBridge");this.network=t,this.chain=r,this.connection=n,this.contracts=i,this.chainId=y(r);const a=i.tokenBridge;if(!a)throw new Error(`TokenBridge contract Address for chain ${r} not found`);this.tokenBridge=W(a,n),this.coreBridge=new Ht(t,r,n,i)}static async fromRpc(t,r){const[n,i]=await oe.chainFromRpc(t),a=r[i];if(a.network!==n)throw new Error(`Network mismatch for chain ${i}: ${a.network} != ${n}`);return new qe(n,i,t,a.contracts)}async isWrappedAsset(t){return me(this.connection,this.tokenBridge.programId,new k(t).toUint8Array()).catch(r=>null).then(r=>r!=null)}async getOriginalAsset(t){if(!await this.isWrappedAsset(t))throw Ce(t.toString());const r=new k(t).toUint8Array(),n=new c(r);try{const i=await me(this.connection,this.tokenBridge.programId,r);return i===null?{chain:this.chain,address:new k(n.toBytes()).toUniversalAddress()}:{chain:Zt(i.chain),address:new dt(new Uint8Array(i.tokenAddress))}}catch{throw Ce(t.toString())}}async getTokenUniversalAddress(t){return new k(t).toUniversalAddress()}async getTokenNativeAddress(t,r){return new k(r).toNative()}async hasWrappedAsset(t){try{return await this.getWrappedAsset(t),!0}catch{}return!1}async getWrappedAsset(t){if(j(t.address))throw new Error("Native cannot be a wrapped asset");const r=re(this.tokenBridge.programId,y(t.chain),t.address.toUniversalAddress().toUint8Array());try{return await me(this.connection,this.tokenBridge.programId,r),Be(this.chain,r.toBase58())}catch{}throw Ce(`${r}: ${t.address.toUniversalAddress().toString()}`)}async isTransferCompleted(t){return Qt(this.connection,this.tokenBridge.programId,t.emitterAddress.toUint8Array(),y(t.emitterChain),t.sequence,this.connection.commitment).catch(()=>!1)}async getWrappedNative(){return Be(this.chain,D.toBase58())}async*createAttestation(t,r){if(!r)throw new Error("Payer required to create attestation");const n=new k(r).unwrap(),i=0,a=await this.coreBridge.getMessageFee(),o=Yt(this.coreBridge.coreBridge.programId,n,a),s=ae.generate(),d=or(this.connection,this.tokenBridge.programId,this.coreBridge.address,n,new k(t).unwrap(),s.publicKey,i),u=new L().add(o,d);u.feePayer=n,yield this.createUnsignedTx({transaction:u,signers:[s]},"Solana.AttestToken")}async*submitAttestation(t,r){if(!r)throw new Error("Payer required to create attestation");const n=new k(r).unwrap();yield*this.coreBridge.postVaa(n,t);const i=new L().add(lr(this.connection,this.tokenBridge.programId,this.coreBridge.address,n,t));i.feePayer=n,yield this.createUnsignedTx({transaction:i},"Solana.CreateWrapped")}async transferSol(t,r,n,i){const a=new k(t).unwrap(),o=a,s=r.address.toUniversalAddress().toUint8Array(),d=y(r.chain),u=0,m=0n,h=ae.generate(),g=ae.generate(),w=await Je(this.connection),p=E.createAccount({fromPubkey:o,newAccountPubkey:g.publicKey,lamports:w,space:_,programId:M}),C=E.transfer({fromPubkey:o,lamports:n,toPubkey:g.publicKey}),R=nt(g.publicKey,D,o),F=it(this.tokenBridge.programId,g.publicKey,o,n),I=i?ut(this.connection,this.tokenBridge.programId,this.coreBridge.address,a,h.publicKey,g.publicKey,D,u,n,s,d,i):ct(this.connection,this.tokenBridge.programId,this.coreBridge.address,a,h.publicKey,g.publicKey,D,u,n,m,s,d),ie=Ye(g.publicKey,o,o),x=new L;return x.feePayer=o,x.add(p,C,R,F,I,ie),this.createUnsignedTx({transaction:x,signers:[h,g]},"TokenBridge.TransferNative")}async*transfer(t,r,n,i,a){if(j(n)){yield await this.transferSol(t,r,i,a);return}const o=new k(n).unwrap(),s=new k(t).unwrap(),d=await Xe(o,s),u=r.address.toUniversalAddress().toUint8Array(),m=y(r.chain),h=0,g=0n,w=!await this.isWrappedAsset(n),p=ae.generate();let C;if(w)C=a?ut(this.connection,this.tokenBridge.programId,this.coreBridge.address,s,p.publicKey,d,o,h,i,u,m,a):ct(this.connection,this.tokenBridge.programId,this.coreBridge.address,s,p.publicKey,d,o,h,i,g,u,m);else{const I=await this.getOriginalAsset(n);if(j(I.address))throw new Error("Native cannot be an original asset");C=a?Sr(this.connection,this.tokenBridge.programId,this.coreBridge.address,s,p.publicKey,d,s,y(I.chain),I.address.toUint8Array(),h,i,u,m,a):wr(this.connection,this.tokenBridge.programId,this.coreBridge.address,s,p.publicKey,d,s,y(I.chain),I.address.toUint8Array(),h,i,g,u,m)}const R=it(this.tokenBridge.programId,d,s,i),F=new L().add(R,C);F.feePayer=s,yield this.createUnsignedTx({transaction:F,signers:[p]},"TokenBridge.TransferTokens")}async*redeemAndUnwrap(t,r){const n=new k(t).unwrap(),i=new k(r.payload.to.address).unwrap(),a=await an(this.connection,D).then(p=>r.payload.token.amount*BigInt(Math.pow(10,p.decimals-8))),o=await Je(this.connection),s=ae.generate(),d=ot(this.connection,this.tokenBridge.programId,this.coreBridge.address,n,r),u=E.createAccount({fromPubkey:n,newAccountPubkey:s.publicKey,lamports:o,space:_,programId:M}),m=nt(s.publicKey,D,n),h=Ln(i,s.publicKey,n,a.valueOf()),g=Ye(s.publicKey,n,n),w=new L;w.feePayer=n,w.add(d,u,m,h,g),yield this.createUnsignedTx({transaction:w,signers:[s]},"TokenBridge.RedeemAndUnwrap")}async*createAta(t,r){const n=new k(t).unwrap(),i=new k(r).unwrap(),a=await Xe(i,n);if(await this.connection.getAccountInfo(a)===null){const s=new L().add(At(n,a,n,i));s.feePayer=n,yield this.createUnsignedTx({transaction:s},"Redeem.CreateATA")}}async*redeem(t,r,n=!0){const i=r.payload.token.chain===this.chain?r.payload.token.address:(await this.getWrappedAsset(r.payload.token)).toUniversalAddress();if(yield*this.createAta(t,i),yield*this.coreBridge.postVaa(t,r),n){const d=new k(await this.getWrappedNative());if(Jt.equals(i.toUint8Array(),d.toUint8Array())){yield*this.redeemAndUnwrap(t,r);return}}const a=new k(t).unwrap(),o=r.payload.token.chain==this.chain?ot:ur,s=new L().add(o(this.connection,this.tokenBridge.programId,this.coreBridge.address,a,r));s.feePayer=a,yield this.createUnsignedTx({transaction:s},"Solana.RedeemTransfer")}createUnsignedTx(t,r,n=!1){return new ft(t,this.network,this.chain,r,n)}}const Cr={Testnet:["7VPWjBhCXrpYYBiRKZh1ubh9tLZZNkZGp2ReRphEV4Mc","3WK3mEDNPrNuQReBvM28NcsqrExMnPxD9pPJmgrUeKKH","BaGfF51MQ3a61papTRDYaNefBgTQ9ywnVne5fCff4bxT","ACbmcQxbbhiXWM1GmapUSMmBYKMvnFLfAAXKqdo8xKwo","GQtMXZxnuacCFTXVeTvyHi6P9F6chbtzhVc8JgD8hv7c","3Ftc5hTz9sG4huk79onufGiebJNDMZNL8HYgdMJ9E7JR","DMw2tLaq1bVoAEKtkoUtieSk9bfCPUvubYLatTMsSVop","84F2QX9278ToDmA98u4A86xSV9hz1ovazr8zwGaX6qjS","So11111111111111111111111111111111111111112","8987WGkYa5viiZ9DD8sS3PB5XghKmWjkEgmzvwDuoAEc","BJZ72CjPQojVoH68mzrd4VQ4nr6KuhbAGnhZEZCujKxY"],Mainnet:["7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs","A9mUU4qviSctJVPJdBJWkb28deg915LYJKrzQ19ji3FM","Dn4noZ5jgGfkntzcQSUZ8czkreiZ1ForXYoV2H8Dm7S1","3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh","9gP2kCy3wA1ctvYWQk75guqXuHfrEomqydHLtcTCqiLa","Gz7VkD4MacbEB6yC5XD3HcumEiYx2EtDYYrfikGsvopG","KgV1GvrHQmRBY8sHQQeUKwTm2r2h8t4C8qt12Cw1HVE","DRQBDBEWmwWGK13fRTLhSPzjbvMSUavhV6nW4RUH8W6T","9kvAcwQbqejuJMd59mKuw2bfSsLRaQ7zuvaTVHEeBBec","7ixSaXGsHAFy34wogPk2YXiUX3BMmQMFdercdaHLnBby","G1vJEgzepqhnVu35BN4jrkv3wVwkujYWFFCxhbEZ1CZr","So11111111111111111111111111111111111111112"],Devnet:[]},J=9,se=new v(10),X=new v(1e8);class Ke{constructor(t,r,n,i){f(this,"network");f(this,"chain");f(this,"connection");f(this,"contracts");f(this,"chainId");f(this,"coreBridgeProgramId");f(this,"tokenBridgeProgramId");f(this,"tokenBridgeRelayer");this.network=t,this.chain=r,this.connection=n,this.contracts=i,this.chainId=y(r);const a=i.tokenBridgeRelayer;if(!a)throw new Error(`TokenBridge contract Address for chain ${r} not found`);this.tokenBridgeRelayer=De(a,n),this.tokenBridgeProgramId=new c(i.tokenBridge),this.coreBridgeProgramId=new c(i.coreBridge)}static async fromRpc(t,r){const[n,i]=await oe.chainFromRpc(t),a=r[i];if(a.network!==n)throw new Error(`Network mismatch for chain ${i}: ${a.network} != ${n}`);return new Ke(n,i,t,a.contracts)}async*transfer(t,r,n,i,a){const s=new k(t).unwrap(),d=r.address.toUniversalAddress().toUint8Array(),u=this.mintAddress(n),m=new L;if(j(n)){const p=We(u,s);try{await tn(this.connection,p)}catch(C){if(C instanceof Re){const R=At(s,p,s,u);m.add(R)}else throw C}}const h=a||0n,g=j(n),w=g?await br(this.connection,this.tokenBridgeRelayer.programId,s,this.tokenBridgeProgramId,this.coreBridgeProgramId,u,i,h,d,r.chain,0,g):await Tr(this.connection,this.tokenBridgeRelayer.programId,s,this.tokenBridgeProgramId,this.coreBridgeProgramId,u,i,h,d,r.chain,0);m.add(w),m.feePayer=s,yield this.createUnsignedTx({transaction:m},"AutomaticTokenBridge.Transfer")}async*redeem(t,r){const n=new L;throw yield this.createUnsignedTx({transaction:n},"AutomaticTokenBridge.Redeem"),new Error("Method not implemented.")}async getRelayerFee(t,r){const n=this.mintAddress(r),[{fee:i},{swapRate:a},{relayerFeePrecision:o}]=await Promise.all([this.getForeignContract(t),this.getRegisteredToken(n),this.getRedeemerConfig()]),s=Number(await oe.getDecimals(this.chain,this.connection,r)),d=se.pow(new v(s)).mul(i).mul(X).div(new v(o).mul(a));return BigInt(d.toString())}async maxSwapAmount(t){const r=this.mintAddress(t),[{swapRate:n,maxNativeSwapAmount:i},{swapRate:a}]=await Promise.all([this.getRegisteredToken(r),this.getRegisteredToken(D)]),o=Number(await oe.getDecimals(this.chain,this.connection,t)),s=this.calculateNativeSwapRate(a,n),d=o>J?i.mul(s).mul(se.pow(new v(o-J))).div(X):i.mul(s).div(se.pow(new v(J-o)).mul(X));return BigInt(d.toString())}async nativeTokenAmount(t,r){if(r===0n)return 0n;const n=this.mintAddress(t),i=Number(await oe.getDecimals(this.chain,this.connection,t)),[{swapRate:a},{swapRate:o}]=await Promise.all([this.getRegisteredToken(n),this.getRegisteredToken(D)]),s=this.calculateNativeSwapRate(o,a),d=i>J?X.mul(new v(r.toString())).div(s.mul(se.pow(new v(i-J)))):X.mul(new v(r.toString())).mul(se.pow(new v(J-i))).div(s);return BigInt(d.toString())}async isRegisteredToken(t){var n;const r=this.mintAddress(t);try{return await this.getRegisteredToken(r),!0}catch(i){if((n=i.message)!=null&&n.includes("Account does not exist"))return!1;throw i}}mintAddress(t){return j(t)?new c(D):new k(t).unwrap()}async getRegisteredTokens(){return Cr[this.network].map(t=>Be(this.chain,t))}calculateNativeSwapRate(t,r){return X.mul(t).div(r)}async getForeignContract(t){return await this.tokenBridgeRelayer.account.foreignContract.fetch(Ie(this.tokenBridgeRelayer.programId,t))}async getRegisteredToken(t){return await this.tokenBridgeRelayer.account.registeredToken.fetch(Ue(this.tokenBridgeRelayer.programId,t))}async getRedeemerConfig(){return await this.tokenBridgeRelayer.account.redeemerConfig.fetch(Dn(this.tokenBridgeRelayer.programId))}createUnsignedTx(t,r,n=!1){return new ft(t,this.network,this.chain,r,n)}}mt(gt,"TokenBridge",qe);mt(gt,"AutomaticTokenBridge",Ke);export{pe as CreateMetadataAccountArgs,K as Creator,be as Data,Fe as EndpointRegistration,at as Key,Le as Metadata,Ke as SolanaAutomaticTokenBridge,qe as SolanaTokenBridge,de as SplTokenMetadataProgram,vt as TOKEN_BRIDGE_IDL,kr as TOKEN_BRIDGE_RELAYER_IDL,Ne as TokenBridgeConfig,Oe as WrappedMeta,sr as coder,it as createApproveAuthoritySignerInstruction,or as createAttestTokenInstruction,ot as createCompleteTransferNativeInstruction,ur as createCompleteTransferWrappedInstruction,lr as createCreateWrappedInstruction,_r as createInitializeInstruction,W as createReadOnlyTokenBridgeProgramInterface,Wr as createRegisterChainInstruction,ar as createTokenBridgeProgramInterface,De as createTokenBridgeRelayerProgramInterface,ct as createTransferNativeInstruction,br as createTransferNativeTokensWithRelayInstruction,ut as createTransferNativeWithPayloadInstruction,wr as createTransferWrappedInstruction,Tr as createTransferWrappedTokensWithRelayInstruction,Sr as createTransferWrappedWithPayloadInstruction,Ir as createUpgradeContractInstruction,ne as deriveAuthoritySignerKey,Me as deriveCustodyKey,fe as deriveCustodySignerKey,te as deriveEndpointKey,Ie as deriveForeignContractAddress,ke as deriveMintAuthorityKey,ze as deriveRedeemerAccountKey,Dn as deriveRedeemerConfigAddress,Ue as deriveRegisteredTokenAddress,xe as deriveSenderAccountKey,Mt as deriveSenderConfigAddress,Te as deriveSplTokenMetadataKey,kt as deriveTmpTokenAccountAddress,B as deriveTokenBridgeConfigKey,bt as deriveTokenTransferMessageAddress,Q as deriveWrappedMetaKey,re as deriveWrappedMintKey,st as getAttestTokenAccounts,cr as getCompleteTransferNativeAccounts,Nr as getCompleteTransferNativeWithPayloadCpiAccounts,dr as getCompleteTransferWrappedAccounts,Fr as getCompleteTransferWrappedWithPayloadCpiAccounts,fr as getCreateWrappedAccounts,Er as getEndpointRegistration,mr as getInitializeAccounts,Pr as getMetadata,gr as getRegisterChainAccounts,Rr as getTokenBridgeConfig,Ur as getTokenBridgeDerivedAccounts,pr as getTransferNativeAccounts,Bt as getTransferNativeWithPayloadAccounts,Ar as getTransferNativeWithPayloadCpiAccounts,yr as getTransferWrappedAccounts,Rt as getTransferWrappedWithPayloadAccounts,Mr as getTransferWrappedWithPayloadCpiAccounts,hr as getUpgradeContractAccounts,me as getWrappedMeta};
@@ -1 +1 @@
1
- var d=Object.defineProperty;var h=(i,e,r)=>e in i?d(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r;var o=(i,e,r)=>h(i,typeof e!="symbol"?e+"":e,r);import{bI as m,cU as w,a$ as p,bV as g}from"../main.js";import{S as u}from"./sui-DZhbOaP_.js";import"./blake2b-C_UGgjrB.js";import"./index-WlpSU6Q6.js";class c{constructor(e,r,t,n){o(this,"network");o(this,"chain");o(this,"provider");o(this,"contracts");o(this,"chainId");o(this,"coreBridgePackageId");this.network=e,this.chain=r,this.provider=t,this.contracts=n,this.chainId=m(r);const s=n.coreBridge;if(!s)throw new Error(`CoreBridge contract Address for chain ${r} not found`);this.coreBridgePackageId=s}getGuardianSet(e){throw new Error("Method not implemented.")}getMessageFee(){throw new Error("Method not implemented.")}static async fromRpc(e,r){const[t,n]=await u.chainFromRpc(e),s=r[n];if(s.network!==t)throw new Error(`Network mismatch: ${s.network} !== ${t}`);return new c(t,n,e,s.contracts)}async*verifyMessage(e,r){throw new Error("Method not implemented.")}async*publishMessage(e,r){throw new Error("Method not implemented.")}async parseTransaction(e){return(await this.parseMessages(e)).map(t=>({emitter:t.emitterAddress,sequence:t.sequence,chain:this.chain}))}async getGuardianSetIndex(){throw new Error("Method not implemented.")}async parseMessages(e){var n;const t=(n=(await this.provider.getTransactionBlock({digest:e,options:{showEvents:!0,showEffects:!0,showInput:!0}})).events)==null?void 0:n.filter(s=>s.type.endsWith("WormholeMessage"));if(!t||t.length==0)throw new Error("WormholeMessage not found");return t.map(s=>{const a=s.parsedJson;return w("Uint8Array",{emitterChain:this.chain,emitterAddress:new p(a.sender).toUniversalAddress(),sequence:BigInt(a.sequence),guardianSet:0,timestamp:Number(a.timestamp),consistencyLevel:a.consistency_level,nonce:a.nonce,signatures:[],payload:new Uint8Array(a.payload)})})}}g("Sui","WormholeCore",c);export{c as SuiWormholeCore};
1
+ var d=Object.defineProperty;var h=(i,e,r)=>e in i?d(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r;var o=(i,e,r)=>h(i,typeof e!="symbol"?e+"":e,r);import{bJ as m,cV as w,a$ as p,bW as g}from"../main.js";import{S as u}from"./sui-76yNbUUP.js";import"./blake2b-C_UGgjrB.js";import"./index-WlpSU6Q6.js";class c{constructor(e,r,t,n){o(this,"network");o(this,"chain");o(this,"provider");o(this,"contracts");o(this,"chainId");o(this,"coreBridgePackageId");this.network=e,this.chain=r,this.provider=t,this.contracts=n,this.chainId=m(r);const s=n.coreBridge;if(!s)throw new Error(`CoreBridge contract Address for chain ${r} not found`);this.coreBridgePackageId=s}getGuardianSet(e){throw new Error("Method not implemented.")}getMessageFee(){throw new Error("Method not implemented.")}static async fromRpc(e,r){const[t,n]=await u.chainFromRpc(e),s=r[n];if(s.network!==t)throw new Error(`Network mismatch: ${s.network} !== ${t}`);return new c(t,n,e,s.contracts)}async*verifyMessage(e,r){throw new Error("Method not implemented.")}async*publishMessage(e,r){throw new Error("Method not implemented.")}async parseTransaction(e){return(await this.parseMessages(e)).map(t=>({emitter:t.emitterAddress,sequence:t.sequence,chain:this.chain}))}async getGuardianSetIndex(){throw new Error("Method not implemented.")}async parseMessages(e){var n;const t=(n=(await this.provider.getTransactionBlock({digest:e,options:{showEvents:!0,showEffects:!0,showInput:!0}})).events)==null?void 0:n.filter(s=>s.type.endsWith("WormholeMessage"));if(!t||t.length==0)throw new Error("WormholeMessage not found");return t.map(s=>{const a=s.parsedJson;return w("Uint8Array",{emitterChain:this.chain,emitterAddress:new p(a.sender).toUniversalAddress(),sequence:BigInt(a.sequence),guardianSet:0,timestamp:Number(a.timestamp),consistencyLevel:a.consistency_level,nonce:a.nonce,signatures:[],payload:new Uint8Array(a.payload)})})}}g("Sui","WormholeCore",c);export{c as SuiWormholeCore};
@@ -1 +1 @@
1
- var S=Object.defineProperty;var v=(a,e,t)=>e in a?S(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var i=(a,e,t)=>v(a,typeof e!="symbol"?e+"":e,t);import{cV as I,cW as f,cX as x,cT as b,cY as p,bI as w,c9 as U,bP as $,ca as m,af as o,Q as k,ap as c,an as h,cZ as E,cf as T,i as F,cc as C,al as _,bQ as u,c_ as Q,bV as W}from"../main.js";import{A as N}from"./unsignedTransaction-DsxtoHjl.js";import{A as O}from"./aptos-C2a0dQjT.js";import"./chunk-IMTC3J2M-DIjpRZZk.js";import"./index-WlpSU6Q6.js";import"./base64-IWuz5NCL.js";const R=[{name:"tokenBridgeAddress",...f},{name:"chain",...x()},{name:"domainSeparator",binary:"bytes",custom:b.encode(p),omit:!0},{name:"tokenId",...f},{name:"domainSeparator",binary:"bytes",custom:new Uint8Array([255]),omit:!0}],P=a=>I(R,a);class d{constructor(e,t,s,r){i(this,"network");i(this,"chain");i(this,"connection");i(this,"contracts");i(this,"chainId");i(this,"tokenBridgeAddress");this.network=e,this.chain=t,this.connection=s,this.contracts=r,this.chainId=w(t);const n=r.tokenBridge;if(!n)throw new Error(`TokenBridge contract Address for chain ${t} not found`);this.tokenBridgeAddress=n}static async fromRpc(e,t){const[s,r]=await O.chainFromRpc(e),n=t[r];if(n.network!==s)throw new Error("Network mismatch "+n.network+" !== "+s);return new d(s,r,e,n.contracts)}async isWrappedAsset(e){try{return await this.getOriginalAsset(e),!0}catch{return!1}}async getOriginalAsset(e){const t=e.toString().split(p),s=await this.connection.getAccountResource({accountAddress:t[0],resourceType:`${this.tokenBridgeAddress}::state::OriginInfo`});if(!s)throw U(e.toString());const r=$(parseInt(s.token_chain.number)),n=new m(s.token_address.external_address);return{chain:r,address:n}}async getTokenUniversalAddress(e){return new m(o.encode(k(e.toString()),!0))}async getTokenNativeAddress(e,t){const s=e===this.chain?await this.getTypeFromExternalAddress(t.toString()):await this.getAssetFullyQualifiedType({chain:e,address:t});if(!s)throw new Error("Invalid asset address.");return new c(s)}async hasWrappedAsset(e){try{return await this.getWrappedAsset(e),!0}catch{}return!1}async getWrappedAsset(e){if(h(e.address))throw new Error("native asset cannot be a wrapped asset");const t=await this.getAssetFullyQualifiedType(e);if(!t)throw new Error("Invalid asset address.");return await this.connection.getAccountResource({accountAddress:E(t),resourceType:`${this.tokenBridgeAddress}::state::OriginInfo`}),T(this.chain,t)}async isTransferCompleted(e){const s=(await this.connection.getAccountResource({accountAddress:this.tokenBridgeAddress,resourceType:`${this.tokenBridgeAddress}::state::State`})).consumed_vaas.elems.handle;try{return await this.connection.getTableItem({handle:s,data:{key_type:"vector<u8>",value_type:"u8",key:`0x${F.Buffer.from(C(e.hash)).toString("hex")}`}}),!0}catch{return!1}}async getWrappedNative(){return T(this.chain,_)}async*createAttestation(e,t){const s={chain:this.chain,address:new c(e)},r=await this.getAssetFullyQualifiedType(s);if(!r)throw new Error("Invalid asset address.");yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::attest_token::attest_token_entry`,typeArguments:[r],functionArguments:[]},"Aptos.AttestToken")}async*submitAttestation(e,t){yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::wrapped::create_wrapped_coin_type`,typeArguments:[],functionArguments:[u(e)]},"Aptos.CreateWrappedCoinType");const s=await this.getAssetFullyQualifiedType(e.payload.token);if(!s)throw new Error("Invalid asset address.");yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::wrapped::create_wrapped_coin`,typeArguments:[s],functionArguments:[u(e)]},"Aptos.CreateWrappedCoin")}async*transfer(e,t,s,r,n){const B=0n,A=0n,y=h(s)?_:s.toString(),l=t.address.toUniversalAddress().toUint8Array(),g=w(t.chain);n?yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::transfer_tokens::transfer_tokens_with_payload_entry`,typeArguments:[y],functionArguments:[r,g,l,A,n]},"Aptos.TransferTokensWithPayload"):yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::transfer_tokens::transfer_tokens_entry`,typeArguments:[y],functionArguments:[r,g,l,B,A]},"Aptos.TransferTokens")}async*redeem(e,t,s=!0){const r=t.payload.token.chain===this.chain?await this.getTypeFromExternalAddress(t.payload.token.address.toString()):await this.getAssetFullyQualifiedType(t.payload.token);if(!r)throw new Error("Invalid asset address.");yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::complete_transfer::submit_vaa_and_register_entry`,typeArguments:[r],functionArguments:[u(t)]},"Aptos.CompleteTransfer")}async getAssetFullyQualifiedType(e){return e.chain===this.chain?Q(e.address.toString())?e.address.toString():null:`${d.getForeignAssetAddress(this.chain,this.tokenBridgeAddress,e)}::coin::T`}async getTypeFromExternalAddress(e){try{const t=await this.connection.getAccountResource({accountAddress:this.tokenBridgeAddress,resourceType:`${this.tokenBridgeAddress}::state::State`}),{handle:s}=t.native_infos,r=await this.connection.getTableItem({handle:s,data:{key_type:`${this.tokenBridgeAddress}::token_hash::TokenHash`,value_type:"0x1::type_info::TypeInfo",key:{hash:e}}});return r?[r.account_address,String.fromCharCode(...o.decode(r.module_name)),String.fromCharCode(...o.decode(r.struct_name))].join(p):null}catch{return null}}static getForeignAssetAddress(e,t,s){if(h(s.address))throw new Error("Invalid token address");const r=P({chain:s.chain,tokenBridgeAddress:new c(t).toUniversalAddress(),tokenId:s.address.toUniversalAddress()});return o.encode(k(r),!0)}createUnsignedTx(e,t,s=!1){return new N(e,this.network,this.chain,t,s)}}W("Aptos","TokenBridge",d);export{d as AptosTokenBridge};
1
+ var S=Object.defineProperty;var v=(a,e,t)=>e in a?S(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var i=(a,e,t)=>v(a,typeof e!="symbol"?e+"":e,t);import{cW as I,cX as f,cY as x,cU as b,cZ as p,bJ as w,ca as U,bQ as $,cb as m,af as o,Q as k,ap as c,an as h,c_ as E,cg as T,i as F,cd as C,al as _,bR as u,c$ as W,bW as Q}from"../main.js";import{A as R}from"./unsignedTransaction-DsxtoHjl.js";import{A as N}from"./aptos-BaxuZv2A.js";import"./chunk-IMTC3J2M-DIjpRZZk.js";import"./index-WlpSU6Q6.js";import"./base64-IWuz5NCL.js";const O=[{name:"tokenBridgeAddress",...f},{name:"chain",...x()},{name:"domainSeparator",binary:"bytes",custom:b.encode(p),omit:!0},{name:"tokenId",...f},{name:"domainSeparator",binary:"bytes",custom:new Uint8Array([255]),omit:!0}],P=a=>I(O,a);class d{constructor(e,t,s,r){i(this,"network");i(this,"chain");i(this,"connection");i(this,"contracts");i(this,"chainId");i(this,"tokenBridgeAddress");this.network=e,this.chain=t,this.connection=s,this.contracts=r,this.chainId=w(t);const n=r.tokenBridge;if(!n)throw new Error(`TokenBridge contract Address for chain ${t} not found`);this.tokenBridgeAddress=n}static async fromRpc(e,t){const[s,r]=await N.chainFromRpc(e),n=t[r];if(n.network!==s)throw new Error("Network mismatch "+n.network+" !== "+s);return new d(s,r,e,n.contracts)}async isWrappedAsset(e){try{return await this.getOriginalAsset(e),!0}catch{return!1}}async getOriginalAsset(e){const t=e.toString().split(p),s=await this.connection.getAccountResource({accountAddress:t[0],resourceType:`${this.tokenBridgeAddress}::state::OriginInfo`});if(!s)throw U(e.toString());const r=$(parseInt(s.token_chain.number)),n=new m(s.token_address.external_address);return{chain:r,address:n}}async getTokenUniversalAddress(e){return new m(o.encode(k(e.toString()),!0))}async getTokenNativeAddress(e,t){const s=e===this.chain?await this.getTypeFromExternalAddress(t.toString()):await this.getAssetFullyQualifiedType({chain:e,address:t});if(!s)throw new Error("Invalid asset address.");return new c(s)}async hasWrappedAsset(e){try{return await this.getWrappedAsset(e),!0}catch{}return!1}async getWrappedAsset(e){if(h(e.address))throw new Error("native asset cannot be a wrapped asset");const t=await this.getAssetFullyQualifiedType(e);if(!t)throw new Error("Invalid asset address.");return await this.connection.getAccountResource({accountAddress:E(t),resourceType:`${this.tokenBridgeAddress}::state::OriginInfo`}),T(this.chain,t)}async isTransferCompleted(e){const s=(await this.connection.getAccountResource({accountAddress:this.tokenBridgeAddress,resourceType:`${this.tokenBridgeAddress}::state::State`})).consumed_vaas.elems.handle;try{return await this.connection.getTableItem({handle:s,data:{key_type:"vector<u8>",value_type:"u8",key:`0x${F.Buffer.from(C(e.hash)).toString("hex")}`}}),!0}catch{return!1}}async getWrappedNative(){return T(this.chain,_)}async*createAttestation(e,t){const s={chain:this.chain,address:new c(e)},r=await this.getAssetFullyQualifiedType(s);if(!r)throw new Error("Invalid asset address.");yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::attest_token::attest_token_entry`,typeArguments:[r],functionArguments:[]},"Aptos.AttestToken")}async*submitAttestation(e,t){yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::wrapped::create_wrapped_coin_type`,typeArguments:[],functionArguments:[u(e)]},"Aptos.CreateWrappedCoinType");const s=await this.getAssetFullyQualifiedType(e.payload.token);if(!s)throw new Error("Invalid asset address.");yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::wrapped::create_wrapped_coin`,typeArguments:[s],functionArguments:[u(e)]},"Aptos.CreateWrappedCoin")}async*transfer(e,t,s,r,n){const B=0n,A=0n,y=h(s)?_:s.toString(),g=t.address.toUniversalAddress().toUint8Array(),l=w(t.chain);n?yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::transfer_tokens::transfer_tokens_with_payload_entry`,typeArguments:[y],functionArguments:[r,l,g,A,n]},"Aptos.TransferTokensWithPayload"):yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::transfer_tokens::transfer_tokens_entry`,typeArguments:[y],functionArguments:[r,l,g,B,A]},"Aptos.TransferTokens")}async*redeem(e,t,s=!0){const r=t.payload.token.chain===this.chain?await this.getTypeFromExternalAddress(t.payload.token.address.toString()):await this.getAssetFullyQualifiedType(t.payload.token);if(!r)throw new Error("Invalid asset address.");yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::complete_transfer::submit_vaa_and_register_entry`,typeArguments:[r],functionArguments:[u(t)]},"Aptos.CompleteTransfer")}async getAssetFullyQualifiedType(e){return e.chain===this.chain?W(e.address.toString())?e.address.toString():null:`${d.getForeignAssetAddress(this.chain,this.tokenBridgeAddress,e)}::coin::T`}async getTypeFromExternalAddress(e){try{const t=await this.connection.getAccountResource({accountAddress:this.tokenBridgeAddress,resourceType:`${this.tokenBridgeAddress}::state::State`}),{handle:s}=t.native_infos,r=await this.connection.getTableItem({handle:s,data:{key_type:`${this.tokenBridgeAddress}::token_hash::TokenHash`,value_type:"0x1::type_info::TypeInfo",key:{hash:e}}});return r?[r.account_address,String.fromCharCode(...o.decode(r.module_name)),String.fromCharCode(...o.decode(r.struct_name))].join(p):null}catch{return null}}static getForeignAssetAddress(e,t,s){if(h(s.address))throw new Error("Invalid token address");const r=P({chain:s.chain,tokenBridgeAddress:new c(t).toUniversalAddress(),tokenId:s.address.toUniversalAddress()});return o.encode(k(r),!0)}createUnsignedTx(e,t,s=!1){return new R(e,this.network,this.chain,t,s)}}Q("Aptos","TokenBridge",d);export{d as AptosTokenBridge};