@wormhole-foundation/wormhole-connect 2.2.0-beta.1-development → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +49 -49
- package/dist/src/views/TxSearch.d.ts.map +1 -1
- package/lib/{aptos-CCgGvZjs.mjs → aptos-7dMQQEIW.mjs} +5 -5
- package/lib/{aptos-DVYbmFJJ.mjs → aptos-BUemveTM.mjs} +2 -2
- package/lib/{aptos-31PA2rFX.js → aptos-CWfp2v_P.js} +2 -2
- package/lib/{aptos-B8jsnVoS.js → aptos-umg2ncs_.js} +1 -1
- package/lib/{base64-5kcPH2Ry.js → base64-BlOlyzUY.js} +1 -1
- package/lib/{base64-CL9tkFGP.mjs → base64-CIH-T7Pn.mjs} +1 -1
- package/lib/{ccip-javMNNCd.mjs → ccip-BhU7SDb9.mjs} +1 -1
- package/lib/{ccip--zj9SMHN.js → ccip-CdkU-__S.js} +1 -1
- package/lib/{chunk-IMTC3J2M-DeAwWSAu.mjs → chunk-IMTC3J2M-Bm_KxGLU.mjs} +3 -3
- package/lib/{chunk-IMTC3J2M-BcLXY1O4.js → chunk-IMTC3J2M-CG7LPkYt.js} +1 -1
- package/lib/{events-BIr0rmUF.mjs → events-hPS-mKjU.mjs} +1 -1
- package/lib/{events-ZTJJzzwL.js → events-jQ_Do8B1.js} +1 -1
- package/lib/{evm-CYdShX9n.mjs → evm-AFZ_po3U.mjs} +5 -5
- package/lib/{evm-BmG93aNU.js → evm-Ck-LC8K1.js} +3 -3
- package/lib/{evm-DWNU26Tx.js → evm-D4OaAvxv.js} +1 -1
- package/lib/{evm-BdJvPk3J.mjs → evm-DvlAO_-c.mjs} +5 -5
- package/lib/{index-CGW6Ztd2.js → index-AVSrA-i6.js} +1 -1
- package/lib/{index-DCC8GaVH.mjs → index-B3nUhqKI.mjs} +2 -2
- package/lib/{index-DvkkJ_AY.js → index-B9WBHQFN.js} +1 -1
- package/lib/{index-DOGZjt2S.js → index-BEhe2aRM.js} +5 -5
- package/lib/{index-D0onBS9d.js → index-BFXBE_Mo.js} +1 -1
- package/lib/{index-D_elFvDQ.mjs → index-BKBGPzmc.mjs} +1 -1
- package/lib/{index-kwKTcApr.mjs → index-BNe7LUKU.mjs} +5 -5
- package/lib/{index-DYiI6lkY.mjs → index-BUDas0Q7.mjs} +1 -1
- package/lib/{index-SEUn7gSU.mjs → index-BWsfR9uT.mjs} +1 -1
- package/lib/{index-BhqFkgz5.mjs → index-BZs20N4K.mjs} +2 -2
- package/lib/{index-DWtG2bDp.js → index-BbSC7v8g.js} +1 -1
- package/lib/{index-Bn7RXnWl.mjs → index-BchoBDpT.mjs} +2 -2
- package/lib/{index-ZSnwMbPW.js → index-Bd3pCFb1.js} +1 -1
- package/lib/{index-i9soDbgm.js → index-Bi5J2r-k.js} +1 -1
- package/lib/{index-Upxa6-Ok.js → index-Bu1PkKLG.js} +1 -1
- package/lib/{index-Ck1M3TS1.mjs → index-C0ecUbom.mjs} +2 -2
- package/lib/{index-Dsfz-oia.mjs → index-CHWND-D1.mjs} +3 -3
- package/lib/{index-BbiyKg6p.js → index-CUR8Z8Cf.js} +1 -1
- package/lib/{index-CNRoD0cV.mjs → index-CaNzAG1x.mjs} +98 -92
- package/lib/{index-rzStwWOM.js → index-CdrPNIu_.js} +1 -1
- package/lib/{index-ZjwERA88.js → index-CtS6jcgq.js} +1 -1
- package/lib/{index-B39ftYxK.mjs → index-D0QNNKvo.mjs} +4 -4
- package/lib/{index-DUaJiMqI.mjs → index-D1q2O2Av.mjs} +3 -3
- package/lib/{index-D_2bb1Pv.js → index-D5fAF0iQ.js} +1 -1
- package/lib/{index-CvDrTlD5.js → index-D9o7O_OT.js} +1 -1
- package/lib/{index-DdvuhkPU.mjs → index-DTfWrGt3.mjs} +1 -1
- package/lib/{index-C0yUUgWL.js → index-DV2Mc1nu.js} +1 -1
- package/lib/{index-Co3Xxu9O.mjs → index-Derjp7Zu.mjs} +2 -2
- package/lib/{index-xI8bbCGj.js → index-Df5E8ttw.js} +1 -1
- package/lib/{index-cugw_66S.mjs → index-Dhyj87bh.mjs} +1 -1
- package/lib/{index-yQD0Xsib.js → index-DirgoiOD.js} +1 -1
- package/lib/{index-CLGrfUbL.mjs → index-DyvLFo_F.mjs} +2 -2
- package/lib/{index-CtfLRYM0.mjs → index-JVwNffKI.mjs} +2 -2
- package/lib/{index-C89319ht.js → index-KdiLn9Rj.js} +1 -1
- package/lib/{index-DGB2Fxry.mjs → index-MxqIZiRX.mjs} +2 -2
- package/lib/{index-BUHmIbm1.mjs → index-NWE7RRiw.mjs} +2 -2
- package/lib/{index-CMzehyQ8.js → index-PNYcH9VB.js} +1 -1
- package/lib/{index-gdamBcoQ.js → index-WPYOQdpa.js} +1 -1
- package/lib/{index-Dg_F5gMq.js → index-hus1Sl4S.js} +1 -1
- package/lib/{index-x4yUWfDi.mjs → index-ihbUzPuY.mjs} +1 -1
- package/lib/{index-YTBFGtnw.mjs → index-nWaQESZp.mjs} +1 -1
- package/lib/{index-CGCa-j7o.js → index-wHDS4NqS.js} +1 -1
- package/lib/{index.es-D1p0ce-Y.js → index.es-CJrTwrY5.js} +2 -2
- package/lib/{index.es-Cw1Vg7NX.mjs → index.es-D6eM34wK.mjs} +6 -6
- package/lib/index.js +1 -1
- package/lib/index.mjs +1 -1
- package/lib/{signer-C1_tDQTi.js → signer-C1hgiPI9.js} +1 -1
- package/lib/{signer-C4Jm9zsl.mjs → signer-CXxUSLSd.mjs} +1 -1
- package/lib/solana-B0ZJBh57.js +1 -0
- package/lib/{solana-Q8lVR5YD.mjs → solana-C06kaujM.mjs} +5 -5
- package/lib/{solana--vtCR0-G.mjs → solana-D4eoBu_Q.mjs} +4 -4
- package/lib/{solana-BtM4z8cN.js → solana-XXmHFxEb.js} +1 -1
- package/lib/{solanaEmbed.esm-DsV8Nqbb.js → solanaEmbed.esm-CBSm6nV9.js} +1 -1
- package/lib/{solanaEmbed.esm-BvXjTkVM.mjs → solanaEmbed.esm-dce8g5AQ.mjs} +2 -2
- package/lib/src/views/TxSearch.d.ts.map +1 -1
- package/lib/{sui-CsDZcGdt.js → sui-BDZkyTVG.js} +1 -1
- package/lib/{sui-B6LQdf1S.mjs → sui-BEvt3G9o.mjs} +1 -1
- package/lib/{sui-CdyyFA7x.js → sui-CrYGHvcd.js} +2 -2
- package/lib/{sui-C9At-twC.mjs → sui-D8i87rc-.mjs} +5 -5
- package/package.json +1 -1
- package/lib/solana-LXeQ1tV1.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./index-CUR8Z8Cf.js"),ko=require("./dijkstra-CtFxn7S9.js"),Mo=require("./index-BEhe2aRM.js");/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ct as Wl, V as R, cr as sa, aD as Hl, X as oa, c5 as L, ae as Jl, ai as Gl } from "./index-
|
|
1
|
+
import { ct as Wl, V as R, cr as sa, aD as Hl, X as oa, c5 as L, ae as Jl, ai as Gl } from "./index-CaNzAG1x.mjs";
|
|
2
2
|
import { d as Yl } from "./dijkstra-BZM-8g-B.mjs";
|
|
3
|
-
import { e as He, s as aa } from "./events-
|
|
4
|
-
import { c as I, a as Ye } from "./index-
|
|
5
|
-
import { r as Ql, a as It, g as xt, i as qe, b as ni, I as Rt, f as Ce, t as fe, w as Hi, c as Si, C as Xl, d as Zl, e as ns, h as eu, j as tu, k as vn, p as ru, l as wn, A as iu, E as pe, m as nu, y as be, P as ss, Q as su, n as ou, T as ca, o as _n, q as bn, s as Qe, _ as au, u as vt } from "./index-
|
|
6
|
-
import { s as la, a as Re, h as ua, L as cu, d as nr, l as lu, e as Ii, g as uu, i as os, k as hu } from "./index-
|
|
3
|
+
import { e as He, s as aa } from "./events-hPS-mKjU.mjs";
|
|
4
|
+
import { c as I, a as Ye } from "./index-nWaQESZp.mjs";
|
|
5
|
+
import { r as Ql, a as It, g as xt, i as qe, b as ni, I as Rt, f as Ce, t as fe, w as Hi, c as Si, C as Xl, d as Zl, e as ns, h as eu, j as tu, k as vn, p as ru, l as wn, A as iu, E as pe, m as nu, y as be, P as ss, Q as su, n as ou, T as ca, o as _n, q as bn, s as Qe, _ as au, u as vt } from "./index-MxqIZiRX.mjs";
|
|
6
|
+
import { s as la, a as Re, h as ua, L as cu, d as nr, l as lu, e as Ii, g as uu, i as os, k as hu } from "./index-BKBGPzmc.mjs";
|
|
7
7
|
let du = class extends Ql {
|
|
8
8
|
constructor(e) {
|
|
9
9
|
super(e), this.events = new He.EventEmitter(), this.hasRegisteredEventListeners = !1, this.connection = this.setConnection(e), this.connection.connected && this.registerEventListeners();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aJ as L, aU as g, aV as F, aW as k, aX as I, O as P, Q as T } from "./index-
|
|
1
|
+
import { aJ as L, aU as g, aV as F, aW as k, aX as I, O as P, Q as T } from "./index-CaNzAG1x.mjs";
|
|
2
2
|
function D(n, t, e, s) {
|
|
3
3
|
g(n);
|
|
4
4
|
const i = F({ dkLen: 32, asyncTick: 10 }, s), { c: u, dkLen: a, asyncTick: o } = i;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var $ = Object.defineProperty;
|
|
2
2
|
var V = (i, e, b) => e in i ? $(i, e, { enumerable: !0, configurable: !0, writable: !0, value: b }) : i[e] = b;
|
|
3
3
|
var d = (i, e, b) => V(i, typeof e != "symbol" ? e + "" : e, b);
|
|
4
|
-
import { b8 as E, E as o, bA as x, b6 as l, bd as z, bB as j, b as c, m as k, bC as L, bD as G, be as g, bE as W, bF as T, bc as s, bG as _, bh as P, bi as F, bz as N, b5 as q, a4 as D, bj as H, _ as O } from "./index-
|
|
4
|
+
import { b8 as E, E as o, bA as x, b6 as l, bd as z, bB as j, b as c, m as k, bC as L, bD as G, be as g, bE as W, bF as T, bc as s, bG as _, bh as P, bi as F, bz as N, b5 as q, a4 as D, bj as H, _ as O } from "./index-CaNzAG1x.mjs";
|
|
5
5
|
class B {
|
|
6
6
|
constructor(e, b, a, t) {
|
|
7
7
|
d(this, "network");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var Er = Object.defineProperty;
|
|
2
2
|
var xr = (e, t, r) => t in e ? Er(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
3
|
var F = (e, t, r) => xr(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
import { X as jr, y as Ir, cj as Or, bw as Ar, bu as kr, bv as Bt, r as _r, bx as Rt, bj as Cr } from "./index-
|
|
5
|
-
import { S as Nt, u as Pt } from "./sui-
|
|
4
|
+
import { X as jr, y as Ir, cj as Or, bw as Ar, bu as kr, bv as Bt, r as _r, bx as Rt, bj as Cr } from "./index-CaNzAG1x.mjs";
|
|
5
|
+
import { S as Nt, u as Pt } from "./sui-D8i87rc-.mjs";
|
|
6
6
|
import { S as $r } from "./unsignedTransaction-BD81leu1.mjs";
|
|
7
7
|
class Mr extends TypeError {
|
|
8
8
|
constructor(t, r) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var wt=Object.defineProperty;var St=(t,n,i)=>n in t?wt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i;var l=(t,n,i)=>St(t,typeof n!="symbol"?n+"":n,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DOGZjt2S.js"),y=new e.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");new e.PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");const te=new e.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),R=new e.PublicKey("So11111111111111111111111111111111111111112");new e.PublicKey("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP");class z extends Error{constructor(n){super(n)}}class Se extends z{constructor(){super(...arguments),this.name="TokenAccountNotFoundError"}}class At extends z{constructor(){super(...arguments),this.name="TokenInvalidAccountError"}}class Le extends z{constructor(){super(...arguments),this.name="TokenInvalidAccountOwnerError"}}class V extends z{constructor(){super(...arguments),this.name="TokenInvalidAccountSizeError"}}class Mt extends z{constructor(){super(...arguments),this.name="TokenInvalidMintError"}}class qe extends z{constructor(){super(...arguments),this.name="TokenOwnerOffCurveError"}}var O;(function(t){t[t.InitializeMint=0]="InitializeMint",t[t.InitializeAccount=1]="InitializeAccount",t[t.InitializeMultisig=2]="InitializeMultisig",t[t.Transfer=3]="Transfer",t[t.Approve=4]="Approve",t[t.Revoke=5]="Revoke",t[t.SetAuthority=6]="SetAuthority",t[t.MintTo=7]="MintTo",t[t.Burn=8]="Burn",t[t.CloseAccount=9]="CloseAccount",t[t.FreezeAccount=10]="FreezeAccount",t[t.ThawAccount=11]="ThawAccount",t[t.TransferChecked=12]="TransferChecked",t[t.ApproveChecked=13]="ApproveChecked",t[t.MintToChecked=14]="MintToChecked",t[t.BurnChecked=15]="BurnChecked",t[t.InitializeAccount2=16]="InitializeAccount2",t[t.SyncNative=17]="SyncNative",t[t.InitializeAccount3=18]="InitializeAccount3",t[t.InitializeMultisig2=19]="InitializeMultisig2",t[t.InitializeMint2=20]="InitializeMint2",t[t.GetAccountDataSize=21]="GetAccountDataSize",t[t.InitializeImmutableOwner=22]="InitializeImmutableOwner",t[t.AmountToUiAmount=23]="AmountToUiAmount",t[t.UiAmountToAmount=24]="UiAmountToAmount",t[t.InitializeMintCloseAuthority=25]="InitializeMintCloseAuthority",t[t.TransferFeeExtension=26]="TransferFeeExtension",t[t.ConfidentialTransferExtension=27]="ConfidentialTransferExtension",t[t.DefaultAccountStateExtension=28]="DefaultAccountStateExtension",t[t.Reallocate=29]="Reallocate",t[t.MemoTransferExtension=30]="MemoTransferExtension",t[t.CreateNativeMint=31]="CreateNativeMint",t[t.InitializeNonTransferableMint=32]="InitializeNonTransferableMint",t[t.InterestBearingMintExtension=33]="InterestBearingMintExtension",t[t.CpiGuardExtension=34]="CpiGuardExtension",t[t.InitializePermanentDelegate=35]="InitializePermanentDelegate",t[t.TransferHookExtension=36]="TransferHookExtension",t[t.MetadataPointerExtension=39]="MetadataPointerExtension"})(O||(O={}));function Ae(t,n,i){if(i.length){t.push({pubkey:n,isSigner:!1,isWritable:!1});for(const r of i)t.push({pubkey:r instanceof e.PublicKey?r:r.publicKey,isSigner:!0,isWritable:!1})}else t.push({pubkey:n,isSigner:!0,isWritable:!1});return t}const Ee=e.struct([e.u8("instruction"),e.u64("amount")]);function bt(t,n,i,r,a=[],s=y){const c=Ae([{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1}],i,a),o=e.dist.Buffer.alloc(Ee.span);return Ee.encode({instruction:O.Approve,amount:BigInt(r)},o),new e.TransactionInstruction({keys:c,programId:s,data:o})}const _e=e.struct([e.u8("instruction")]);function Ke(t,n,i,r=[],a=y){const s=Ae([{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0}],i,r),c=e.dist.Buffer.alloc(_e.span);return _e.encode({instruction:O.CloseAccount},c),new e.TransactionInstruction({keys:s,programId:a,data:c})}var $;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Mint=1]="Mint",t[t.Account=2]="Account"})($||($={}));const Me=1,kt=e.struct([e.u8("m"),e.u8("n"),e.bool("isInitialized"),e.publicKey("signer1"),e.publicKey("signer2"),e.publicKey("signer3"),e.publicKey("signer4"),e.publicKey("signer5"),e.publicKey("signer6"),e.publicKey("signer7"),e.publicKey("signer8"),e.publicKey("signer9"),e.publicKey("signer10"),e.publicKey("signer11")]),be=kt.span;var j;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initialized=1]="Initialized",t[t.Frozen=2]="Frozen"})(j||(j={}));const Ve=e.struct([e.publicKey("mint"),e.publicKey("owner"),e.u64("amount"),e.u32("delegateOption"),e.publicKey("delegate"),e.u8("state"),e.u32("isNativeOption"),e.u64("isNative"),e.u64("delegatedAmount"),e.u32("closeAuthorityOption"),e.publicKey("closeAuthority")]),T=Ve.span;async function Tt(t,n,i,r=y){const a=await t.getAccountInfo(n,i);return vt(n,a,r)}async function We(t,n){return await Ct(t,[],n)}async function Ct(t,n,i){const r=on(n);return await t.getMinimumBalanceForRentExemption(r,i)}function vt(t,n,i=y){if(!n)throw new Se;if(!n.owner.equals(i))throw new Le;if(n.data.length<T)throw new V;const r=Ve.decode(n.data.slice(0,T));let a=e.dist.Buffer.alloc(0);if(n.data.length>T){if(n.data.length===be)throw new V;if(n.data[T]!=$.Account)throw new At;a=n.data.slice(T+Me)}return{address:t,mint:r.mint,owner:r.owner,amount:r.amount,delegate:r.delegateOption?r.delegate:null,delegatedAmount:r.delegatedAmount,isInitialized:r.state!==j.Uninitialized,isFrozen:r.state===j.Frozen,isNative:!!r.isNativeOption,rentExemptReserve:r.isNativeOption?r.isNative:null,closeAuthority:r.closeAuthorityOption?r.closeAuthority:null,tlvData:a}}const Ge=e.struct([e.u32("mintAuthorityOption"),e.publicKey("mintAuthority"),e.u64("supply"),e.u8("decimals"),e.bool("isInitialized"),e.u32("freezeAuthorityOption"),e.publicKey("freezeAuthority")]),me=Ge.span;async function Pt(t,n,i,r=y){const a=await t.getAccountInfo(n,i);return Bt(n,a,r)}function Bt(t,n,i=y){if(!n)throw new Se;if(!n.owner.equals(i))throw new Le;if(n.data.length<me)throw new V;const r=Ge.decode(n.data.slice(0,me));let a=e.dist.Buffer.alloc(0);if(n.data.length>me){if(n.data.length<=T)throw new V;if(n.data.length===be)throw new V;if(n.data[T]!=$.Mint)throw new Mt;a=n.data.slice(T+Me)}return{address:t,mintAuthority:r.mintAuthorityOption?r.mintAuthority:null,supply:r.supply,decimals:r.decimals,isInitialized:r.isInitialized,freezeAuthority:r.freezeAuthorityOption?r.freezeAuthority:null,tlvData:a}}async function Ne(t,n,i=!1,r=y,a=te){if(!i&&!e.PublicKey.isOnCurve(n.toBuffer()))throw new qe;const[s]=await e.PublicKey.findProgramAddress([n.toBuffer(),r.toBuffer(),t.toBuffer()],a);return s}function ke(t,n,i=!1,r=y,a=te){if(!i&&!e.PublicKey.isOnCurve(n.toBuffer()))throw new qe;const[s]=e.PublicKey.findProgramAddressSync([n.toBuffer(),r.toBuffer(),t.toBuffer()],a);return s}const Rt=e.struct([e.bool("lockCpi")]),It=Rt.span,Et=e.struct([e.u8("state")]),_t=Et.span,Kt=e.struct([]),Wt=Kt.span,Nt=e.struct([e.publicKey("rateAuthority"),e.ns64("initializationTimestamp"),e.s16("preUpdateAverageRate"),e.ns64("lastUpdateTimestamp"),e.s16("currentRate")]),Ut=Nt.span,Ft=e.struct([e.bool("requireIncomingTransferMemos")]),Ot=Ft.span,xt=e.struct([e.publicKey("authority"),e.publicKey("metadataAddress")]),zt=xt.span,Dt=e.struct([e.publicKey("closeAuthority")]),Lt=Dt.span,Ye=e.struct([]),qt=Ye.span,Vt=Ye.span,Gt=e.struct([e.publicKey("delegate")]),Yt=Gt.span,Zt=1e4;BigInt(Zt);function Ue(t){return e.struct([e.u64("epoch"),e.u64("maximumFee"),e.u16("transferFeeBasisPoints")],t)}const Ht=e.struct([e.publicKey("transferFeeConfigAuthority"),e.publicKey("withdrawWithheldAuthority"),e.u64("withheldAmount"),Ue("olderTransferFee"),Ue("newerTransferFee")]),Qt=Ht.span,Xt=e.struct([e.u64("withheldAmount")]),Jt=Xt.span,$t=e.struct([e.publicKey("authority"),e.publicKey("programId")]),jt=$t.span,en=e.struct([e.bool("transferring")]),tn=en.span,Fe=e.struct([e.u8("discriminator"),e.blob(32,"addressConfig"),e.bool("isSigner"),e.bool("isWritable")]),nn=e.struct([e.u32("count"),e.seq(Fe,e.greedy(Fe.span),"extraAccounts")]);e.struct([e.u64("instructionDiscriminator"),e.u32("length"),nn.replicate("extraAccountsList")]);var w;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.TransferFeeConfig=1]="TransferFeeConfig",t[t.TransferFeeAmount=2]="TransferFeeAmount",t[t.MintCloseAuthority=3]="MintCloseAuthority",t[t.ConfidentialTransferMint=4]="ConfidentialTransferMint",t[t.ConfidentialTransferAccount=5]="ConfidentialTransferAccount",t[t.DefaultAccountState=6]="DefaultAccountState",t[t.ImmutableOwner=7]="ImmutableOwner",t[t.MemoTransfer=8]="MemoTransfer",t[t.NonTransferable=9]="NonTransferable",t[t.InterestBearingConfig=10]="InterestBearingConfig",t[t.CpiGuard=11]="CpiGuard",t[t.PermanentDelegate=12]="PermanentDelegate",t[t.NonTransferableAccount=13]="NonTransferableAccount",t[t.TransferHook=14]="TransferHook",t[t.TransferHookAccount=15]="TransferHookAccount",t[t.MetadataPointer=18]="MetadataPointer"})(w||(w={}));const Oe=2,rn=2;function an(t){switch(t){case w.Uninitialized:return 0;case w.TransferFeeConfig:return Qt;case w.TransferFeeAmount:return Jt;case w.MintCloseAuthority:return Lt;case w.ConfidentialTransferMint:return 97;case w.ConfidentialTransferAccount:return 286;case w.CpiGuard:return It;case w.DefaultAccountState:return _t;case w.ImmutableOwner:return Wt;case w.MemoTransfer:return Ot;case w.MetadataPointer:return zt;case w.NonTransferable:return qt;case w.InterestBearingConfig:return Ut;case w.PermanentDelegate:return Yt;case w.NonTransferableAccount:return Vt;case w.TransferHook:return jt;case w.TransferHookAccount:return tn;default:throw Error(`Unknown extension type: ${t}`)}}function sn(t,n){if(t.length===0)return n;{const i=T+Me+t.filter((r,a)=>a===t.indexOf(r)).map(r=>an(r)+Oe+rn).reduce((r,a)=>r+a);return i===be?i+Oe:i}}function on(t){return sn(t,T)}const xe=e.struct([e.u8("instruction")]);function ze(t,n,i,r=y){const a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:e.SYSVAR_RENT_PUBKEY,isSigner:!1,isWritable:!1}],s=e.dist.Buffer.alloc(xe.span);return xe.encode({instruction:O.InitializeAccount},s),new e.TransactionInstruction({keys:a,programId:r,data:s})}function Ze(t,n,i,r,a=y,s=te){return cn(t,n,i,r,e.dist.Buffer.alloc(0),a,s)}function cn(t,n,i,r,a,s=y,c=te){const o=[{pubkey:t,isSigner:!0,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:e.SystemProgram.programId,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!1,isWritable:!1}];return new e.TransactionInstruction({keys:o,programId:c,data:a})}const De=e.struct([e.u8("instruction"),e.u64("amount")]);function un(t,n,i,r,a=[],s=y){const c=Ae([{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0}],i,a),o=e.dist.Buffer.alloc(De.span);return De.encode({instruction:O.Transfer,amount:BigInt(r)},o),new e.TransactionInstruction({keys:c,programId:s,data:o})}function ne(t,n){const i=e.dist.Buffer.alloc(2);return i.writeUInt16BE(e.toChainId(n)),e.deriveAddress([e.dist.Buffer.from("foreign_contract"),i],t)}function He(t){return e.deriveAddress([e.dist.Buffer.from("redeemer")],t)}function re(t,n){return e.deriveAddress([e.dist.Buffer.from("mint"),new e.PublicKey(n).toBuffer()],t)}function Te(t){return e.deriveAddress([e.dist.Buffer.from("sender")],t)}function Ce(t,n){return e.deriveAddress([e.dist.Buffer.from("tmp"),new e.PublicKey(n).toBuffer()],t)}function ve(t,n,i){return e.deriveAddress([e.dist.Buffer.from("bridged"),new e.PublicKey(n).toBuffer(),e.dist.Buffer.from(e.bignum.toBytes(BigInt(i.toString()),8))],t)}function A(t){return e.deriveAddress([e.dist.Buffer.from("config")],t)}async function dn(t,n,i){return t.getAccountInfo(A(n),i).then(r=>ie.deserialize(e.getAccountData(r)))}class ie{constructor(n){l(this,"wormhole");this.wormhole=new e.PublicKey(n)}static deserialize(n){if(n.length!=32)throw new Error("data.length != 32");const i=n.subarray(0,32);return new ie(i)}}function H(t,n){return e.deriveAddress([new e.PublicKey(n).toBuffer()],t)}function K(t,n,i){if(n==e.toChainId("Solana"))throw new Error("emitterChain == CHAIN_ID_SOLANA cannot exist as foreign token bridge emitter");const r=typeof i=="string"?new e.UniversalAddress(i).toUint8Array():i;return e.deriveAddress([(()=>{const a=e.dist.Buffer.alloc(2);return a.writeUInt16BE(n),a})(),r],t)}async function ln(t,n,i){return t.getAccountInfo(new e.PublicKey(n),i).then(r=>ae.deserialize(e.getAccountData(r)))}class ae{constructor(n,i){l(this,"chain");l(this,"contract");this.chain=n,this.contract=i}static deserialize(n){if(n.length!=34)throw new Error("data.length != 34");const i=n.readUInt16LE(0),r=n.subarray(2,34);return new ae(i,r)}}function se(t){return e.deriveAddress([e.dist.Buffer.from("sender")],t)}function oe(t){return e.deriveAddress([e.dist.Buffer.from("redeemer")],t)}function W(t){return e.deriveAddress([e.dist.Buffer.from("authority_signer")],t)}function D(t){return e.deriveAddress([e.dist.Buffer.from("custody_signer")],t)}function Q(t){return e.deriveAddress([e.dist.Buffer.from("mint_signer")],t)}function N(t,n,i){if(n==e.toChainId("Solana"))throw new Error("tokenChain == CHAIN_ID_SOLANA does not have wrapped mint key");return e.deriveAddress([e.dist.Buffer.from("wrapped"),(()=>{const r=e.dist.Buffer.alloc(2);return r.writeUInt16BE(n),r})(),i],t)}function E(t,n){return e.deriveAddress([e.dist.Buffer.from("meta"),new e.PublicKey(n).toBuffer()],t)}async function G(t,n,i,r){return t.getAccountInfo(E(n,i),r).then(a=>ce.deserialize(e.getAccountData(a)))}class ce{constructor(n,i,r,a){l(this,"chain");l(this,"tokenAddress");l(this,"originalDecimals");l(this,"lastUpdatedSequence");this.chain=n,this.tokenAddress=i,this.originalDecimals=r,this.lastUpdatedSequence=a}static deserialize(n){if(n.length!==35&&n.length!==43)throw new Error(`invalid wrapped meta length: ${n.length}`);const i=n.readUInt16LE(0),r=n.subarray(2,34),a=n.readUInt8(34),s=n.length===43?n.readBigUInt64LE(35):void 0;return new ce(i,r,a,s)}}function ge(t,n,i,r){return bt(new e.PublicKey(n),W(t),new e.PublicKey(i),r)}class fn{constructor(n){l(this,"idl");this.idl=n}async encode(n,i){switch(n){default:throw new Error(`Invalid account name: ${n}`)}}decode(n,i){return this.decodeUnchecked(n,i)}decodeUnchecked(n,i){switch(n){default:throw new Error(`Invalid account name: ${n}`)}}memcmp(n,i){switch(n){default:throw new Error(`Invalid account name: ${n}`)}}size(n){return e.accountSize(this.idl,n)??0}}class mn{constructor(n){}decode(n){throw new Error("Token Bridge program does not have events")}}class gn{constructor(n){}encode(n,i){switch(n){case"initialize":return hn(i);case"attestToken":return pn(i);case"completeNative":return yn(i);case"completeWrapped":return wn(i);case"transferWrapped":return Sn(i);case"transferNative":return An(i);case"registerChain":return Mn(i);case"createWrapped":return bn(i);case"upgradeContract":return kn(i);case"transferWrappedWithPayload":return Tn(i);case"transferNativeWithPayload":return Cn(i);default:throw new Error(`Invalid instruction: ${n}`)}}encodeState(n,i){throw new Error("Token Bridge program does not have state")}}var b;(function(t){t[t.Initialize=0]="Initialize",t[t.AttestToken=1]="AttestToken",t[t.CompleteNative=2]="CompleteNative",t[t.CompleteWrapped=3]="CompleteWrapped",t[t.TransferWrapped=4]="TransferWrapped",t[t.TransferNative=5]="TransferNative",t[t.RegisterChain=6]="RegisterChain",t[t.CreateWrapped=7]="CreateWrapped",t[t.UpgradeContract=8]="UpgradeContract",t[t.CompleteNativeWithPayload=9]="CompleteNativeWithPayload",t[t.CompleteWrappedWithPayload=10]="CompleteWrappedWithPayload",t[t.TransferWrappedWithPayload=11]="TransferWrappedWithPayload",t[t.TransferNativeWithPayload=12]="TransferNativeWithPayload"})(b||(b={}));function v(t,n){const i=n===void 0?0:n.length,r=e.dist.Buffer.alloc(1+i);return r.writeUInt8(t,0),i>0&&r.write(n.toString("hex"),1,"hex"),r}function hn({wormhole:t}){const n=e.dist.Buffer.alloc(32);return n.write(new e.PublicKey(t).toBuffer().toString("hex"),0,"hex"),v(b.Initialize,n)}function pn({nonce:t}){const n=e.dist.Buffer.alloc(4);return n.writeUInt32LE(t,0),v(b.AttestToken,n)}function yn({}){return v(b.CompleteNative)}function wn({}){return v(b.CompleteWrapped)}function Qe({nonce:t,amount:n,fee:i,targetAddress:r,targetChain:a}){if(typeof n!="bigint"&&(n=BigInt(n)),typeof i!="bigint"&&(i=BigInt(i)),!e.dist.Buffer.isBuffer(r))throw new Error("targetAddress must be Buffer");const s=e.dist.Buffer.alloc(54);return s.writeUInt32LE(t,0),s.writeBigUInt64LE(n,4),s.writeBigUInt64LE(i,12),s.write(r.toString("hex"),20,"hex"),s.writeUInt16LE(a,52),s}function Sn({nonce:t,amount:n,fee:i,targetAddress:r,targetChain:a}){return v(b.TransferWrapped,Qe({nonce:t,amount:n,fee:i,targetAddress:r,targetChain:a}))}function An({nonce:t,amount:n,fee:i,targetAddress:r,targetChain:a}){return v(b.TransferNative,Qe({nonce:t,amount:n,fee:i,targetAddress:r,targetChain:a}))}function Mn({}){return v(b.RegisterChain)}function bn({}){return v(b.CreateWrapped)}function kn({}){return v(b.UpgradeContract)}function Xe({nonce:t,amount:n,targetAddress:i,targetChain:r,payload:a}){if(typeof n!="bigint"&&(n=BigInt(n)),!e.dist.Buffer.isBuffer(i))throw new Error("targetAddress must be Buffer");if(!e.dist.Buffer.isBuffer(a))throw new Error("payload must be Buffer");const s=e.dist.Buffer.alloc(50);return s.writeUInt32LE(t,0),s.writeBigUInt64LE(n,4),s.write(i.toString("hex"),12,"hex"),s.writeUInt16LE(r,44),s.writeUInt32LE(a.length,46),e.dist.Buffer.concat([s,a,e.dist.Buffer.alloc(1)])}function Tn({nonce:t,amount:n,fee:i,targetAddress:r,targetChain:a,payload:s}){return v(b.TransferWrappedWithPayload,Xe({nonce:t,amount:n,targetAddress:r,targetChain:a,payload:s}))}function Cn({nonce:t,amount:n,fee:i,targetAddress:r,targetChain:a,payload:s}){return v(b.TransferNativeWithPayload,Xe({nonce:t,amount:n,targetAddress:r,targetChain:a,payload:s}))}class vn{constructor(n){}encode(n,i){throw new Error("Token Bridge program does not have state")}decode(n){throw new Error("Token Bridge program does not have state")}}class Pn{constructor(n){}encode(n,i){throw new Error("Token Bridge program does not have user-defined types")}decode(n,i){throw new Error("Token Bridge program does not have user-defined types")}}class Bn{constructor(n){l(this,"instruction");l(this,"accounts");l(this,"state");l(this,"events");l(this,"types");this.instruction=new gn(n),this.accounts=new fn(n),this.state=new vn(n),this.events=new mn(n),this.types=new Pn(n)}}const Pe={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 Je(t,n){return new e.Program(Pe,new e.PublicKey(t),n===void 0?{connection:null}:n,$e())}function k(t,n){return Je(t,e.createReadOnlyProvider(n))}function $e(){return new Bn(Pe)}const Y=class Y{constructor(n,i,r){l(this,"address");l(this,"verified");l(this,"share");this.address=new e.PublicKey(n),this.verified=i,this.share=r}serialize(){const n=e.dist.Buffer.alloc(Y.size);return n.write(this.address.toBuffer().toString("hex"),0,"hex"),this.verified&&n.writeUInt8(1,32),n.writeUInt8(this.share,33),n}static deserialize(n){const i=n.subarray(0,32),r=n.readUInt8(32)>0,a=n.readUInt8(33);return new Y(i,r,a)}};l(Y,"size",34);let I=Y;class X{constructor(n,i,r,a,s){l(this,"name");l(this,"symbol");l(this,"uri");l(this,"sellerFeeBasisPoints");l(this,"creators");this.name=n,this.symbol=i,this.uri=r,this.sellerFeeBasisPoints=a,this.creators=s}serialize(){const n=this.name.length,i=this.symbol.length,r=this.uri.length,a=this.creators,[s,c]=(()=>{if(a===null)return[0,0];const d=a.length;return[d,4+d*I.size]})(),o=e.dist.Buffer.alloc(15+n+i+r+c);if(o.writeUInt32LE(n,0),o.write(this.name,4),o.writeUInt32LE(i,4+n),o.write(this.symbol,8+n),o.writeUInt32LE(r,8+n+i),o.write(this.uri,12+n+i),o.writeUInt16LE(this.sellerFeeBasisPoints,12+n+i+r),a===null)o.writeUInt8(0,14+n+i+r);else{o.writeUInt8(1,14+n+i+r),o.writeUInt32LE(s,15+n+i+r);for(let d=0;d<s;++d){const u=a.at(d),f=19+n+i+r+d*I.size;o.write(u.serialize().toString("hex"),f,"hex")}}return o}static deserialize(n){const i=n.readUInt32LE(0),r=n.subarray(4,4+i).toString(),a=n.readUInt32LE(4+i),s=n.subarray(8+i,8+i+a).toString(),c=n.readUInt32LE(8+i+a),o=n.subarray(12+i+a,12+i+a+c).toString(),d=n.readUInt16LE(12+i+a+c),u=n.readUInt8(14+i+a+c),f=(()=>{if(u==0)return null;const g=[],m=n.readUInt32LE(15+i+a+c);for(let p=0;p<m;++p){const h=19+i+a+c+p*I.size;g.push(I.deserialize(n.subarray(h,h+I.size)))}return g})();return new X(r,s,o,d,f)}}class Z extends X{constructor(i,r,a,s,c,o){super(i,r,a,s,c);l(this,"isMutable");this.isMutable=o}static serialize(i,r,a,s,c,o){return new Z(i,r,a,s,c,o).serialize()}static serializeInstructionData(i,r,a,s,c,o){return e.dist.Buffer.concat([e.dist.Buffer.alloc(1,0),Z.serialize(i,r,a,s,c,o)])}serialize(){return e.dist.Buffer.concat([super.serialize(),e.dist.Buffer.alloc(1,this.isMutable?1:0)])}}const ee=class ee{constructor(){}static createMetadataAccounts(n,i,r,a,s,c,o=!1,d,u,f,g=!1,m=J(i)){const p=[e.newAccountMeta(m,!1),e.newReadOnlyAccountMeta(i,!1),e.newReadOnlyAccountMeta(r,!0),e.newReadOnlyAccountMeta(n,!0),e.newReadOnlyAccountMeta(c,o),e.newReadOnlyAccountMeta(e.SystemProgram.programId,!1),e.newReadOnlyAccountMeta(e.SYSVAR_RENT_PUBKEY,!1)],h=Z.serializeInstructionData(a,s,d===void 0?"":d,f===void 0?0:f,u===void 0?null:u,g);return{programId:ee.programId,keys:p,data:h}}};l(ee,"programId",new e.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"));let x=ee;function J(t){return e.deriveAddress([e.dist.Buffer.from("metadata"),x.programId.toBuffer(),new e.PublicKey(t).toBuffer()],x.programId)}exports.Key=void 0;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.EditionV1=1]="EditionV1",t[t.MasterEditionV1=2]="MasterEditionV1",t[t.ReservationListV1=3]="ReservationListV1",t[t.MetadataV1=4]="MetadataV1",t[t.ReservationListV2=5]="ReservationListV2",t[t.MasterEditionV2=6]="MasterEditionV2",t[t.EditionMarker=7]="EditionMarker"})(exports.Key||(exports.Key={}));class ue{constructor(n,i,r,a,s,c){l(this,"key");l(this,"updateAuthority");l(this,"mint");l(this,"data");l(this,"primarySaleHappened");l(this,"isMutable");this.key=n,this.updateAuthority=new e.PublicKey(i),this.mint=new e.PublicKey(r),this.data=a,this.primarySaleHappened=s,this.isMutable=c}static deserialize(n){const i=n.readUInt8(0),r=n.subarray(1,33),a=n.subarray(33,65),s=X.deserialize(n.subarray(65)),c=s.serialize().length,o=n.readUInt8(65+c)>0,d=n.readUInt8(66+c)>0;return new ue(i,r,a,s,o,d)}}async function Rn(t,n,i){return t.getAccountInfo(J(n),i).then(r=>ue.deserialize(e.getAccountData(r)))}function je(t,n,i,r,a,s,c){const o=k(n,t).methods.attestToken(c);return console.log(he(n,i,r,a,s)),o._ixFn(...o._args,{accounts:he(n,i,r,a,s),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function he(t,n,i,r,a){const{bridge:s,emitter:c,sequence:o,feeCollector:d,clock:u,rent:f,systemProgram:g}=e.getPostMessageAccounts(n,i,a,t);return{payer:new e.PublicKey(i),config:A(t),mint:new e.PublicKey(r),wrappedMeta:E(t,r),splMetadata:J(r),wormholeBridge:s,wormholeMessage:new e.PublicKey(a),wormholeEmitter:c,wormholeSequence:o,wormholeFeeCollector:d,clock:u,rent:f,systemProgram:g,wormholeProgram:new e.PublicKey(n)}}function pe(t,n,i,r,a,s){const c=k(n,t).methods.completeNative();return c._ixFn(...c._args,{accounts:et(n,i,r,a,s),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function et(t,n,i,r,a){const s=new e.PublicKey(r.payload.token.address.toUint8Array());return{payer:new e.PublicKey(i),config:A(t),vaa:e.derivePostedVaaKey(n,e.dist.Buffer.from(r.hash)),claim:e.deriveClaimKey(t,r.emitterAddress.toUint8Array(),e.toChainId(r.emitterChain),r.sequence),endpoint:K(t,e.toChainId(r.emitterChain),r.emitterAddress.toUint8Array()),to:new e.PublicKey(r.payload.to.address.toUint8Array()),toFees:new e.PublicKey(a===void 0?r.payload.to.address.toUint8Array():a),custody:H(t,s),mint:s,custodySigner:D(t),rent:e.SYSVAR_RENT_PUBKEY,systemProgram:e.SystemProgram.programId,tokenProgram:y,wormholeProgram:new e.PublicKey(n)}}function tt(t,n,i,r,a,s){const c=k(n,t).methods.completeWrapped();return c._ixFn(...c._args,{accounts:nt(n,i,r,a,s),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function nt(t,n,i,r,a){const s=N(t,e.toChainId(r.payload.token.chain),r.payload.token.address.toUint8Array());return{payer:new e.PublicKey(i),config:A(t),vaa:e.derivePostedVaaKey(n,e.dist.Buffer.from(r.hash)),claim:e.deriveClaimKey(t,r.emitterAddress.toUint8Array(),e.toChainId(r.emitterChain),r.sequence),endpoint:K(t,e.toChainId(r.emitterChain),r.emitterAddress.toUint8Array()),to:new e.PublicKey(r.payload.to.address.toUint8Array()),toFees:new e.PublicKey(a===void 0?r.payload.to.address.toUint8Array():a),mint:s,wrappedMeta:E(t,s),mintAuthority:Q(t),rent:e.SYSVAR_RENT_PUBKEY,systemProgram:e.SystemProgram.programId,tokenProgram:y,wormholeProgram:new e.PublicKey(n)}}function rt(t,n,i,r,a){const s=k(n,t).methods.createWrapped();return s._ixFn(...s._args,{accounts:it(n,i,r,a),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function it(t,n,i,r){const a=N(t,e.toChainId(r.payload.token.chain),r.payload.token.address.toUint8Array());return{payer:new e.PublicKey(i),config:A(t),endpoint:K(t,e.toChainId(r.emitterChain),r.emitterAddress.toUint8Array()),vaa:e.derivePostedVaaKey(n,e.dist.Buffer.from(r.hash)),claim:e.deriveClaimKey(t,r.emitterAddress.toUint8Array(),e.toChainId(r.emitterChain),r.sequence),mint:a,wrappedMeta:E(t,a),splMetadata:J(a),mintAuthority:Q(t),rent:e.SYSVAR_RENT_PUBKEY,systemProgram:e.SystemProgram.programId,tokenProgram:y,splMetadataProgram:x.programId,wormholeProgram:new e.PublicKey(n)}}function In(t,n,i){const r=k(t).methods.initialize(i);return r._ixFn(...r._args,{accounts:at(t,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function at(t,n){return{payer:new e.PublicKey(n),config:A(t),rent:e.SYSVAR_RENT_PUBKEY,systemProgram:e.SystemProgram.programId}}function En(t,n,i,r){const a=k(t).methods.registerChain();return a._ixFn(...a._args,{accounts:st(t,n,i,r),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function st(t,n,i,r){return{payer:new e.PublicKey(i),config:A(t),endpoint:K(t,e.toChainId(r.payload.actionArgs.foreignChain),r.payload.actionArgs.foreignAddress.toUint8Array()),vaa:e.derivePostedVaaKey(n,e.dist.Buffer.from(r.hash)),claim:e.deriveClaimKey(t,r.emitterAddress.toUint8Array(),e.toChainId(r.emitterChain),r.sequence),rent:e.SYSVAR_RENT_PUBKEY,systemProgram:e.SystemProgram.programId,wormholeProgram:new e.PublicKey(n)}}function _n(t,n,i,r,a){const s=k(t).methods.upgradeContract();return s._ixFn(...s._args,{accounts:ot(t,n,i,r,a),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function ot(t,n,i,r,a){return{payer:new e.PublicKey(i),vaa:e.derivePostedVaaKey(n,e.dist.Buffer.from(r.hash)),claim:e.deriveClaimKey(t,r.emitterAddress.toUint8Array(),e.toChainId(r.emitterChain),r.sequence),upgradeAuthority:e.deriveUpgradeAuthorityKey(t),spill:new e.PublicKey(a===void 0?i:a),implementation:new e.PublicKey(r.payload.actionArgs.newContract),programData:e.deriveProgramDataAddress(t),tokenBridgeProgram:new e.PublicKey(t),rent:e.SYSVAR_RENT_PUBKEY,clock:e.SYSVAR_CLOCK_PUBKEY,bpfLoaderUpgradeable:e.BPF_LOADER_UPGRADEABLE_PROGRAM_ID,systemProgram:e.SystemProgram.programId}}function ye(t,n,i,r,a,s,c,o,d,u,f,g){const m=k(n,t).methods.transferNative(o,d,u,e.dist.Buffer.from(f),g);return m._ixFn(...m._args,{accounts:ct(n,i,r,a,s,c),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function ct(t,n,i,r,a,s){const{wormholeBridge:c,wormholeMessage:o,wormholeEmitter:d,wormholeSequence:u,wormholeFeeCollector:f,clock:g,rent:m,systemProgram:p}=e.getPostMessageCpiAccounts(t,n,i,r);return{payer:new e.PublicKey(i),config:A(t),from:new e.PublicKey(a),mint:new e.PublicKey(s),custody:H(t,s),authoritySigner:W(t),custodySigner:D(t),wormholeBridge:c,wormholeMessage:o,wormholeEmitter:d,wormholeSequence:u,wormholeFeeCollector:f,clock:g,rent:m,systemProgram:p,tokenProgram:y,wormholeProgram:new e.PublicKey(n)}}function we(t,n,i,r,a,s,c,o,d,u,f,g){const m=k(n,t).methods.transferNativeWithPayload(o,d,e.dist.Buffer.from(u),f,e.dist.Buffer.from(g),null);return m._ixFn(...m._args,{accounts:Be(n,i,r,a,s,c),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function Be(t,n,i,r,a,s,c){const{wormholeBridge:o,wormholeMessage:d,wormholeEmitter:u,wormholeSequence:f,wormholeFeeCollector:g,clock:m,rent:p,systemProgram:h}=e.getPostMessageCpiAccounts(t,n,i,r);return{payer:new e.PublicKey(i),config:A(t),from:new e.PublicKey(a),mint:new e.PublicKey(s),custody:H(t,s),authoritySigner:W(t),custodySigner:D(t),wormholeBridge:o,wormholeMessage:d,wormholeEmitter:u,wormholeSequence:f,wormholeFeeCollector:g,clock:m,sender:new e.PublicKey(c===void 0?i:se(c)),rent:p,systemProgram:h,tokenProgram:y,wormholeProgram:new e.PublicKey(n)}}function ut(t,n,i,r,a,s,c,o,d,u,f,g,m,p){const h=k(n,t).methods.transferWrapped(u,f,g,e.dist.Buffer.from(m),p);return h._ixFn(...h._args,{accounts:dt(n,i,r,a,s,c,o,d),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function dt(t,n,i,r,a,s,c,o){const d=N(t,c,o),{wormholeBridge:u,wormholeMessage:f,wormholeEmitter:g,wormholeSequence:m,wormholeFeeCollector:p,clock:h,rent:S,systemProgram:M}=e.getPostMessageCpiAccounts(t,n,i,r);return{payer:new e.PublicKey(i),config:A(t),from:new e.PublicKey(a),fromOwner:new e.PublicKey(s),mint:d,wrappedMeta:E(t,d),authoritySigner:W(t),wormholeBridge:u,wormholeMessage:f,wormholeEmitter:g,wormholeSequence:m,wormholeFeeCollector:p,clock:h,rent:S,systemProgram:M,wormholeProgram:new e.PublicKey(n),tokenProgram:y}}function lt(t,n,i,r,a,s,c,o,d,u,f,g,m,p){const h=k(n,t).methods.transferWrappedWithPayload(u,f,e.dist.Buffer.from(g),m,e.dist.Buffer.from(p),null);return h._ixFn(...h._args,{accounts:Re(n,i,r,a,s,c,o,d),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function Re(t,n,i,r,a,s,c,o,d){const u=N(t,c,o),{wormholeBridge:f,wormholeMessage:g,wormholeEmitter:m,wormholeSequence:p,wormholeFeeCollector:h,clock:S,rent:M,systemProgram:P}=e.getPostMessageCpiAccounts(t,n,i,r);return{payer:new e.PublicKey(i),config:A(t),from:new e.PublicKey(a),fromOwner:new e.PublicKey(s),mint:u,wrappedMeta:E(t,u),authoritySigner:W(t),wormholeBridge:f,wormholeMessage:g,wormholeEmitter:m,wormholeSequence:p,wormholeFeeCollector:h,clock:S,sender:new e.PublicKey(d===void 0?i:se(d)),rent:M,systemProgram:P,wormholeProgram:new e.PublicKey(n),tokenProgram:y}}function Kn(t,n,i){const{wormholeEmitter:r,wormholeBridge:a,wormholeFeeCollector:s,wormholeSequence:c}=e.getWormholeDerivedAccounts(n,i);return{tokenBridgeConfig:A(n),tokenBridgeAuthoritySigner:W(n),tokenBridgeCustodySigner:D(n),tokenBridgeMintAuthority:Q(n),tokenBridgeSender:se(t),tokenBridgeRedeemer:oe(t),wormholeBridge:a,tokenBridgeEmitter:r,wormholeFeeCollector:s,tokenBridgeSequence:c}}function ft(t,n,i,r,a,s,c){const o=Be(n,i,r,a,s,c,t);return{payer:o.payer,tokenBridgeConfig:o.config,fromTokenAccount:o.from,mint:o.mint,tokenBridgeCustody:o.custody,tokenBridgeAuthoritySigner:o.authoritySigner,tokenBridgeCustodySigner:o.custodySigner,wormholeBridge:o.wormholeBridge,wormholeMessage:o.wormholeMessage,tokenBridgeEmitter:o.wormholeEmitter,tokenBridgeSequence:o.wormholeSequence,wormholeFeeCollector:o.wormholeFeeCollector,clock:o.clock,tokenBridgeSender:o.sender,rent:o.rent,systemProgram:o.systemProgram,tokenProgram:o.tokenProgram,wormholeProgram:o.wormholeProgram}}function mt(t,n,i,r,a,s,c,o,d){const u=Re(n,i,r,a,s,d===void 0?t:d,c,o,t);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 Wn(t,n,i,r,a){const s=new e.PublicKey(r.payload.token.address.toUint8Array()),c=new e.PublicKey(r.payload.to.address.toUint8Array());return{payer:new e.PublicKey(i),tokenBridgeConfig:A(t),vaa:e.derivePostedVaaKey(n,e.dist.Buffer.from(r.hash)),tokenBridgeClaim:e.deriveClaimKey(t,r.emitterAddress.toUint8Array(),e.toChainId(r.emitterChain),r.sequence),tokenBridgeForeignEndpoint:K(t,e.toChainId(r.emitterChain),r.emitterAddress.toUint8Array()),toTokenAccount:new e.PublicKey(a),tokenBridgeRedeemer:oe(c),toFeesTokenAccount:new e.PublicKey(a),tokenBridgeCustody:H(t,s),mint:s,tokenBridgeCustodySigner:D(t),rent:e.SYSVAR_RENT_PUBKEY,systemProgram:e.SystemProgram.programId,tokenProgram:y,wormholeProgram:new e.PublicKey(n)}}function Nn(t,n,i,r,a){const s=N(t,e.toChainId(r.payload.token.chain),r.payload.token.address.toUint8Array()),c=new e.PublicKey(r.payload.to.address.toUint8Array());return{payer:new e.PublicKey(i),tokenBridgeConfig:A(t),vaa:e.derivePostedVaaKey(n,e.dist.Buffer.from(r.hash)),tokenBridgeClaim:e.deriveClaimKey(t,r.emitterAddress.toUint8Array(),e.toChainId(r.emitterChain),r.sequence),tokenBridgeForeignEndpoint:K(t,e.toChainId(r.emitterChain),r.emitterAddress.toUint8Array()),toTokenAccount:new e.PublicKey(a),tokenBridgeRedeemer:oe(c),toFeesTokenAccount:new e.PublicKey(a),tokenBridgeWrappedMint:s,tokenBridgeWrappedMeta:E(t,s),tokenBridgeMintAuthority:Q(t),rent:e.SYSVAR_RENT_PUBKEY,systemProgram:e.SystemProgram.programId,tokenProgram:y,wormholeProgram:new e.PublicKey(n)}}const gt={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(t,n){return new e.Program(gt,new e.PublicKey(t),{connection:n})}function ht(t,n){return e.deriveAddress([e.dist.Buffer.from("seq"),new e.PublicKey(n).toBuffer()],t)}async function pt(t,n,i,r,a,s,c,o,d,u,f,g){const{methods:{transferNativeTokensWithRelay:m},account:{signerSequence:p}}=de(n,t),h=ht(n,i),S=await p.fetch(h).then(({value:B})=>B).catch(B=>{var _;if((_=B.message)!=null&&_.includes("Account does not exist"))return new e.BN(0);throw B}),M=ve(n,i,S),P=ke(new e.PublicKey(s),new e.PublicKey(i)),C=Ce(n,s),L=ft(n,r,a,i,M,P,s);return m(new e.BN(c.toString()),new e.BN(o.toString()),e.toChainId(u),[...d],f,g).accounts({config:Te(n),payerSequence:h,foreignContract:ne(n,u),registeredToken:re(n,s),tmpTokenAccount:C,tokenBridgeProgram:new e.PublicKey(r),...L}).instruction()}async function yt(t,n,i,r,a,s,c,o,d,u,f){const{methods:{transferWrappedTokensWithRelay:g},account:{signerSequence:m}}=de(n,t),p=ht(n,i),h=await m.fetch(p).then(({value:_})=>_).catch(_=>{var Ie;if((Ie=_.message)!=null&&Ie.includes("Account does not exist"))return new e.BN(0);throw _}),S=ve(n,i,h),M=ke(new e.PublicKey(s),new e.PublicKey(i)),{chain:P,tokenAddress:C}=await G(t,r,s),L=Ce(n,s),B=mt(n,r,a,i,S,M,P,C);return g(new e.BN(c.toString()),new e.BN(o.toString()),e.toChainId(u),[...d],f).accounts({config:Te(n),payerSequence:p,foreignContract:ne(n,u),registeredToken:re(n,new e.PublicKey(s)),tmpTokenAccount:L,tokenBridgeProgram:new e.PublicKey(r),...B}).instruction()}class le{constructor(n,i,r,a){l(this,"network");l(this,"chain");l(this,"connection");l(this,"contracts");l(this,"chainId");l(this,"coreBridge");l(this,"tokenBridge");this.network=n,this.chain=i,this.connection=r,this.contracts=a,this.chainId=e.toChainId(i);const s=a.tokenBridge;if(!s)throw new Error(`TokenBridge contract Address for chain ${i} not found`);this.tokenBridge=k(s,r),this.coreBridge=new e.SolanaWormholeCore(n,i,r,a)}static async fromRpc(n,i){const[r,a]=await e.SolanaPlatform.chainFromRpc(n),s=i[a];if(s.network!==r)throw new Error(`Network mismatch for chain ${a}: ${s.network} != ${r}`);return new le(r,a,n,s.contracts)}async isWrappedAsset(n){return G(this.connection,this.tokenBridge.programId,new e.SolanaAddress(n).toUint8Array()).catch(i=>null).then(i=>i!=null)}async getOriginalAsset(n){if(!await this.isWrappedAsset(n))throw e.ErrNotWrapped(n.toString());const i=new e.SolanaAddress(n).toUint8Array(),r=new e.PublicKey(i);try{const a=await G(this.connection,this.tokenBridge.programId,i);return a===null?{chain:this.chain,address:new e.SolanaAddress(r.toBytes()).toUniversalAddress()}:{chain:e.toChain(a.chain),address:new e.UniversalAddress(new Uint8Array(a.tokenAddress))}}catch{throw e.ErrNotWrapped(n.toString())}}async getTokenUniversalAddress(n){return new e.SolanaAddress(n).toUniversalAddress()}async getTokenNativeAddress(n,i){return new e.SolanaAddress(i).toNative()}async hasWrappedAsset(n){try{return await this.getWrappedAsset(n),!0}catch{}return!1}async getWrappedAsset(n){if(e.isNative(n.address))throw new Error("Native cannot be a wrapped asset");const i=N(this.tokenBridge.programId,e.toChainId(n.chain),n.address.toUniversalAddress().toUint8Array());try{return await G(this.connection,this.tokenBridge.programId,i),e.toNative(this.chain,i.toBase58())}catch{}throw e.ErrNotWrapped(`${i}: ${n.address.toUniversalAddress().toString()}`)}async isTransferCompleted(n){return e.getClaim(this.connection,this.tokenBridge.programId,n.emitterAddress.toUint8Array(),e.toChainId(n.emitterChain),n.sequence,this.connection.commitment).catch(()=>!1)}async getWrappedNative(){return e.toNative(this.chain,R.toBase58())}async*createAttestation(n,i){if(!i)throw new Error("Payer required to create attestation");const r=new e.SolanaAddress(i).unwrap(),a=0,s=await this.coreBridge.getMessageFee(),c=e.createBridgeFeeTransferInstruction(this.coreBridge.coreBridge.programId,r,s),o=e.Keypair.generate(),d=je(this.connection,this.tokenBridge.programId,this.coreBridge.address,r,new e.SolanaAddress(n).unwrap(),o.publicKey,a),u=new e.Transaction().add(c,d);u.feePayer=r,yield this.createUnsignedTx({transaction:u,signers:[o]},"Solana.AttestToken")}async*submitAttestation(n,i){if(!i)throw new Error("Payer required to create attestation");const r=new e.SolanaAddress(i).unwrap();yield*this.coreBridge.postVaa(r,n);const a=new e.Transaction().add(rt(this.connection,this.tokenBridge.programId,this.coreBridge.address,r,n));a.feePayer=r,yield this.createUnsignedTx({transaction:a},"Solana.CreateWrapped")}async transferSol(n,i,r,a){const s=new e.SolanaAddress(n).unwrap(),c=s,o=i.address.toUniversalAddress().toUint8Array(),d=e.toChainId(i.chain),u=0,f=0n,g=e.Keypair.generate(),m=e.Keypair.generate(),p=await We(this.connection),h=e.SystemProgram.createAccount({fromPubkey:c,newAccountPubkey:m.publicKey,lamports:p,space:T,programId:y}),S=e.SystemProgram.transfer({fromPubkey:c,lamports:r,toPubkey:m.publicKey}),M=ze(m.publicKey,R,c),P=ge(this.tokenBridge.programId,m.publicKey,c,r),C=a?we(this.connection,this.tokenBridge.programId,this.coreBridge.address,s,g.publicKey,m.publicKey,R,u,r,o,d,a):ye(this.connection,this.tokenBridge.programId,this.coreBridge.address,s,g.publicKey,m.publicKey,R,u,r,f,o,d),L=Ke(m.publicKey,c,c),B=new e.Transaction;return B.feePayer=c,B.add(h,S,M,P,C,L),this.createUnsignedTx({transaction:B,signers:[g,m]},"TokenBridge.TransferNative")}async*transfer(n,i,r,a,s){if(e.isNative(r)){yield await this.transferSol(n,i,a,s);return}const c=new e.SolanaAddress(r).unwrap(),o=new e.SolanaAddress(n).unwrap(),d=await Ne(c,o),u=i.address.toUniversalAddress().toUint8Array(),f=e.toChainId(i.chain),g=0,m=0n,p=!await this.isWrappedAsset(r),h=e.Keypair.generate();let S;if(p)S=s?we(this.connection,this.tokenBridge.programId,this.coreBridge.address,o,h.publicKey,d,c,g,a,u,f,s):ye(this.connection,this.tokenBridge.programId,this.coreBridge.address,o,h.publicKey,d,c,g,a,m,u,f);else{const C=await this.getOriginalAsset(r);if(e.isNative(C.address))throw new Error("Native cannot be an original asset");S=s?lt(this.connection,this.tokenBridge.programId,this.coreBridge.address,o,h.publicKey,d,o,e.toChainId(C.chain),C.address.toUint8Array(),g,a,u,f,s):ut(this.connection,this.tokenBridge.programId,this.coreBridge.address,o,h.publicKey,d,o,e.toChainId(C.chain),C.address.toUint8Array(),g,a,m,u,f)}const M=ge(this.tokenBridge.programId,d,o,a),P=new e.Transaction().add(M,S);P.feePayer=o,yield this.createUnsignedTx({transaction:P,signers:[h]},"TokenBridge.TransferTokens")}async*redeemAndUnwrap(n,i){const r=new e.SolanaAddress(n).unwrap(),a=new e.SolanaAddress(i.payload.to.address).unwrap(),s=await Pt(this.connection,R).then(h=>i.payload.token.amount*BigInt(Math.pow(10,h.decimals-8))),c=await We(this.connection),o=e.Keypair.generate(),d=pe(this.connection,this.tokenBridge.programId,this.coreBridge.address,r,i),u=e.SystemProgram.createAccount({fromPubkey:r,newAccountPubkey:o.publicKey,lamports:c,space:T,programId:y}),f=ze(o.publicKey,R,r),g=un(a,o.publicKey,r,s.valueOf()),m=Ke(o.publicKey,r,r),p=new e.Transaction;p.feePayer=r,p.add(d,u,f,g,m),yield this.createUnsignedTx({transaction:p,signers:[o]},"TokenBridge.RedeemAndUnwrap")}async*createAta(n,i){const r=new e.SolanaAddress(n).unwrap(),a=new e.SolanaAddress(i).unwrap(),s=await Ne(a,r);if(await this.connection.getAccountInfo(s)===null){const o=new e.Transaction().add(Ze(r,s,r,a));o.feePayer=r,yield this.createUnsignedTx({transaction:o},"Redeem.CreateATA")}}async*redeem(n,i,r=!0){const a=i.payload.token.chain===this.chain?i.payload.token.address:(await this.getWrappedAsset(i.payload.token)).toUniversalAddress();if(yield*this.createAta(n,a),yield*this.coreBridge.postVaa(n,i),r){const d=new e.SolanaAddress(await this.getWrappedNative());if(e.bytes.equals(a.toUint8Array(),d.toUint8Array())){yield*this.redeemAndUnwrap(n,i);return}}const s=new e.SolanaAddress(n).unwrap(),c=i.payload.token.chain==this.chain?pe:tt,o=new e.Transaction().add(c(this.connection,this.tokenBridge.programId,this.coreBridge.address,s,i));o.feePayer=s,yield this.createUnsignedTx({transaction:o},"Solana.RedeemTransfer")}createUnsignedTx(n,i,r=!1){return new e.SolanaUnsignedTransaction(n,this.network,this.chain,i,r)}}const Un={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:[]},U=9,q=new e.BN(10),F=new e.BN(1e8);class fe{constructor(n,i,r,a){l(this,"network");l(this,"chain");l(this,"connection");l(this,"contracts");l(this,"chainId");l(this,"coreBridgeProgramId");l(this,"tokenBridgeProgramId");l(this,"tokenBridgeRelayer");this.network=n,this.chain=i,this.connection=r,this.contracts=a,this.chainId=e.toChainId(i);const s=a.tokenBridgeRelayer;if(!s)throw new Error(`TokenBridge contract Address for chain ${i} not found`);this.tokenBridgeRelayer=de(s,r),this.tokenBridgeProgramId=new e.PublicKey(a.tokenBridge),this.coreBridgeProgramId=new e.PublicKey(a.coreBridge)}static async fromRpc(n,i){const[r,a]=await e.SolanaPlatform.chainFromRpc(n),s=i[a];if(s.network!==r)throw new Error(`Network mismatch for chain ${a}: ${s.network} != ${r}`);return new fe(r,a,n,s.contracts)}async*transfer(n,i,r,a,s){const o=new e.SolanaAddress(n).unwrap(),d=i.address.toUniversalAddress().toUint8Array(),u=this.mintAddress(r),f=new e.Transaction;if(e.isNative(r)){const h=ke(u,o);try{await Tt(this.connection,h)}catch(S){if(S instanceof Se){const M=Ze(o,h,o,u);f.add(M)}else throw S}}const g=s||0n,m=e.isNative(r),p=m?await pt(this.connection,this.tokenBridgeRelayer.programId,o,this.tokenBridgeProgramId,this.coreBridgeProgramId,u,a,g,d,i.chain,0,m):await yt(this.connection,this.tokenBridgeRelayer.programId,o,this.tokenBridgeProgramId,this.coreBridgeProgramId,u,a,g,d,i.chain,0);f.add(p),f.feePayer=o,yield this.createUnsignedTx({transaction:f},"AutomaticTokenBridge.Transfer")}async*redeem(n,i){const r=new e.Transaction;throw yield this.createUnsignedTx({transaction:r},"AutomaticTokenBridge.Redeem"),new Error("Method not implemented.")}async getRelayerFee(n,i){const r=this.mintAddress(i),[{fee:a},{swapRate:s},{relayerFeePrecision:c}]=await Promise.all([this.getForeignContract(n),this.getRegisteredToken(r),this.getRedeemerConfig()]),o=Number(await e.SolanaPlatform.getDecimals(this.chain,this.connection,i)),d=q.pow(new e.BN(o)).mul(a).mul(F).div(new e.BN(c).mul(s));return BigInt(d.toString())}async maxSwapAmount(n){const i=this.mintAddress(n),[{swapRate:r,maxNativeSwapAmount:a},{swapRate:s}]=await Promise.all([this.getRegisteredToken(i),this.getRegisteredToken(R)]),c=Number(await e.SolanaPlatform.getDecimals(this.chain,this.connection,n)),o=this.calculateNativeSwapRate(s,r),d=c>U?a.mul(o).mul(q.pow(new e.BN(c-U))).div(F):a.mul(o).div(q.pow(new e.BN(U-c)).mul(F));return BigInt(d.toString())}async nativeTokenAmount(n,i){if(i===0n)return 0n;const r=this.mintAddress(n),a=Number(await e.SolanaPlatform.getDecimals(this.chain,this.connection,n)),[{swapRate:s},{swapRate:c}]=await Promise.all([this.getRegisteredToken(r),this.getRegisteredToken(R)]),o=this.calculateNativeSwapRate(c,s),d=a>U?F.mul(new e.BN(i.toString())).div(o.mul(q.pow(new e.BN(a-U)))):F.mul(new e.BN(i.toString())).mul(q.pow(new e.BN(U-a))).div(o);return BigInt(d.toString())}async isRegisteredToken(n){var r;const i=this.mintAddress(n);try{return await this.getRegisteredToken(i),!0}catch(a){if((r=a.message)!=null&&r.includes("Account does not exist"))return!1;throw a}}mintAddress(n){return e.isNative(n)?new e.PublicKey(R):new e.SolanaAddress(n).unwrap()}async getRegisteredTokens(){return Un[this.network].map(n=>e.toNative(this.chain,n))}calculateNativeSwapRate(n,i){return F.mul(n).div(i)}async getForeignContract(n){return await this.tokenBridgeRelayer.account.foreignContract.fetch(ne(this.tokenBridgeRelayer.programId,n))}async getRegisteredToken(n){return await this.tokenBridgeRelayer.account.registeredToken.fetch(re(this.tokenBridgeRelayer.programId,n))}async getRedeemerConfig(){return await this.tokenBridgeRelayer.account.redeemerConfig.fetch(He(this.tokenBridgeRelayer.programId))}createUnsignedTx(n,i,r=!1){return new e.SolanaUnsignedTransaction(n,this.network,this.chain,i,r)}}e.registerProtocol(e._platform$1,"TokenBridge",le);e.registerProtocol(e._platform$1,"AutomaticTokenBridge",fe);exports.CreateMetadataAccountArgs=Z;exports.Creator=I;exports.Data=X;exports.EndpointRegistration=ae;exports.Metadata=ue;exports.SolanaAutomaticTokenBridge=fe;exports.SolanaTokenBridge=le;exports.SplTokenMetadataProgram=x;exports.TOKEN_BRIDGE_IDL=Pe;exports.TOKEN_BRIDGE_RELAYER_IDL=gt;exports.TokenBridgeConfig=ie;exports.WrappedMeta=ce;exports.coder=$e;exports.createApproveAuthoritySignerInstruction=ge;exports.createAttestTokenInstruction=je;exports.createCompleteTransferNativeInstruction=pe;exports.createCompleteTransferWrappedInstruction=tt;exports.createCreateWrappedInstruction=rt;exports.createInitializeInstruction=In;exports.createReadOnlyTokenBridgeProgramInterface=k;exports.createRegisterChainInstruction=En;exports.createTokenBridgeProgramInterface=Je;exports.createTokenBridgeRelayerProgramInterface=de;exports.createTransferNativeInstruction=ye;exports.createTransferNativeTokensWithRelayInstruction=pt;exports.createTransferNativeWithPayloadInstruction=we;exports.createTransferWrappedInstruction=ut;exports.createTransferWrappedTokensWithRelayInstruction=yt;exports.createTransferWrappedWithPayloadInstruction=lt;exports.createUpgradeContractInstruction=_n;exports.deriveAuthoritySignerKey=W;exports.deriveCustodyKey=H;exports.deriveCustodySignerKey=D;exports.deriveEndpointKey=K;exports.deriveForeignContractAddress=ne;exports.deriveMintAuthorityKey=Q;exports.deriveRedeemerAccountKey=oe;exports.deriveRedeemerConfigAddress=He;exports.deriveRegisteredTokenAddress=re;exports.deriveSenderAccountKey=se;exports.deriveSenderConfigAddress=Te;exports.deriveSplTokenMetadataKey=J;exports.deriveTmpTokenAccountAddress=Ce;exports.deriveTokenBridgeConfigKey=A;exports.deriveTokenTransferMessageAddress=ve;exports.deriveWrappedMetaKey=E;exports.deriveWrappedMintKey=N;exports.getAttestTokenAccounts=he;exports.getCompleteTransferNativeAccounts=et;exports.getCompleteTransferNativeWithPayloadCpiAccounts=Wn;exports.getCompleteTransferWrappedAccounts=nt;exports.getCompleteTransferWrappedWithPayloadCpiAccounts=Nn;exports.getCreateWrappedAccounts=it;exports.getEndpointRegistration=ln;exports.getInitializeAccounts=at;exports.getMetadata=Rn;exports.getRegisterChainAccounts=st;exports.getTokenBridgeConfig=dn;exports.getTokenBridgeDerivedAccounts=Kn;exports.getTransferNativeAccounts=ct;exports.getTransferNativeWithPayloadAccounts=Be;exports.getTransferNativeWithPayloadCpiAccounts=ft;exports.getTransferWrappedAccounts=dt;exports.getTransferWrappedWithPayloadAccounts=Re;exports.getTransferWrappedWithPayloadCpiAccounts=mt;exports.getUpgradeContractAccounts=ot;exports.getWrappedMeta=G;
|
|
1
|
+
"use strict";var wt=Object.defineProperty;var St=(t,n,i)=>n in t?wt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i;var l=(t,n,i)=>St(t,typeof n!="symbol"?n+"":n,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BEhe2aRM.js"),y=new e.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");new e.PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");const te=new e.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),R=new e.PublicKey("So11111111111111111111111111111111111111112");new e.PublicKey("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP");class z extends Error{constructor(n){super(n)}}class Se extends z{constructor(){super(...arguments),this.name="TokenAccountNotFoundError"}}class At extends z{constructor(){super(...arguments),this.name="TokenInvalidAccountError"}}class Le extends z{constructor(){super(...arguments),this.name="TokenInvalidAccountOwnerError"}}class V extends z{constructor(){super(...arguments),this.name="TokenInvalidAccountSizeError"}}class Mt extends z{constructor(){super(...arguments),this.name="TokenInvalidMintError"}}class qe extends z{constructor(){super(...arguments),this.name="TokenOwnerOffCurveError"}}var O;(function(t){t[t.InitializeMint=0]="InitializeMint",t[t.InitializeAccount=1]="InitializeAccount",t[t.InitializeMultisig=2]="InitializeMultisig",t[t.Transfer=3]="Transfer",t[t.Approve=4]="Approve",t[t.Revoke=5]="Revoke",t[t.SetAuthority=6]="SetAuthority",t[t.MintTo=7]="MintTo",t[t.Burn=8]="Burn",t[t.CloseAccount=9]="CloseAccount",t[t.FreezeAccount=10]="FreezeAccount",t[t.ThawAccount=11]="ThawAccount",t[t.TransferChecked=12]="TransferChecked",t[t.ApproveChecked=13]="ApproveChecked",t[t.MintToChecked=14]="MintToChecked",t[t.BurnChecked=15]="BurnChecked",t[t.InitializeAccount2=16]="InitializeAccount2",t[t.SyncNative=17]="SyncNative",t[t.InitializeAccount3=18]="InitializeAccount3",t[t.InitializeMultisig2=19]="InitializeMultisig2",t[t.InitializeMint2=20]="InitializeMint2",t[t.GetAccountDataSize=21]="GetAccountDataSize",t[t.InitializeImmutableOwner=22]="InitializeImmutableOwner",t[t.AmountToUiAmount=23]="AmountToUiAmount",t[t.UiAmountToAmount=24]="UiAmountToAmount",t[t.InitializeMintCloseAuthority=25]="InitializeMintCloseAuthority",t[t.TransferFeeExtension=26]="TransferFeeExtension",t[t.ConfidentialTransferExtension=27]="ConfidentialTransferExtension",t[t.DefaultAccountStateExtension=28]="DefaultAccountStateExtension",t[t.Reallocate=29]="Reallocate",t[t.MemoTransferExtension=30]="MemoTransferExtension",t[t.CreateNativeMint=31]="CreateNativeMint",t[t.InitializeNonTransferableMint=32]="InitializeNonTransferableMint",t[t.InterestBearingMintExtension=33]="InterestBearingMintExtension",t[t.CpiGuardExtension=34]="CpiGuardExtension",t[t.InitializePermanentDelegate=35]="InitializePermanentDelegate",t[t.TransferHookExtension=36]="TransferHookExtension",t[t.MetadataPointerExtension=39]="MetadataPointerExtension"})(O||(O={}));function Ae(t,n,i){if(i.length){t.push({pubkey:n,isSigner:!1,isWritable:!1});for(const r of i)t.push({pubkey:r instanceof e.PublicKey?r:r.publicKey,isSigner:!0,isWritable:!1})}else t.push({pubkey:n,isSigner:!0,isWritable:!1});return t}const Ee=e.struct([e.u8("instruction"),e.u64("amount")]);function bt(t,n,i,r,a=[],s=y){const c=Ae([{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1}],i,a),o=e.dist.Buffer.alloc(Ee.span);return Ee.encode({instruction:O.Approve,amount:BigInt(r)},o),new e.TransactionInstruction({keys:c,programId:s,data:o})}const _e=e.struct([e.u8("instruction")]);function Ke(t,n,i,r=[],a=y){const s=Ae([{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0}],i,r),c=e.dist.Buffer.alloc(_e.span);return _e.encode({instruction:O.CloseAccount},c),new e.TransactionInstruction({keys:s,programId:a,data:c})}var $;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Mint=1]="Mint",t[t.Account=2]="Account"})($||($={}));const Me=1,kt=e.struct([e.u8("m"),e.u8("n"),e.bool("isInitialized"),e.publicKey("signer1"),e.publicKey("signer2"),e.publicKey("signer3"),e.publicKey("signer4"),e.publicKey("signer5"),e.publicKey("signer6"),e.publicKey("signer7"),e.publicKey("signer8"),e.publicKey("signer9"),e.publicKey("signer10"),e.publicKey("signer11")]),be=kt.span;var j;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initialized=1]="Initialized",t[t.Frozen=2]="Frozen"})(j||(j={}));const Ve=e.struct([e.publicKey("mint"),e.publicKey("owner"),e.u64("amount"),e.u32("delegateOption"),e.publicKey("delegate"),e.u8("state"),e.u32("isNativeOption"),e.u64("isNative"),e.u64("delegatedAmount"),e.u32("closeAuthorityOption"),e.publicKey("closeAuthority")]),T=Ve.span;async function Tt(t,n,i,r=y){const a=await t.getAccountInfo(n,i);return vt(n,a,r)}async function We(t,n){return await Ct(t,[],n)}async function Ct(t,n,i){const r=on(n);return await t.getMinimumBalanceForRentExemption(r,i)}function vt(t,n,i=y){if(!n)throw new Se;if(!n.owner.equals(i))throw new Le;if(n.data.length<T)throw new V;const r=Ve.decode(n.data.slice(0,T));let a=e.dist.Buffer.alloc(0);if(n.data.length>T){if(n.data.length===be)throw new V;if(n.data[T]!=$.Account)throw new At;a=n.data.slice(T+Me)}return{address:t,mint:r.mint,owner:r.owner,amount:r.amount,delegate:r.delegateOption?r.delegate:null,delegatedAmount:r.delegatedAmount,isInitialized:r.state!==j.Uninitialized,isFrozen:r.state===j.Frozen,isNative:!!r.isNativeOption,rentExemptReserve:r.isNativeOption?r.isNative:null,closeAuthority:r.closeAuthorityOption?r.closeAuthority:null,tlvData:a}}const Ge=e.struct([e.u32("mintAuthorityOption"),e.publicKey("mintAuthority"),e.u64("supply"),e.u8("decimals"),e.bool("isInitialized"),e.u32("freezeAuthorityOption"),e.publicKey("freezeAuthority")]),me=Ge.span;async function Pt(t,n,i,r=y){const a=await t.getAccountInfo(n,i);return Bt(n,a,r)}function Bt(t,n,i=y){if(!n)throw new Se;if(!n.owner.equals(i))throw new Le;if(n.data.length<me)throw new V;const r=Ge.decode(n.data.slice(0,me));let a=e.dist.Buffer.alloc(0);if(n.data.length>me){if(n.data.length<=T)throw new V;if(n.data.length===be)throw new V;if(n.data[T]!=$.Mint)throw new Mt;a=n.data.slice(T+Me)}return{address:t,mintAuthority:r.mintAuthorityOption?r.mintAuthority:null,supply:r.supply,decimals:r.decimals,isInitialized:r.isInitialized,freezeAuthority:r.freezeAuthorityOption?r.freezeAuthority:null,tlvData:a}}async function Ne(t,n,i=!1,r=y,a=te){if(!i&&!e.PublicKey.isOnCurve(n.toBuffer()))throw new qe;const[s]=await e.PublicKey.findProgramAddress([n.toBuffer(),r.toBuffer(),t.toBuffer()],a);return s}function ke(t,n,i=!1,r=y,a=te){if(!i&&!e.PublicKey.isOnCurve(n.toBuffer()))throw new qe;const[s]=e.PublicKey.findProgramAddressSync([n.toBuffer(),r.toBuffer(),t.toBuffer()],a);return s}const Rt=e.struct([e.bool("lockCpi")]),It=Rt.span,Et=e.struct([e.u8("state")]),_t=Et.span,Kt=e.struct([]),Wt=Kt.span,Nt=e.struct([e.publicKey("rateAuthority"),e.ns64("initializationTimestamp"),e.s16("preUpdateAverageRate"),e.ns64("lastUpdateTimestamp"),e.s16("currentRate")]),Ut=Nt.span,Ft=e.struct([e.bool("requireIncomingTransferMemos")]),Ot=Ft.span,xt=e.struct([e.publicKey("authority"),e.publicKey("metadataAddress")]),zt=xt.span,Dt=e.struct([e.publicKey("closeAuthority")]),Lt=Dt.span,Ye=e.struct([]),qt=Ye.span,Vt=Ye.span,Gt=e.struct([e.publicKey("delegate")]),Yt=Gt.span,Zt=1e4;BigInt(Zt);function Ue(t){return e.struct([e.u64("epoch"),e.u64("maximumFee"),e.u16("transferFeeBasisPoints")],t)}const Ht=e.struct([e.publicKey("transferFeeConfigAuthority"),e.publicKey("withdrawWithheldAuthority"),e.u64("withheldAmount"),Ue("olderTransferFee"),Ue("newerTransferFee")]),Qt=Ht.span,Xt=e.struct([e.u64("withheldAmount")]),Jt=Xt.span,$t=e.struct([e.publicKey("authority"),e.publicKey("programId")]),jt=$t.span,en=e.struct([e.bool("transferring")]),tn=en.span,Fe=e.struct([e.u8("discriminator"),e.blob(32,"addressConfig"),e.bool("isSigner"),e.bool("isWritable")]),nn=e.struct([e.u32("count"),e.seq(Fe,e.greedy(Fe.span),"extraAccounts")]);e.struct([e.u64("instructionDiscriminator"),e.u32("length"),nn.replicate("extraAccountsList")]);var w;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.TransferFeeConfig=1]="TransferFeeConfig",t[t.TransferFeeAmount=2]="TransferFeeAmount",t[t.MintCloseAuthority=3]="MintCloseAuthority",t[t.ConfidentialTransferMint=4]="ConfidentialTransferMint",t[t.ConfidentialTransferAccount=5]="ConfidentialTransferAccount",t[t.DefaultAccountState=6]="DefaultAccountState",t[t.ImmutableOwner=7]="ImmutableOwner",t[t.MemoTransfer=8]="MemoTransfer",t[t.NonTransferable=9]="NonTransferable",t[t.InterestBearingConfig=10]="InterestBearingConfig",t[t.CpiGuard=11]="CpiGuard",t[t.PermanentDelegate=12]="PermanentDelegate",t[t.NonTransferableAccount=13]="NonTransferableAccount",t[t.TransferHook=14]="TransferHook",t[t.TransferHookAccount=15]="TransferHookAccount",t[t.MetadataPointer=18]="MetadataPointer"})(w||(w={}));const Oe=2,rn=2;function an(t){switch(t){case w.Uninitialized:return 0;case w.TransferFeeConfig:return Qt;case w.TransferFeeAmount:return Jt;case w.MintCloseAuthority:return Lt;case w.ConfidentialTransferMint:return 97;case w.ConfidentialTransferAccount:return 286;case w.CpiGuard:return It;case w.DefaultAccountState:return _t;case w.ImmutableOwner:return Wt;case w.MemoTransfer:return Ot;case w.MetadataPointer:return zt;case w.NonTransferable:return qt;case w.InterestBearingConfig:return Ut;case w.PermanentDelegate:return Yt;case w.NonTransferableAccount:return Vt;case w.TransferHook:return jt;case w.TransferHookAccount:return tn;default:throw Error(`Unknown extension type: ${t}`)}}function sn(t,n){if(t.length===0)return n;{const i=T+Me+t.filter((r,a)=>a===t.indexOf(r)).map(r=>an(r)+Oe+rn).reduce((r,a)=>r+a);return i===be?i+Oe:i}}function on(t){return sn(t,T)}const xe=e.struct([e.u8("instruction")]);function ze(t,n,i,r=y){const a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:e.SYSVAR_RENT_PUBKEY,isSigner:!1,isWritable:!1}],s=e.dist.Buffer.alloc(xe.span);return xe.encode({instruction:O.InitializeAccount},s),new e.TransactionInstruction({keys:a,programId:r,data:s})}function Ze(t,n,i,r,a=y,s=te){return cn(t,n,i,r,e.dist.Buffer.alloc(0),a,s)}function cn(t,n,i,r,a,s=y,c=te){const o=[{pubkey:t,isSigner:!0,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:e.SystemProgram.programId,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!1,isWritable:!1}];return new e.TransactionInstruction({keys:o,programId:c,data:a})}const De=e.struct([e.u8("instruction"),e.u64("amount")]);function un(t,n,i,r,a=[],s=y){const c=Ae([{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0}],i,a),o=e.dist.Buffer.alloc(De.span);return De.encode({instruction:O.Transfer,amount:BigInt(r)},o),new e.TransactionInstruction({keys:c,programId:s,data:o})}function ne(t,n){const i=e.dist.Buffer.alloc(2);return i.writeUInt16BE(e.toChainId(n)),e.deriveAddress([e.dist.Buffer.from("foreign_contract"),i],t)}function He(t){return e.deriveAddress([e.dist.Buffer.from("redeemer")],t)}function re(t,n){return e.deriveAddress([e.dist.Buffer.from("mint"),new e.PublicKey(n).toBuffer()],t)}function Te(t){return e.deriveAddress([e.dist.Buffer.from("sender")],t)}function Ce(t,n){return e.deriveAddress([e.dist.Buffer.from("tmp"),new e.PublicKey(n).toBuffer()],t)}function ve(t,n,i){return e.deriveAddress([e.dist.Buffer.from("bridged"),new e.PublicKey(n).toBuffer(),e.dist.Buffer.from(e.bignum.toBytes(BigInt(i.toString()),8))],t)}function A(t){return e.deriveAddress([e.dist.Buffer.from("config")],t)}async function dn(t,n,i){return t.getAccountInfo(A(n),i).then(r=>ie.deserialize(e.getAccountData(r)))}class ie{constructor(n){l(this,"wormhole");this.wormhole=new e.PublicKey(n)}static deserialize(n){if(n.length!=32)throw new Error("data.length != 32");const i=n.subarray(0,32);return new ie(i)}}function H(t,n){return e.deriveAddress([new e.PublicKey(n).toBuffer()],t)}function K(t,n,i){if(n==e.toChainId("Solana"))throw new Error("emitterChain == CHAIN_ID_SOLANA cannot exist as foreign token bridge emitter");const r=typeof i=="string"?new e.UniversalAddress(i).toUint8Array():i;return e.deriveAddress([(()=>{const a=e.dist.Buffer.alloc(2);return a.writeUInt16BE(n),a})(),r],t)}async function ln(t,n,i){return t.getAccountInfo(new e.PublicKey(n),i).then(r=>ae.deserialize(e.getAccountData(r)))}class ae{constructor(n,i){l(this,"chain");l(this,"contract");this.chain=n,this.contract=i}static deserialize(n){if(n.length!=34)throw new Error("data.length != 34");const i=n.readUInt16LE(0),r=n.subarray(2,34);return new ae(i,r)}}function se(t){return e.deriveAddress([e.dist.Buffer.from("sender")],t)}function oe(t){return e.deriveAddress([e.dist.Buffer.from("redeemer")],t)}function W(t){return e.deriveAddress([e.dist.Buffer.from("authority_signer")],t)}function D(t){return e.deriveAddress([e.dist.Buffer.from("custody_signer")],t)}function Q(t){return e.deriveAddress([e.dist.Buffer.from("mint_signer")],t)}function N(t,n,i){if(n==e.toChainId("Solana"))throw new Error("tokenChain == CHAIN_ID_SOLANA does not have wrapped mint key");return e.deriveAddress([e.dist.Buffer.from("wrapped"),(()=>{const r=e.dist.Buffer.alloc(2);return r.writeUInt16BE(n),r})(),i],t)}function E(t,n){return e.deriveAddress([e.dist.Buffer.from("meta"),new e.PublicKey(n).toBuffer()],t)}async function G(t,n,i,r){return t.getAccountInfo(E(n,i),r).then(a=>ce.deserialize(e.getAccountData(a)))}class ce{constructor(n,i,r,a){l(this,"chain");l(this,"tokenAddress");l(this,"originalDecimals");l(this,"lastUpdatedSequence");this.chain=n,this.tokenAddress=i,this.originalDecimals=r,this.lastUpdatedSequence=a}static deserialize(n){if(n.length!==35&&n.length!==43)throw new Error(`invalid wrapped meta length: ${n.length}`);const i=n.readUInt16LE(0),r=n.subarray(2,34),a=n.readUInt8(34),s=n.length===43?n.readBigUInt64LE(35):void 0;return new ce(i,r,a,s)}}function ge(t,n,i,r){return bt(new e.PublicKey(n),W(t),new e.PublicKey(i),r)}class fn{constructor(n){l(this,"idl");this.idl=n}async encode(n,i){switch(n){default:throw new Error(`Invalid account name: ${n}`)}}decode(n,i){return this.decodeUnchecked(n,i)}decodeUnchecked(n,i){switch(n){default:throw new Error(`Invalid account name: ${n}`)}}memcmp(n,i){switch(n){default:throw new Error(`Invalid account name: ${n}`)}}size(n){return e.accountSize(this.idl,n)??0}}class mn{constructor(n){}decode(n){throw new Error("Token Bridge program does not have events")}}class gn{constructor(n){}encode(n,i){switch(n){case"initialize":return hn(i);case"attestToken":return pn(i);case"completeNative":return yn(i);case"completeWrapped":return wn(i);case"transferWrapped":return Sn(i);case"transferNative":return An(i);case"registerChain":return Mn(i);case"createWrapped":return bn(i);case"upgradeContract":return kn(i);case"transferWrappedWithPayload":return Tn(i);case"transferNativeWithPayload":return Cn(i);default:throw new Error(`Invalid instruction: ${n}`)}}encodeState(n,i){throw new Error("Token Bridge program does not have state")}}var b;(function(t){t[t.Initialize=0]="Initialize",t[t.AttestToken=1]="AttestToken",t[t.CompleteNative=2]="CompleteNative",t[t.CompleteWrapped=3]="CompleteWrapped",t[t.TransferWrapped=4]="TransferWrapped",t[t.TransferNative=5]="TransferNative",t[t.RegisterChain=6]="RegisterChain",t[t.CreateWrapped=7]="CreateWrapped",t[t.UpgradeContract=8]="UpgradeContract",t[t.CompleteNativeWithPayload=9]="CompleteNativeWithPayload",t[t.CompleteWrappedWithPayload=10]="CompleteWrappedWithPayload",t[t.TransferWrappedWithPayload=11]="TransferWrappedWithPayload",t[t.TransferNativeWithPayload=12]="TransferNativeWithPayload"})(b||(b={}));function v(t,n){const i=n===void 0?0:n.length,r=e.dist.Buffer.alloc(1+i);return r.writeUInt8(t,0),i>0&&r.write(n.toString("hex"),1,"hex"),r}function hn({wormhole:t}){const n=e.dist.Buffer.alloc(32);return n.write(new e.PublicKey(t).toBuffer().toString("hex"),0,"hex"),v(b.Initialize,n)}function pn({nonce:t}){const n=e.dist.Buffer.alloc(4);return n.writeUInt32LE(t,0),v(b.AttestToken,n)}function yn({}){return v(b.CompleteNative)}function wn({}){return v(b.CompleteWrapped)}function Qe({nonce:t,amount:n,fee:i,targetAddress:r,targetChain:a}){if(typeof n!="bigint"&&(n=BigInt(n)),typeof i!="bigint"&&(i=BigInt(i)),!e.dist.Buffer.isBuffer(r))throw new Error("targetAddress must be Buffer");const s=e.dist.Buffer.alloc(54);return s.writeUInt32LE(t,0),s.writeBigUInt64LE(n,4),s.writeBigUInt64LE(i,12),s.write(r.toString("hex"),20,"hex"),s.writeUInt16LE(a,52),s}function Sn({nonce:t,amount:n,fee:i,targetAddress:r,targetChain:a}){return v(b.TransferWrapped,Qe({nonce:t,amount:n,fee:i,targetAddress:r,targetChain:a}))}function An({nonce:t,amount:n,fee:i,targetAddress:r,targetChain:a}){return v(b.TransferNative,Qe({nonce:t,amount:n,fee:i,targetAddress:r,targetChain:a}))}function Mn({}){return v(b.RegisterChain)}function bn({}){return v(b.CreateWrapped)}function kn({}){return v(b.UpgradeContract)}function Xe({nonce:t,amount:n,targetAddress:i,targetChain:r,payload:a}){if(typeof n!="bigint"&&(n=BigInt(n)),!e.dist.Buffer.isBuffer(i))throw new Error("targetAddress must be Buffer");if(!e.dist.Buffer.isBuffer(a))throw new Error("payload must be Buffer");const s=e.dist.Buffer.alloc(50);return s.writeUInt32LE(t,0),s.writeBigUInt64LE(n,4),s.write(i.toString("hex"),12,"hex"),s.writeUInt16LE(r,44),s.writeUInt32LE(a.length,46),e.dist.Buffer.concat([s,a,e.dist.Buffer.alloc(1)])}function Tn({nonce:t,amount:n,fee:i,targetAddress:r,targetChain:a,payload:s}){return v(b.TransferWrappedWithPayload,Xe({nonce:t,amount:n,targetAddress:r,targetChain:a,payload:s}))}function Cn({nonce:t,amount:n,fee:i,targetAddress:r,targetChain:a,payload:s}){return v(b.TransferNativeWithPayload,Xe({nonce:t,amount:n,targetAddress:r,targetChain:a,payload:s}))}class vn{constructor(n){}encode(n,i){throw new Error("Token Bridge program does not have state")}decode(n){throw new Error("Token Bridge program does not have state")}}class Pn{constructor(n){}encode(n,i){throw new Error("Token Bridge program does not have user-defined types")}decode(n,i){throw new Error("Token Bridge program does not have user-defined types")}}class Bn{constructor(n){l(this,"instruction");l(this,"accounts");l(this,"state");l(this,"events");l(this,"types");this.instruction=new gn(n),this.accounts=new fn(n),this.state=new vn(n),this.events=new mn(n),this.types=new Pn(n)}}const Pe={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 Je(t,n){return new e.Program(Pe,new e.PublicKey(t),n===void 0?{connection:null}:n,$e())}function k(t,n){return Je(t,e.createReadOnlyProvider(n))}function $e(){return new Bn(Pe)}const Y=class Y{constructor(n,i,r){l(this,"address");l(this,"verified");l(this,"share");this.address=new e.PublicKey(n),this.verified=i,this.share=r}serialize(){const n=e.dist.Buffer.alloc(Y.size);return n.write(this.address.toBuffer().toString("hex"),0,"hex"),this.verified&&n.writeUInt8(1,32),n.writeUInt8(this.share,33),n}static deserialize(n){const i=n.subarray(0,32),r=n.readUInt8(32)>0,a=n.readUInt8(33);return new Y(i,r,a)}};l(Y,"size",34);let I=Y;class X{constructor(n,i,r,a,s){l(this,"name");l(this,"symbol");l(this,"uri");l(this,"sellerFeeBasisPoints");l(this,"creators");this.name=n,this.symbol=i,this.uri=r,this.sellerFeeBasisPoints=a,this.creators=s}serialize(){const n=this.name.length,i=this.symbol.length,r=this.uri.length,a=this.creators,[s,c]=(()=>{if(a===null)return[0,0];const d=a.length;return[d,4+d*I.size]})(),o=e.dist.Buffer.alloc(15+n+i+r+c);if(o.writeUInt32LE(n,0),o.write(this.name,4),o.writeUInt32LE(i,4+n),o.write(this.symbol,8+n),o.writeUInt32LE(r,8+n+i),o.write(this.uri,12+n+i),o.writeUInt16LE(this.sellerFeeBasisPoints,12+n+i+r),a===null)o.writeUInt8(0,14+n+i+r);else{o.writeUInt8(1,14+n+i+r),o.writeUInt32LE(s,15+n+i+r);for(let d=0;d<s;++d){const u=a.at(d),f=19+n+i+r+d*I.size;o.write(u.serialize().toString("hex"),f,"hex")}}return o}static deserialize(n){const i=n.readUInt32LE(0),r=n.subarray(4,4+i).toString(),a=n.readUInt32LE(4+i),s=n.subarray(8+i,8+i+a).toString(),c=n.readUInt32LE(8+i+a),o=n.subarray(12+i+a,12+i+a+c).toString(),d=n.readUInt16LE(12+i+a+c),u=n.readUInt8(14+i+a+c),f=(()=>{if(u==0)return null;const g=[],m=n.readUInt32LE(15+i+a+c);for(let p=0;p<m;++p){const h=19+i+a+c+p*I.size;g.push(I.deserialize(n.subarray(h,h+I.size)))}return g})();return new X(r,s,o,d,f)}}class Z extends X{constructor(i,r,a,s,c,o){super(i,r,a,s,c);l(this,"isMutable");this.isMutable=o}static serialize(i,r,a,s,c,o){return new Z(i,r,a,s,c,o).serialize()}static serializeInstructionData(i,r,a,s,c,o){return e.dist.Buffer.concat([e.dist.Buffer.alloc(1,0),Z.serialize(i,r,a,s,c,o)])}serialize(){return e.dist.Buffer.concat([super.serialize(),e.dist.Buffer.alloc(1,this.isMutable?1:0)])}}const ee=class ee{constructor(){}static createMetadataAccounts(n,i,r,a,s,c,o=!1,d,u,f,g=!1,m=J(i)){const p=[e.newAccountMeta(m,!1),e.newReadOnlyAccountMeta(i,!1),e.newReadOnlyAccountMeta(r,!0),e.newReadOnlyAccountMeta(n,!0),e.newReadOnlyAccountMeta(c,o),e.newReadOnlyAccountMeta(e.SystemProgram.programId,!1),e.newReadOnlyAccountMeta(e.SYSVAR_RENT_PUBKEY,!1)],h=Z.serializeInstructionData(a,s,d===void 0?"":d,f===void 0?0:f,u===void 0?null:u,g);return{programId:ee.programId,keys:p,data:h}}};l(ee,"programId",new e.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"));let x=ee;function J(t){return e.deriveAddress([e.dist.Buffer.from("metadata"),x.programId.toBuffer(),new e.PublicKey(t).toBuffer()],x.programId)}exports.Key=void 0;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.EditionV1=1]="EditionV1",t[t.MasterEditionV1=2]="MasterEditionV1",t[t.ReservationListV1=3]="ReservationListV1",t[t.MetadataV1=4]="MetadataV1",t[t.ReservationListV2=5]="ReservationListV2",t[t.MasterEditionV2=6]="MasterEditionV2",t[t.EditionMarker=7]="EditionMarker"})(exports.Key||(exports.Key={}));class ue{constructor(n,i,r,a,s,c){l(this,"key");l(this,"updateAuthority");l(this,"mint");l(this,"data");l(this,"primarySaleHappened");l(this,"isMutable");this.key=n,this.updateAuthority=new e.PublicKey(i),this.mint=new e.PublicKey(r),this.data=a,this.primarySaleHappened=s,this.isMutable=c}static deserialize(n){const i=n.readUInt8(0),r=n.subarray(1,33),a=n.subarray(33,65),s=X.deserialize(n.subarray(65)),c=s.serialize().length,o=n.readUInt8(65+c)>0,d=n.readUInt8(66+c)>0;return new ue(i,r,a,s,o,d)}}async function Rn(t,n,i){return t.getAccountInfo(J(n),i).then(r=>ue.deserialize(e.getAccountData(r)))}function je(t,n,i,r,a,s,c){const o=k(n,t).methods.attestToken(c);return console.log(he(n,i,r,a,s)),o._ixFn(...o._args,{accounts:he(n,i,r,a,s),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function he(t,n,i,r,a){const{bridge:s,emitter:c,sequence:o,feeCollector:d,clock:u,rent:f,systemProgram:g}=e.getPostMessageAccounts(n,i,a,t);return{payer:new e.PublicKey(i),config:A(t),mint:new e.PublicKey(r),wrappedMeta:E(t,r),splMetadata:J(r),wormholeBridge:s,wormholeMessage:new e.PublicKey(a),wormholeEmitter:c,wormholeSequence:o,wormholeFeeCollector:d,clock:u,rent:f,systemProgram:g,wormholeProgram:new e.PublicKey(n)}}function pe(t,n,i,r,a,s){const c=k(n,t).methods.completeNative();return c._ixFn(...c._args,{accounts:et(n,i,r,a,s),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function et(t,n,i,r,a){const s=new e.PublicKey(r.payload.token.address.toUint8Array());return{payer:new e.PublicKey(i),config:A(t),vaa:e.derivePostedVaaKey(n,e.dist.Buffer.from(r.hash)),claim:e.deriveClaimKey(t,r.emitterAddress.toUint8Array(),e.toChainId(r.emitterChain),r.sequence),endpoint:K(t,e.toChainId(r.emitterChain),r.emitterAddress.toUint8Array()),to:new e.PublicKey(r.payload.to.address.toUint8Array()),toFees:new e.PublicKey(a===void 0?r.payload.to.address.toUint8Array():a),custody:H(t,s),mint:s,custodySigner:D(t),rent:e.SYSVAR_RENT_PUBKEY,systemProgram:e.SystemProgram.programId,tokenProgram:y,wormholeProgram:new e.PublicKey(n)}}function tt(t,n,i,r,a,s){const c=k(n,t).methods.completeWrapped();return c._ixFn(...c._args,{accounts:nt(n,i,r,a,s),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function nt(t,n,i,r,a){const s=N(t,e.toChainId(r.payload.token.chain),r.payload.token.address.toUint8Array());return{payer:new e.PublicKey(i),config:A(t),vaa:e.derivePostedVaaKey(n,e.dist.Buffer.from(r.hash)),claim:e.deriveClaimKey(t,r.emitterAddress.toUint8Array(),e.toChainId(r.emitterChain),r.sequence),endpoint:K(t,e.toChainId(r.emitterChain),r.emitterAddress.toUint8Array()),to:new e.PublicKey(r.payload.to.address.toUint8Array()),toFees:new e.PublicKey(a===void 0?r.payload.to.address.toUint8Array():a),mint:s,wrappedMeta:E(t,s),mintAuthority:Q(t),rent:e.SYSVAR_RENT_PUBKEY,systemProgram:e.SystemProgram.programId,tokenProgram:y,wormholeProgram:new e.PublicKey(n)}}function rt(t,n,i,r,a){const s=k(n,t).methods.createWrapped();return s._ixFn(...s._args,{accounts:it(n,i,r,a),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function it(t,n,i,r){const a=N(t,e.toChainId(r.payload.token.chain),r.payload.token.address.toUint8Array());return{payer:new e.PublicKey(i),config:A(t),endpoint:K(t,e.toChainId(r.emitterChain),r.emitterAddress.toUint8Array()),vaa:e.derivePostedVaaKey(n,e.dist.Buffer.from(r.hash)),claim:e.deriveClaimKey(t,r.emitterAddress.toUint8Array(),e.toChainId(r.emitterChain),r.sequence),mint:a,wrappedMeta:E(t,a),splMetadata:J(a),mintAuthority:Q(t),rent:e.SYSVAR_RENT_PUBKEY,systemProgram:e.SystemProgram.programId,tokenProgram:y,splMetadataProgram:x.programId,wormholeProgram:new e.PublicKey(n)}}function In(t,n,i){const r=k(t).methods.initialize(i);return r._ixFn(...r._args,{accounts:at(t,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function at(t,n){return{payer:new e.PublicKey(n),config:A(t),rent:e.SYSVAR_RENT_PUBKEY,systemProgram:e.SystemProgram.programId}}function En(t,n,i,r){const a=k(t).methods.registerChain();return a._ixFn(...a._args,{accounts:st(t,n,i,r),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function st(t,n,i,r){return{payer:new e.PublicKey(i),config:A(t),endpoint:K(t,e.toChainId(r.payload.actionArgs.foreignChain),r.payload.actionArgs.foreignAddress.toUint8Array()),vaa:e.derivePostedVaaKey(n,e.dist.Buffer.from(r.hash)),claim:e.deriveClaimKey(t,r.emitterAddress.toUint8Array(),e.toChainId(r.emitterChain),r.sequence),rent:e.SYSVAR_RENT_PUBKEY,systemProgram:e.SystemProgram.programId,wormholeProgram:new e.PublicKey(n)}}function _n(t,n,i,r,a){const s=k(t).methods.upgradeContract();return s._ixFn(...s._args,{accounts:ot(t,n,i,r,a),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function ot(t,n,i,r,a){return{payer:new e.PublicKey(i),vaa:e.derivePostedVaaKey(n,e.dist.Buffer.from(r.hash)),claim:e.deriveClaimKey(t,r.emitterAddress.toUint8Array(),e.toChainId(r.emitterChain),r.sequence),upgradeAuthority:e.deriveUpgradeAuthorityKey(t),spill:new e.PublicKey(a===void 0?i:a),implementation:new e.PublicKey(r.payload.actionArgs.newContract),programData:e.deriveProgramDataAddress(t),tokenBridgeProgram:new e.PublicKey(t),rent:e.SYSVAR_RENT_PUBKEY,clock:e.SYSVAR_CLOCK_PUBKEY,bpfLoaderUpgradeable:e.BPF_LOADER_UPGRADEABLE_PROGRAM_ID,systemProgram:e.SystemProgram.programId}}function ye(t,n,i,r,a,s,c,o,d,u,f,g){const m=k(n,t).methods.transferNative(o,d,u,e.dist.Buffer.from(f),g);return m._ixFn(...m._args,{accounts:ct(n,i,r,a,s,c),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function ct(t,n,i,r,a,s){const{wormholeBridge:c,wormholeMessage:o,wormholeEmitter:d,wormholeSequence:u,wormholeFeeCollector:f,clock:g,rent:m,systemProgram:p}=e.getPostMessageCpiAccounts(t,n,i,r);return{payer:new e.PublicKey(i),config:A(t),from:new e.PublicKey(a),mint:new e.PublicKey(s),custody:H(t,s),authoritySigner:W(t),custodySigner:D(t),wormholeBridge:c,wormholeMessage:o,wormholeEmitter:d,wormholeSequence:u,wormholeFeeCollector:f,clock:g,rent:m,systemProgram:p,tokenProgram:y,wormholeProgram:new e.PublicKey(n)}}function we(t,n,i,r,a,s,c,o,d,u,f,g){const m=k(n,t).methods.transferNativeWithPayload(o,d,e.dist.Buffer.from(u),f,e.dist.Buffer.from(g),null);return m._ixFn(...m._args,{accounts:Be(n,i,r,a,s,c),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function Be(t,n,i,r,a,s,c){const{wormholeBridge:o,wormholeMessage:d,wormholeEmitter:u,wormholeSequence:f,wormholeFeeCollector:g,clock:m,rent:p,systemProgram:h}=e.getPostMessageCpiAccounts(t,n,i,r);return{payer:new e.PublicKey(i),config:A(t),from:new e.PublicKey(a),mint:new e.PublicKey(s),custody:H(t,s),authoritySigner:W(t),custodySigner:D(t),wormholeBridge:o,wormholeMessage:d,wormholeEmitter:u,wormholeSequence:f,wormholeFeeCollector:g,clock:m,sender:new e.PublicKey(c===void 0?i:se(c)),rent:p,systemProgram:h,tokenProgram:y,wormholeProgram:new e.PublicKey(n)}}function ut(t,n,i,r,a,s,c,o,d,u,f,g,m,p){const h=k(n,t).methods.transferWrapped(u,f,g,e.dist.Buffer.from(m),p);return h._ixFn(...h._args,{accounts:dt(n,i,r,a,s,c,o,d),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function dt(t,n,i,r,a,s,c,o){const d=N(t,c,o),{wormholeBridge:u,wormholeMessage:f,wormholeEmitter:g,wormholeSequence:m,wormholeFeeCollector:p,clock:h,rent:S,systemProgram:M}=e.getPostMessageCpiAccounts(t,n,i,r);return{payer:new e.PublicKey(i),config:A(t),from:new e.PublicKey(a),fromOwner:new e.PublicKey(s),mint:d,wrappedMeta:E(t,d),authoritySigner:W(t),wormholeBridge:u,wormholeMessage:f,wormholeEmitter:g,wormholeSequence:m,wormholeFeeCollector:p,clock:h,rent:S,systemProgram:M,wormholeProgram:new e.PublicKey(n),tokenProgram:y}}function lt(t,n,i,r,a,s,c,o,d,u,f,g,m,p){const h=k(n,t).methods.transferWrappedWithPayload(u,f,e.dist.Buffer.from(g),m,e.dist.Buffer.from(p),null);return h._ixFn(...h._args,{accounts:Re(n,i,r,a,s,c,o,d),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function Re(t,n,i,r,a,s,c,o,d){const u=N(t,c,o),{wormholeBridge:f,wormholeMessage:g,wormholeEmitter:m,wormholeSequence:p,wormholeFeeCollector:h,clock:S,rent:M,systemProgram:P}=e.getPostMessageCpiAccounts(t,n,i,r);return{payer:new e.PublicKey(i),config:A(t),from:new e.PublicKey(a),fromOwner:new e.PublicKey(s),mint:u,wrappedMeta:E(t,u),authoritySigner:W(t),wormholeBridge:f,wormholeMessage:g,wormholeEmitter:m,wormholeSequence:p,wormholeFeeCollector:h,clock:S,sender:new e.PublicKey(d===void 0?i:se(d)),rent:M,systemProgram:P,wormholeProgram:new e.PublicKey(n),tokenProgram:y}}function Kn(t,n,i){const{wormholeEmitter:r,wormholeBridge:a,wormholeFeeCollector:s,wormholeSequence:c}=e.getWormholeDerivedAccounts(n,i);return{tokenBridgeConfig:A(n),tokenBridgeAuthoritySigner:W(n),tokenBridgeCustodySigner:D(n),tokenBridgeMintAuthority:Q(n),tokenBridgeSender:se(t),tokenBridgeRedeemer:oe(t),wormholeBridge:a,tokenBridgeEmitter:r,wormholeFeeCollector:s,tokenBridgeSequence:c}}function ft(t,n,i,r,a,s,c){const o=Be(n,i,r,a,s,c,t);return{payer:o.payer,tokenBridgeConfig:o.config,fromTokenAccount:o.from,mint:o.mint,tokenBridgeCustody:o.custody,tokenBridgeAuthoritySigner:o.authoritySigner,tokenBridgeCustodySigner:o.custodySigner,wormholeBridge:o.wormholeBridge,wormholeMessage:o.wormholeMessage,tokenBridgeEmitter:o.wormholeEmitter,tokenBridgeSequence:o.wormholeSequence,wormholeFeeCollector:o.wormholeFeeCollector,clock:o.clock,tokenBridgeSender:o.sender,rent:o.rent,systemProgram:o.systemProgram,tokenProgram:o.tokenProgram,wormholeProgram:o.wormholeProgram}}function mt(t,n,i,r,a,s,c,o,d){const u=Re(n,i,r,a,s,d===void 0?t:d,c,o,t);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 Wn(t,n,i,r,a){const s=new e.PublicKey(r.payload.token.address.toUint8Array()),c=new e.PublicKey(r.payload.to.address.toUint8Array());return{payer:new e.PublicKey(i),tokenBridgeConfig:A(t),vaa:e.derivePostedVaaKey(n,e.dist.Buffer.from(r.hash)),tokenBridgeClaim:e.deriveClaimKey(t,r.emitterAddress.toUint8Array(),e.toChainId(r.emitterChain),r.sequence),tokenBridgeForeignEndpoint:K(t,e.toChainId(r.emitterChain),r.emitterAddress.toUint8Array()),toTokenAccount:new e.PublicKey(a),tokenBridgeRedeemer:oe(c),toFeesTokenAccount:new e.PublicKey(a),tokenBridgeCustody:H(t,s),mint:s,tokenBridgeCustodySigner:D(t),rent:e.SYSVAR_RENT_PUBKEY,systemProgram:e.SystemProgram.programId,tokenProgram:y,wormholeProgram:new e.PublicKey(n)}}function Nn(t,n,i,r,a){const s=N(t,e.toChainId(r.payload.token.chain),r.payload.token.address.toUint8Array()),c=new e.PublicKey(r.payload.to.address.toUint8Array());return{payer:new e.PublicKey(i),tokenBridgeConfig:A(t),vaa:e.derivePostedVaaKey(n,e.dist.Buffer.from(r.hash)),tokenBridgeClaim:e.deriveClaimKey(t,r.emitterAddress.toUint8Array(),e.toChainId(r.emitterChain),r.sequence),tokenBridgeForeignEndpoint:K(t,e.toChainId(r.emitterChain),r.emitterAddress.toUint8Array()),toTokenAccount:new e.PublicKey(a),tokenBridgeRedeemer:oe(c),toFeesTokenAccount:new e.PublicKey(a),tokenBridgeWrappedMint:s,tokenBridgeWrappedMeta:E(t,s),tokenBridgeMintAuthority:Q(t),rent:e.SYSVAR_RENT_PUBKEY,systemProgram:e.SystemProgram.programId,tokenProgram:y,wormholeProgram:new e.PublicKey(n)}}const gt={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(t,n){return new e.Program(gt,new e.PublicKey(t),{connection:n})}function ht(t,n){return e.deriveAddress([e.dist.Buffer.from("seq"),new e.PublicKey(n).toBuffer()],t)}async function pt(t,n,i,r,a,s,c,o,d,u,f,g){const{methods:{transferNativeTokensWithRelay:m},account:{signerSequence:p}}=de(n,t),h=ht(n,i),S=await p.fetch(h).then(({value:B})=>B).catch(B=>{var _;if((_=B.message)!=null&&_.includes("Account does not exist"))return new e.BN(0);throw B}),M=ve(n,i,S),P=ke(new e.PublicKey(s),new e.PublicKey(i)),C=Ce(n,s),L=ft(n,r,a,i,M,P,s);return m(new e.BN(c.toString()),new e.BN(o.toString()),e.toChainId(u),[...d],f,g).accounts({config:Te(n),payerSequence:h,foreignContract:ne(n,u),registeredToken:re(n,s),tmpTokenAccount:C,tokenBridgeProgram:new e.PublicKey(r),...L}).instruction()}async function yt(t,n,i,r,a,s,c,o,d,u,f){const{methods:{transferWrappedTokensWithRelay:g},account:{signerSequence:m}}=de(n,t),p=ht(n,i),h=await m.fetch(p).then(({value:_})=>_).catch(_=>{var Ie;if((Ie=_.message)!=null&&Ie.includes("Account does not exist"))return new e.BN(0);throw _}),S=ve(n,i,h),M=ke(new e.PublicKey(s),new e.PublicKey(i)),{chain:P,tokenAddress:C}=await G(t,r,s),L=Ce(n,s),B=mt(n,r,a,i,S,M,P,C);return g(new e.BN(c.toString()),new e.BN(o.toString()),e.toChainId(u),[...d],f).accounts({config:Te(n),payerSequence:p,foreignContract:ne(n,u),registeredToken:re(n,new e.PublicKey(s)),tmpTokenAccount:L,tokenBridgeProgram:new e.PublicKey(r),...B}).instruction()}class le{constructor(n,i,r,a){l(this,"network");l(this,"chain");l(this,"connection");l(this,"contracts");l(this,"chainId");l(this,"coreBridge");l(this,"tokenBridge");this.network=n,this.chain=i,this.connection=r,this.contracts=a,this.chainId=e.toChainId(i);const s=a.tokenBridge;if(!s)throw new Error(`TokenBridge contract Address for chain ${i} not found`);this.tokenBridge=k(s,r),this.coreBridge=new e.SolanaWormholeCore(n,i,r,a)}static async fromRpc(n,i){const[r,a]=await e.SolanaPlatform.chainFromRpc(n),s=i[a];if(s.network!==r)throw new Error(`Network mismatch for chain ${a}: ${s.network} != ${r}`);return new le(r,a,n,s.contracts)}async isWrappedAsset(n){return G(this.connection,this.tokenBridge.programId,new e.SolanaAddress(n).toUint8Array()).catch(i=>null).then(i=>i!=null)}async getOriginalAsset(n){if(!await this.isWrappedAsset(n))throw e.ErrNotWrapped(n.toString());const i=new e.SolanaAddress(n).toUint8Array(),r=new e.PublicKey(i);try{const a=await G(this.connection,this.tokenBridge.programId,i);return a===null?{chain:this.chain,address:new e.SolanaAddress(r.toBytes()).toUniversalAddress()}:{chain:e.toChain(a.chain),address:new e.UniversalAddress(new Uint8Array(a.tokenAddress))}}catch{throw e.ErrNotWrapped(n.toString())}}async getTokenUniversalAddress(n){return new e.SolanaAddress(n).toUniversalAddress()}async getTokenNativeAddress(n,i){return new e.SolanaAddress(i).toNative()}async hasWrappedAsset(n){try{return await this.getWrappedAsset(n),!0}catch{}return!1}async getWrappedAsset(n){if(e.isNative(n.address))throw new Error("Native cannot be a wrapped asset");const i=N(this.tokenBridge.programId,e.toChainId(n.chain),n.address.toUniversalAddress().toUint8Array());try{return await G(this.connection,this.tokenBridge.programId,i),e.toNative(this.chain,i.toBase58())}catch{}throw e.ErrNotWrapped(`${i}: ${n.address.toUniversalAddress().toString()}`)}async isTransferCompleted(n){return e.getClaim(this.connection,this.tokenBridge.programId,n.emitterAddress.toUint8Array(),e.toChainId(n.emitterChain),n.sequence,this.connection.commitment).catch(()=>!1)}async getWrappedNative(){return e.toNative(this.chain,R.toBase58())}async*createAttestation(n,i){if(!i)throw new Error("Payer required to create attestation");const r=new e.SolanaAddress(i).unwrap(),a=0,s=await this.coreBridge.getMessageFee(),c=e.createBridgeFeeTransferInstruction(this.coreBridge.coreBridge.programId,r,s),o=e.Keypair.generate(),d=je(this.connection,this.tokenBridge.programId,this.coreBridge.address,r,new e.SolanaAddress(n).unwrap(),o.publicKey,a),u=new e.Transaction().add(c,d);u.feePayer=r,yield this.createUnsignedTx({transaction:u,signers:[o]},"Solana.AttestToken")}async*submitAttestation(n,i){if(!i)throw new Error("Payer required to create attestation");const r=new e.SolanaAddress(i).unwrap();yield*this.coreBridge.postVaa(r,n);const a=new e.Transaction().add(rt(this.connection,this.tokenBridge.programId,this.coreBridge.address,r,n));a.feePayer=r,yield this.createUnsignedTx({transaction:a},"Solana.CreateWrapped")}async transferSol(n,i,r,a){const s=new e.SolanaAddress(n).unwrap(),c=s,o=i.address.toUniversalAddress().toUint8Array(),d=e.toChainId(i.chain),u=0,f=0n,g=e.Keypair.generate(),m=e.Keypair.generate(),p=await We(this.connection),h=e.SystemProgram.createAccount({fromPubkey:c,newAccountPubkey:m.publicKey,lamports:p,space:T,programId:y}),S=e.SystemProgram.transfer({fromPubkey:c,lamports:r,toPubkey:m.publicKey}),M=ze(m.publicKey,R,c),P=ge(this.tokenBridge.programId,m.publicKey,c,r),C=a?we(this.connection,this.tokenBridge.programId,this.coreBridge.address,s,g.publicKey,m.publicKey,R,u,r,o,d,a):ye(this.connection,this.tokenBridge.programId,this.coreBridge.address,s,g.publicKey,m.publicKey,R,u,r,f,o,d),L=Ke(m.publicKey,c,c),B=new e.Transaction;return B.feePayer=c,B.add(h,S,M,P,C,L),this.createUnsignedTx({transaction:B,signers:[g,m]},"TokenBridge.TransferNative")}async*transfer(n,i,r,a,s){if(e.isNative(r)){yield await this.transferSol(n,i,a,s);return}const c=new e.SolanaAddress(r).unwrap(),o=new e.SolanaAddress(n).unwrap(),d=await Ne(c,o),u=i.address.toUniversalAddress().toUint8Array(),f=e.toChainId(i.chain),g=0,m=0n,p=!await this.isWrappedAsset(r),h=e.Keypair.generate();let S;if(p)S=s?we(this.connection,this.tokenBridge.programId,this.coreBridge.address,o,h.publicKey,d,c,g,a,u,f,s):ye(this.connection,this.tokenBridge.programId,this.coreBridge.address,o,h.publicKey,d,c,g,a,m,u,f);else{const C=await this.getOriginalAsset(r);if(e.isNative(C.address))throw new Error("Native cannot be an original asset");S=s?lt(this.connection,this.tokenBridge.programId,this.coreBridge.address,o,h.publicKey,d,o,e.toChainId(C.chain),C.address.toUint8Array(),g,a,u,f,s):ut(this.connection,this.tokenBridge.programId,this.coreBridge.address,o,h.publicKey,d,o,e.toChainId(C.chain),C.address.toUint8Array(),g,a,m,u,f)}const M=ge(this.tokenBridge.programId,d,o,a),P=new e.Transaction().add(M,S);P.feePayer=o,yield this.createUnsignedTx({transaction:P,signers:[h]},"TokenBridge.TransferTokens")}async*redeemAndUnwrap(n,i){const r=new e.SolanaAddress(n).unwrap(),a=new e.SolanaAddress(i.payload.to.address).unwrap(),s=await Pt(this.connection,R).then(h=>i.payload.token.amount*BigInt(Math.pow(10,h.decimals-8))),c=await We(this.connection),o=e.Keypair.generate(),d=pe(this.connection,this.tokenBridge.programId,this.coreBridge.address,r,i),u=e.SystemProgram.createAccount({fromPubkey:r,newAccountPubkey:o.publicKey,lamports:c,space:T,programId:y}),f=ze(o.publicKey,R,r),g=un(a,o.publicKey,r,s.valueOf()),m=Ke(o.publicKey,r,r),p=new e.Transaction;p.feePayer=r,p.add(d,u,f,g,m),yield this.createUnsignedTx({transaction:p,signers:[o]},"TokenBridge.RedeemAndUnwrap")}async*createAta(n,i){const r=new e.SolanaAddress(n).unwrap(),a=new e.SolanaAddress(i).unwrap(),s=await Ne(a,r);if(await this.connection.getAccountInfo(s)===null){const o=new e.Transaction().add(Ze(r,s,r,a));o.feePayer=r,yield this.createUnsignedTx({transaction:o},"Redeem.CreateATA")}}async*redeem(n,i,r=!0){const a=i.payload.token.chain===this.chain?i.payload.token.address:(await this.getWrappedAsset(i.payload.token)).toUniversalAddress();if(yield*this.createAta(n,a),yield*this.coreBridge.postVaa(n,i),r){const d=new e.SolanaAddress(await this.getWrappedNative());if(e.bytes.equals(a.toUint8Array(),d.toUint8Array())){yield*this.redeemAndUnwrap(n,i);return}}const s=new e.SolanaAddress(n).unwrap(),c=i.payload.token.chain==this.chain?pe:tt,o=new e.Transaction().add(c(this.connection,this.tokenBridge.programId,this.coreBridge.address,s,i));o.feePayer=s,yield this.createUnsignedTx({transaction:o},"Solana.RedeemTransfer")}createUnsignedTx(n,i,r=!1){return new e.SolanaUnsignedTransaction(n,this.network,this.chain,i,r)}}const Un={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:[]},U=9,q=new e.BN(10),F=new e.BN(1e8);class fe{constructor(n,i,r,a){l(this,"network");l(this,"chain");l(this,"connection");l(this,"contracts");l(this,"chainId");l(this,"coreBridgeProgramId");l(this,"tokenBridgeProgramId");l(this,"tokenBridgeRelayer");this.network=n,this.chain=i,this.connection=r,this.contracts=a,this.chainId=e.toChainId(i);const s=a.tokenBridgeRelayer;if(!s)throw new Error(`TokenBridge contract Address for chain ${i} not found`);this.tokenBridgeRelayer=de(s,r),this.tokenBridgeProgramId=new e.PublicKey(a.tokenBridge),this.coreBridgeProgramId=new e.PublicKey(a.coreBridge)}static async fromRpc(n,i){const[r,a]=await e.SolanaPlatform.chainFromRpc(n),s=i[a];if(s.network!==r)throw new Error(`Network mismatch for chain ${a}: ${s.network} != ${r}`);return new fe(r,a,n,s.contracts)}async*transfer(n,i,r,a,s){const o=new e.SolanaAddress(n).unwrap(),d=i.address.toUniversalAddress().toUint8Array(),u=this.mintAddress(r),f=new e.Transaction;if(e.isNative(r)){const h=ke(u,o);try{await Tt(this.connection,h)}catch(S){if(S instanceof Se){const M=Ze(o,h,o,u);f.add(M)}else throw S}}const g=s||0n,m=e.isNative(r),p=m?await pt(this.connection,this.tokenBridgeRelayer.programId,o,this.tokenBridgeProgramId,this.coreBridgeProgramId,u,a,g,d,i.chain,0,m):await yt(this.connection,this.tokenBridgeRelayer.programId,o,this.tokenBridgeProgramId,this.coreBridgeProgramId,u,a,g,d,i.chain,0);f.add(p),f.feePayer=o,yield this.createUnsignedTx({transaction:f},"AutomaticTokenBridge.Transfer")}async*redeem(n,i){const r=new e.Transaction;throw yield this.createUnsignedTx({transaction:r},"AutomaticTokenBridge.Redeem"),new Error("Method not implemented.")}async getRelayerFee(n,i){const r=this.mintAddress(i),[{fee:a},{swapRate:s},{relayerFeePrecision:c}]=await Promise.all([this.getForeignContract(n),this.getRegisteredToken(r),this.getRedeemerConfig()]),o=Number(await e.SolanaPlatform.getDecimals(this.chain,this.connection,i)),d=q.pow(new e.BN(o)).mul(a).mul(F).div(new e.BN(c).mul(s));return BigInt(d.toString())}async maxSwapAmount(n){const i=this.mintAddress(n),[{swapRate:r,maxNativeSwapAmount:a},{swapRate:s}]=await Promise.all([this.getRegisteredToken(i),this.getRegisteredToken(R)]),c=Number(await e.SolanaPlatform.getDecimals(this.chain,this.connection,n)),o=this.calculateNativeSwapRate(s,r),d=c>U?a.mul(o).mul(q.pow(new e.BN(c-U))).div(F):a.mul(o).div(q.pow(new e.BN(U-c)).mul(F));return BigInt(d.toString())}async nativeTokenAmount(n,i){if(i===0n)return 0n;const r=this.mintAddress(n),a=Number(await e.SolanaPlatform.getDecimals(this.chain,this.connection,n)),[{swapRate:s},{swapRate:c}]=await Promise.all([this.getRegisteredToken(r),this.getRegisteredToken(R)]),o=this.calculateNativeSwapRate(c,s),d=a>U?F.mul(new e.BN(i.toString())).div(o.mul(q.pow(new e.BN(a-U)))):F.mul(new e.BN(i.toString())).mul(q.pow(new e.BN(U-a))).div(o);return BigInt(d.toString())}async isRegisteredToken(n){var r;const i=this.mintAddress(n);try{return await this.getRegisteredToken(i),!0}catch(a){if((r=a.message)!=null&&r.includes("Account does not exist"))return!1;throw a}}mintAddress(n){return e.isNative(n)?new e.PublicKey(R):new e.SolanaAddress(n).unwrap()}async getRegisteredTokens(){return Un[this.network].map(n=>e.toNative(this.chain,n))}calculateNativeSwapRate(n,i){return F.mul(n).div(i)}async getForeignContract(n){return await this.tokenBridgeRelayer.account.foreignContract.fetch(ne(this.tokenBridgeRelayer.programId,n))}async getRegisteredToken(n){return await this.tokenBridgeRelayer.account.registeredToken.fetch(re(this.tokenBridgeRelayer.programId,n))}async getRedeemerConfig(){return await this.tokenBridgeRelayer.account.redeemerConfig.fetch(He(this.tokenBridgeRelayer.programId))}createUnsignedTx(n,i,r=!1){return new e.SolanaUnsignedTransaction(n,this.network,this.chain,i,r)}}e.registerProtocol(e._platform$1,"TokenBridge",le);e.registerProtocol(e._platform$1,"AutomaticTokenBridge",fe);exports.CreateMetadataAccountArgs=Z;exports.Creator=I;exports.Data=X;exports.EndpointRegistration=ae;exports.Metadata=ue;exports.SolanaAutomaticTokenBridge=fe;exports.SolanaTokenBridge=le;exports.SplTokenMetadataProgram=x;exports.TOKEN_BRIDGE_IDL=Pe;exports.TOKEN_BRIDGE_RELAYER_IDL=gt;exports.TokenBridgeConfig=ie;exports.WrappedMeta=ce;exports.coder=$e;exports.createApproveAuthoritySignerInstruction=ge;exports.createAttestTokenInstruction=je;exports.createCompleteTransferNativeInstruction=pe;exports.createCompleteTransferWrappedInstruction=tt;exports.createCreateWrappedInstruction=rt;exports.createInitializeInstruction=In;exports.createReadOnlyTokenBridgeProgramInterface=k;exports.createRegisterChainInstruction=En;exports.createTokenBridgeProgramInterface=Je;exports.createTokenBridgeRelayerProgramInterface=de;exports.createTransferNativeInstruction=ye;exports.createTransferNativeTokensWithRelayInstruction=pt;exports.createTransferNativeWithPayloadInstruction=we;exports.createTransferWrappedInstruction=ut;exports.createTransferWrappedTokensWithRelayInstruction=yt;exports.createTransferWrappedWithPayloadInstruction=lt;exports.createUpgradeContractInstruction=_n;exports.deriveAuthoritySignerKey=W;exports.deriveCustodyKey=H;exports.deriveCustodySignerKey=D;exports.deriveEndpointKey=K;exports.deriveForeignContractAddress=ne;exports.deriveMintAuthorityKey=Q;exports.deriveRedeemerAccountKey=oe;exports.deriveRedeemerConfigAddress=He;exports.deriveRegisteredTokenAddress=re;exports.deriveSenderAccountKey=se;exports.deriveSenderConfigAddress=Te;exports.deriveSplTokenMetadataKey=J;exports.deriveTmpTokenAccountAddress=Ce;exports.deriveTokenBridgeConfigKey=A;exports.deriveTokenTransferMessageAddress=ve;exports.deriveWrappedMetaKey=E;exports.deriveWrappedMintKey=N;exports.getAttestTokenAccounts=he;exports.getCompleteTransferNativeAccounts=et;exports.getCompleteTransferNativeWithPayloadCpiAccounts=Wn;exports.getCompleteTransferWrappedAccounts=nt;exports.getCompleteTransferWrappedWithPayloadCpiAccounts=Nn;exports.getCreateWrappedAccounts=it;exports.getEndpointRegistration=ln;exports.getInitializeAccounts=at;exports.getMetadata=Rn;exports.getRegisterChainAccounts=st;exports.getTokenBridgeConfig=dn;exports.getTokenBridgeDerivedAccounts=Kn;exports.getTransferNativeAccounts=ct;exports.getTransferNativeWithPayloadAccounts=Be;exports.getTransferNativeWithPayloadCpiAccounts=ft;exports.getTransferWrappedAccounts=dt;exports.getTransferWrappedWithPayloadAccounts=Re;exports.getTransferWrappedWithPayloadCpiAccounts=mt;exports.getUpgradeContractAccounts=ot;exports.getWrappedMeta=G;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var Y = Object.defineProperty;
|
|
2
2
|
var Z = (n, f, e) => f in n ? Y(n, f, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[f] = e;
|
|
3
3
|
var d = (n, f, e) => Z(n, typeof f != "symbol" ? f + "" : f, e);
|
|
4
|
-
import { U as y, bk as f0, bl as W, bm as p, bn as e0, bo as a0, bp as t0, bq as _, br as b0, bs as n0, bt as d0, b8 as L, bu as O, E as v, b as C, bv as D, r as U, bc as u, bw as q, bf as c0, bx as N, bh as H, bi as j, b6 as s0, by as i0, bz as I, b5 as S, a4 as $, bj as V, _ as G } from "./index-
|
|
5
|
-
import "./index-
|
|
4
|
+
import { U as y, bk as f0, bl as W, bm as p, bn as e0, bo as a0, bp as t0, bq as _, br as b0, bs as n0, bt as d0, b8 as L, bu as O, E as v, b as C, bv as D, r as U, bc as u, bw as q, bf as c0, bx as N, bh as H, bi as j, b6 as s0, by as i0, bz as I, b5 as S, a4 as $, bj as V, _ as G } from "./index-CaNzAG1x.mjs";
|
|
5
|
+
import "./index-BWsfR9uT.mjs";
|
|
6
6
|
const r0 = new RegExp("^bytes([0-9]+)$"), p0 = new RegExp("^(u?int)([0-9]*)$"), y0 = new RegExp("^(.*)\\[([0-9]*)\\]$");
|
|
7
7
|
function J(n, f, e) {
|
|
8
8
|
switch (n) {
|