@wormhole-foundation/wormhole-connect 2.4.0-beta.3-development → 2.4.0-beta.5-development
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +70 -70
- package/dist/src/AppRouter.d.ts.map +1 -1
- package/dist/src/consts/wallet.d.ts.map +1 -1
- package/dist/src/utils/coingecko.d.ts.map +1 -1
- package/dist/src/views/v2/Redeem/index.d.ts.map +1 -1
- package/lib/{aptos-CSvcKEJm.js → aptos-BbcbhTYm.js} +1 -1
- package/lib/{aptos-D3RPZgif.mjs → aptos-Bm_dl-Sm.mjs} +5 -5
- package/lib/{aptos-WpCc6eOD.js → aptos-DWjNHjEr.js} +2 -2
- package/lib/{aptos-cEXzuL5b.mjs → aptos-tST8jYJD.mjs} +2 -2
- package/lib/{base64-D3sIs-fw.mjs → base64-U98S6T0_.mjs} +1 -1
- package/lib/{base64-C73YLbqA.js → base64-z-NzkTcM.js} +1 -1
- package/lib/{ccip-CaksatNz.js → ccip-4kkdFBy9.js} +1 -1
- package/lib/{ccip-BJTawxQ_.mjs → ccip-CzIVguK4.mjs} +1 -1
- package/lib/{chunk-IMTC3J2M-Dsnj4Vih.mjs → chunk-IMTC3J2M-BkF-uSqL.mjs} +3 -3
- package/lib/{chunk-IMTC3J2M-DKXvnM6O.js → chunk-IMTC3J2M-D9V8xLCp.js} +1 -1
- package/lib/{evm-Wv2nh7z1.js → evm-BSCCtd8A.js} +3 -3
- package/lib/{evm-D_aPV3AL.mjs → evm-BVICyV8L.mjs} +6 -6
- package/lib/{evm-DNBYBo_p.js → evm-ENyRMNuv.js} +1 -1
- package/lib/{evm-Bs0OjXvE.mjs → evm-YfeWQlF5.mjs} +5 -5
- package/lib/{index-ctEY-xjJ.mjs → index-0ALUTgtr.mjs} +3 -3
- package/lib/{index-KpBoUsX2.mjs → index-5StF040W.mjs} +1 -1
- package/lib/{index-CUMRJ8yy.mjs → index-6NRj6D5S.mjs} +71 -31
- package/lib/{index-Cb51fnZM.js → index-8rarLRXW.js} +1 -1
- package/lib/{index-Ci0LEPmE.mjs → index-B4i6ANNh.mjs} +2 -2
- package/lib/{index-DRMwoM8a.mjs → index-BArAN3-r.mjs} +4 -4
- package/lib/{index-ZK1P1tUH.js → index-BH76Gm64.js} +1 -1
- package/lib/{index-DfPjBy3w.mjs → index-BRWk1KLF.mjs} +1 -1
- package/lib/{index-BvdMRpl6.js → index-BfHTgqOZ.js} +1 -1
- package/lib/{index-v-_ti7Rn.js → index-BfdWU9Y5.js} +1 -1
- package/lib/{index-Cvtp4dgE.js → index-BpqVHbdc.js} +7 -7
- package/lib/{index-D19OP8Mu.mjs → index-BvyrFhuS.mjs} +2 -2
- package/lib/{index-CUSJAO56.js → index-BxFyTBij.js} +1 -1
- package/lib/{index-9pPnVz73.mjs → index-ByKaNDA7.mjs} +2 -2
- package/lib/{index-DGGMUOzp.mjs → index-C-xA8IEi.mjs} +3 -3
- package/lib/{index--95bwciz.js → index-C8mQJEzu.js} +1 -1
- package/lib/{index-tzTI5R9c.js → index-C9uP2nLx.js} +1 -1
- package/lib/{index-CjgM-0OC.js → index-CFDAWb0X.js} +1 -1
- package/lib/{index-DIqG9W_r.js → index-COOq9Yre.js} +1 -1
- package/lib/{index-Bx5QNYj7.mjs → index-CRfcoCAy.mjs} +1 -1
- package/lib/{index-DNBuc7tl.js → index-CU761Hwu.js} +1 -1
- package/lib/{index-DYrT7_2n.mjs → index-CbNgmtU7.mjs} +1 -1
- package/lib/{index-DRYbBPuh.mjs → index-Cio3MIbP.mjs} +2 -2
- package/lib/{index-DS_rORqD.mjs → index-CkmesAuC.mjs} +1 -1
- package/lib/{index-CcEA2K6Q.mjs → index-Cm3sAIIe.mjs} +1 -1
- package/lib/{index-BtA_-iXv.mjs → index-CwCGT3bW.mjs} +2 -2
- package/lib/{index-C5rfYL4K.js → index-DHo7otfk.js} +1 -1
- package/lib/{index-q570DLLo.mjs → index-DJ17vId9.mjs} +2 -2
- package/lib/{index-BpKxYGa-.mjs → index-DMGq-P-n.mjs} +2 -2
- package/lib/{index-DqRhhSXa.mjs → index-DOydP0Ra.mjs} +2 -2
- package/lib/{index-BH-EfOl1.js → index-DQIEuT2z.js} +1 -1
- package/lib/{index-COqO8I1C.mjs → index-DV3sBKmN.mjs} +1 -1
- package/lib/{index-e3oHdOB4.mjs → index-DbFCRZIL.mjs} +1 -1
- package/lib/{index-BrFIzqtL.js → index-DpiBI2wV.js} +1 -1
- package/lib/{index-DwhWt2Jt.mjs → index-DsQWOOoH.mjs} +1 -1
- package/lib/{index-BCrWCNUq.js → index-Gq1AaNfJ.js} +1 -1
- package/lib/{index-Bzn58Yhp.js → index-GzxoZgwg.js} +1 -1
- package/lib/{index-B2VBT3u7.mjs → index-IsMPgaBj.mjs} +2 -2
- package/lib/{index-DLeUCqIq.js → index-Me4j3SkB.js} +1 -1
- package/lib/{index-D0NbpzAg.mjs → index-Ty2OFCqQ.mjs} +1 -1
- package/lib/{index-CMw2Uill.js → index-VIbVNXaj.js} +1 -1
- package/lib/{index-C6Hp_1yF.js → index-Z8OXKqvR.js} +1 -1
- package/lib/{index-BZpnoMd1.js → index-nvmWtaEp.js} +1 -1
- package/lib/{index-DCRe22Ms.js → index-tWdeaq3O.js} +1 -1
- package/lib/{index-D7f2-3wk.js → index-uAi7Hgz5.js} +1 -1
- package/lib/{index-BeGnKztN.js → index-xTj52Pcp.js} +1 -1
- package/lib/{index.es-Czhf3Th8.js → index.es-C6kXpySz.js} +2 -2
- package/lib/{index.es-By1LsNow.mjs → index.es-GYnz6s6j.mjs} +5 -5
- package/lib/index.js +1 -1
- package/lib/index.mjs +1 -1
- package/lib/{signer-CcpDR9mm.mjs → signer-BHB7SxtT.mjs} +1 -1
- package/lib/{signer-jV9Ixq8U.js → signer-C1EeLbAG.js} +1 -1
- package/lib/solana-C6wUNLMT.mjs +17 -0
- package/lib/solana-CVuGjBKt.js +1 -0
- package/lib/{solana-4YAkIi-J.js → solana-DzB5-MhL.js} +1 -1
- package/lib/{solana-Bo2aMvX4.mjs → solana-Q0OdKPAe.mjs} +4 -4
- package/lib/{solanaEmbed.esm-4CS_00aM.mjs → solanaEmbed.esm-BZupTABA.mjs} +1 -1
- package/lib/{solanaEmbed.esm-B-rprhcd.js → solanaEmbed.esm-sERTASiF.js} +1 -1
- package/lib/src/AppRouter.d.ts.map +1 -1
- package/lib/src/consts/wallet.d.ts.map +1 -1
- package/lib/src/utils/coingecko.d.ts.map +1 -1
- package/lib/src/views/v2/Redeem/index.d.ts.map +1 -1
- package/lib/{sui-DLOfqNsy.mjs → sui-BrEJo3ss.mjs} +5 -5
- package/lib/{sui-BgD7gx67.js → sui-CxxJykl3.js} +1 -1
- package/lib/{sui-MorjdPyy.js → sui-Dk9s2xZt.js} +1 -1
- package/lib/{sui-BGaWik82.mjs → sui-Hz2Goaqc.mjs} +1 -1
- package/package.json +21 -21
- package/lib/solana-DA02fWu7.mjs +0 -17
- package/lib/solana-DVFk6Z5q.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const me=Symbol(),se=Object.getPrototypeOf,G=new WeakMap,he=e=>e&&(G.has(e)?G.get(e):se(e)===Object.prototype||se(e)===Array.prototype),ge=e=>he(e)&&e[me]||null,ne=(e,t=!0)=>{G.set(e,t)},H={},F=e=>typeof e=="object"&&e!==null,A=new WeakMap,x=new WeakSet,be=(e=Object.is,t=(n,g)=>new Proxy(n,g),s=n=>F(n)&&!x.has(n)&&(Array.isArray(n)||!(Symbol.iterator in n))&&!(n instanceof WeakMap)&&!(n instanceof WeakSet)&&!(n instanceof Error)&&!(n instanceof Number)&&!(n instanceof Date)&&!(n instanceof String)&&!(n instanceof RegExp)&&!(n instanceof ArrayBuffer),r=n=>{switch(n.status){case"fulfilled":return n.value;case"rejected":throw n.reason;default:throw n}},l=new WeakMap,c=(n,g,I=r)=>{const v=l.get(n);if((v==null?void 0:v[0])===g)return v[1];const w=Array.isArray(n)?[]:Object.create(Object.getPrototypeOf(n));return ne(w,!0),l.set(n,[g,w]),Reflect.ownKeys(n).forEach(k=>{if(Object.getOwnPropertyDescriptor(w,k))return;const O=Reflect.get(n,k),M={value:O,enumerable:!0,configurable:!0};if(x.has(O))ne(O,!1);else if(O instanceof Promise)delete M.value,M.get=()=>I(O);else if(A.has(O)){const[b,q]=A.get(O);M.value=c(b,q(),I)}Object.defineProperty(w,k,M)}),Object.preventExtensions(w)},m=new WeakMap,p=[1,1],E=n=>{if(!F(n))throw new Error("object required");const g=m.get(n);if(g)return g;let I=p[0];const v=new Set,w=(i,a=++p[0])=>{I!==a&&(I=a,v.forEach(o=>o(i,a)))};let k=p[1];const O=(i=++p[1])=>(k!==i&&!v.size&&(k=i,b.forEach(([a])=>{const o=a[1](i);o>I&&(I=o)})),I),M=i=>(a,o)=>{const h=[...a];h[1]=[i,...h[1]],w(h,o)},b=new Map,q=(i,a)=>{if((H?"production":void 0)!=="production"&&b.has(i))throw new Error("prop listener already exists");if(v.size){const o=a[3](M(i));b.set(i,[a,o])}else b.set(i,[a])},te=i=>{var a;const o=b.get(i);o&&(b.delete(i),(a=o[1])==null||a.call(o))},fe=i=>(v.add(i),v.size===1&&b.forEach(([o,h],_)=>{if((H?"production":void 0)!=="production"&&h)throw new Error("remove already exists");const T=o[3](M(_));b.set(_,[o,T])}),()=>{v.delete(i),v.size===0&&b.forEach(([o,h],_)=>{h&&(h(),b.set(_,[o]))})}),J=Array.isArray(n)?[]:Object.create(Object.getPrototypeOf(n)),$=t(J,{deleteProperty(i,a){const o=Reflect.get(i,a);te(a);const h=Reflect.deleteProperty(i,a);return h&&w(["delete",[a],o]),h},set(i,a,o,h){const _=Reflect.has(i,a),T=Reflect.get(i,a,h);if(_&&(e(T,o)||m.has(o)&&e(T,m.get(o))))return!0;te(a),F(o)&&(o=ge(o)||o);let V=o;if(o instanceof Promise)o.then(C=>{o.status="fulfilled",o.value=C,w(["resolve",[a],C])}).catch(C=>{o.status="rejected",o.reason=C,w(["reject",[a],C])});else{!A.has(o)&&s(o)&&(V=E(o));const C=!x.has(V)&&A.get(V);C&&q(a,C)}return Reflect.set(i,a,V,h),w(["set",[a],o,T]),!0}});m.set(n,$);const pe=[J,O,c,fe];return A.set($,pe),Reflect.ownKeys(n).forEach(i=>{const a=Object.getOwnPropertyDescriptor(n,i);"value"in a&&($[i]=n[i],delete a.value,delete a.writable),Object.defineProperty(J,i,a)}),$})=>[E,A,x,e,t,s,r,l,c,m,p],[ye]=be();function j(e={}){return ye(e)}function D(e,t,s){const r=A.get(e);(H?"production":void 0)!=="production"&&!r&&console.warn("Please use proxy object");let l;const c=[],m=r[3];let p=!1;const n=m(g=>{c.push(g),l||(l=Promise.resolve().then(()=>{l=void 0,p&&t(c.splice(0))}))});return p=!0,()=>{p=!1,n()}}function ve(e,t){const s=A.get(e);(H?"production":void 0)!=="production"&&!s&&console.warn("Please use proxy object");const[r,l,c]=s;return c(r,l(),t)}const d=j({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),ee={state:d,subscribe(e){return D(d,()=>e(d))},push(e,t){e!==d.view&&(d.view=e,t&&(d.data=t),d.history.push(e))},reset(e){d.view=e,d.history=[e]},replace(e){d.history.length>1&&(d.history[d.history.length-1]=e,d.view=e)},goBack(){if(d.history.length>1){d.history.pop();const[e]=d.history.slice(-1);d.view=e}},setData(e){d.data=e}},u={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return u.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return u.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},isArray(e){return Array.isArray(e)&&e.length>0},formatNativeUrl(e,t,s){if(u.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let r=e;r.includes("://")||(r=e.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`),this.setWalletConnectDeepLink(r,s);const l=encodeURIComponent(t);return`${r}wc?uri=${l}`},formatUniversalUrl(e,t,s){if(!u.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let r=e;r.endsWith("/")||(r=`${r}/`),this.setWalletConnectDeepLink(r,s);const l=encodeURIComponent(t);return`${r}wc?uri=${l}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){window.open(e,t,"noreferrer noopener")},setWalletConnectDeepLink(e,t){try{localStorage.setItem(u.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(e){try{const[t]=e.split("?");localStorage.setItem(u.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(u.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(u.WCM_VERSION,"2.6.2")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var e;const t=(e=ee.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t}},we=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),f=j({enabled:we,userSessionId:"",events:[],connectedWalletId:void 0}),ue={state:f,subscribe(e){return D(f.events,()=>e(ve(f.events[f.events.length-1])))},initialize(){f.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(f.userSessionId=crypto.randomUUID())},setConnectedWalletId(e){f.connectedWalletId=e},click(e){if(f.enabled){const t={type:"CLICK",name:e.name,userSessionId:f.userSessionId,timestamp:Date.now(),data:e};f.events.push(t)}},track(e){if(f.enabled){const t={type:"TRACK",name:e.name,userSessionId:f.userSessionId,timestamp:Date.now(),data:e};f.events.push(t)}},view(e){if(f.enabled){const t={type:"VIEW",name:e.name,userSessionId:f.userSessionId,timestamp:Date.now(),data:e};f.events.push(t)}}},L=j({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),y={state:L,subscribe(e){return D(L,()=>e(L))},setChains(e){L.chains=e},setWalletConnectUri(e){L.walletConnectUri=e},setIsCustomDesktop(e){L.isCustomDesktop=e},setIsCustomMobile(e){L.isCustomMobile=e},setIsDataLoaded(e){L.isDataLoaded=e},setIsUiLoaded(e){L.isUiLoaded=e},setIsAuth(e){L.isAuth=e}},B=j({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),S={state:B,subscribe(e){return D(B,()=>e(B))},setConfig(e){var t,s;ue.initialize(),y.setChains(e.chains),y.setIsAuth(!!e.enableAuthMode),y.setIsCustomMobile(!!((t=e.mobileWallets)!=null&&t.length)),y.setIsCustomDesktop(!!((s=e.desktopWallets)!=null&&s.length)),u.setModalVersionInStorage(),Object.assign(B,e)}};var Ie=Object.defineProperty,oe=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,We=Object.prototype.propertyIsEnumerable,re=(e,t,s)=>t in e?Ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Oe=(e,t)=>{for(var s in t||(t={}))Le.call(t,s)&&re(e,s,t[s]);if(oe)for(var s of oe(t))We.call(t,s)&&re(e,s,t[s]);return e};const Q="https://explorer-api.walletconnect.com",X="wcm",Y="js-2.6.2";async function K(e,t){const s=Oe({sdkType:X,sdkVersion:Y},t),r=new URL(e,Q);return r.searchParams.append("projectId",S.state.projectId),Object.entries(s).forEach(([l,c])=>{c&&r.searchParams.append(l,String(c))}),(await fetch(r)).json()}const U={async getDesktopListings(e){return K("/w3m/v1/getDesktopListings",e)},async getMobileListings(e){return K("/w3m/v1/getMobileListings",e)},async getInjectedListings(e){return K("/w3m/v1/getInjectedListings",e)},async getAllListings(e){return K("/w3m/v1/getAllListings",e)},getWalletImageUrl(e){return`${Q}/w3m/v1/getWalletImage/${e}?projectId=${S.state.projectId}&sdkType=${X}&sdkVersion=${Y}`},getAssetImageUrl(e){return`${Q}/w3m/v1/getAssetImage/${e}?projectId=${S.state.projectId}&sdkType=${X}&sdkVersion=${Y}`}};var Ee=Object.defineProperty,ae=Object.getOwnPropertySymbols,Ce=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable,ie=(e,t,s)=>t in e?Ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,je=(e,t)=>{for(var s in t||(t={}))Ce.call(t,s)&&ie(e,s,t[s]);if(ae)for(var s of ae(t))Ae.call(t,s)&&ie(e,s,t[s]);return e};const le=u.isMobile(),W=j({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),Me={state:W,async getRecomendedWallets(){const{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=S.state;if(e==="NONE"||t==="ALL"&&!e)return W.recomendedWallets;if(u.isArray(e)){const s={recommendedIds:e.join(",")},{listings:r}=await U.getAllListings(s),l=Object.values(r);l.sort((c,m)=>{const p=e.indexOf(c.id),E=e.indexOf(m.id);return p-E}),W.recomendedWallets=l}else{const{chains:s,isAuth:r}=y.state,l=s==null?void 0:s.join(","),c=u.isArray(t),m={page:1,sdks:r?"auth_v1":void 0,entries:u.RECOMMENDED_WALLET_AMOUNT,chains:l,version:2,excludedIds:c?t.join(","):void 0},{listings:p}=le?await U.getMobileListings(m):await U.getDesktopListings(m);W.recomendedWallets=Object.values(p)}return W.recomendedWallets},async getWallets(e){const t=je({},e),{explorerRecommendedWalletIds:s,explorerExcludedWalletIds:r}=S.state,{recomendedWallets:l}=W;if(r==="ALL")return W.wallets;l.length?t.excludedIds=l.map(I=>I.id).join(","):u.isArray(s)&&(t.excludedIds=s.join(",")),u.isArray(r)&&(t.excludedIds=[t.excludedIds,r].filter(Boolean).join(",")),y.state.isAuth&&(t.sdks="auth_v1");const{page:c,search:m}=e,{listings:p,total:E}=le?await U.getMobileListings(t):await U.getDesktopListings(t),n=Object.values(p),g=m?"search":"wallets";return W[g]={listings:[...W[g].listings,...n],total:E,page:c??1},{listings:n,total:E}},getWalletImageUrl(e){return U.getWalletImageUrl(e)},getAssetImageUrl(e){return U.getAssetImageUrl(e)},resetSearch(){W.search={listings:[],total:0,page:1}}},N=j({open:!1}),z={state:N,subscribe(e){return D(N,()=>e(N))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:r}=y.state;if(u.removeWalletConnectDeepLink(),y.setWalletConnectUri(e==null?void 0:e.uri),y.setChains(e==null?void 0:e.chains),ee.reset("ConnectWallet"),s&&r)N.open=!0,t();else{const l=setInterval(()=>{const c=y.state;c.isUiLoaded&&c.isDataLoaded&&(clearInterval(l),N.open=!0,t())},200)}})},close(){N.open=!1}};var Ue=Object.defineProperty,ce=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable,de=(e,t,s)=>t in e?Ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,De=(e,t)=>{for(var s in t||(t={}))Pe.call(t,s)&&de(e,s,t[s]);if(ce)for(var s of ce(t))Se.call(t,s)&&de(e,s,t[s]);return e};function ke(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const R=j({themeMode:ke()?"dark":"light"}),Z={state:R,subscribe(e){return D(R,()=>e(R))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(R.themeMode=t),s&&(R.themeVariables=De({},s))}},P=j({open:!1,message:"",variant:"success"}),_e={state:P,subscribe(e){return D(P,()=>e(P))},openToast(e,t){P.open=!0,P.message=e,P.variant=t},closeToast(){P.open=!1}};class Ne{constructor(t){this.openModal=z.open,this.closeModal=z.close,this.subscribeModal=z.subscribe,this.setTheme=Z.setThemeConfig,Z.setThemeConfig(t),S.setConfig(t),this.initUi()}async initUi(){if(typeof window<"u"){await Promise.resolve().then(()=>require("./index-DCRe22Ms.js"));const t=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",t),y.setIsUiLoaded(!0)}}}const Te=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectModal:Ne},Symbol.toStringTag,{value:"Module"}));exports.R=ue;exports.T=ee;exports.a=u;exports.index=Te;exports.ne=Z;exports.oe=_e;exports.p=y;exports.se=z;exports.te=Me;exports.y=S;
|
|
1
|
+
"use strict";const me=Symbol(),se=Object.getPrototypeOf,G=new WeakMap,he=e=>e&&(G.has(e)?G.get(e):se(e)===Object.prototype||se(e)===Array.prototype),ge=e=>he(e)&&e[me]||null,ne=(e,t=!0)=>{G.set(e,t)},H={},F=e=>typeof e=="object"&&e!==null,A=new WeakMap,x=new WeakSet,be=(e=Object.is,t=(n,g)=>new Proxy(n,g),s=n=>F(n)&&!x.has(n)&&(Array.isArray(n)||!(Symbol.iterator in n))&&!(n instanceof WeakMap)&&!(n instanceof WeakSet)&&!(n instanceof Error)&&!(n instanceof Number)&&!(n instanceof Date)&&!(n instanceof String)&&!(n instanceof RegExp)&&!(n instanceof ArrayBuffer),r=n=>{switch(n.status){case"fulfilled":return n.value;case"rejected":throw n.reason;default:throw n}},l=new WeakMap,c=(n,g,I=r)=>{const v=l.get(n);if((v==null?void 0:v[0])===g)return v[1];const w=Array.isArray(n)?[]:Object.create(Object.getPrototypeOf(n));return ne(w,!0),l.set(n,[g,w]),Reflect.ownKeys(n).forEach(k=>{if(Object.getOwnPropertyDescriptor(w,k))return;const O=Reflect.get(n,k),M={value:O,enumerable:!0,configurable:!0};if(x.has(O))ne(O,!1);else if(O instanceof Promise)delete M.value,M.get=()=>I(O);else if(A.has(O)){const[b,q]=A.get(O);M.value=c(b,q(),I)}Object.defineProperty(w,k,M)}),Object.preventExtensions(w)},m=new WeakMap,p=[1,1],E=n=>{if(!F(n))throw new Error("object required");const g=m.get(n);if(g)return g;let I=p[0];const v=new Set,w=(i,a=++p[0])=>{I!==a&&(I=a,v.forEach(o=>o(i,a)))};let k=p[1];const O=(i=++p[1])=>(k!==i&&!v.size&&(k=i,b.forEach(([a])=>{const o=a[1](i);o>I&&(I=o)})),I),M=i=>(a,o)=>{const h=[...a];h[1]=[i,...h[1]],w(h,o)},b=new Map,q=(i,a)=>{if((H?"production":void 0)!=="production"&&b.has(i))throw new Error("prop listener already exists");if(v.size){const o=a[3](M(i));b.set(i,[a,o])}else b.set(i,[a])},te=i=>{var a;const o=b.get(i);o&&(b.delete(i),(a=o[1])==null||a.call(o))},fe=i=>(v.add(i),v.size===1&&b.forEach(([o,h],_)=>{if((H?"production":void 0)!=="production"&&h)throw new Error("remove already exists");const T=o[3](M(_));b.set(_,[o,T])}),()=>{v.delete(i),v.size===0&&b.forEach(([o,h],_)=>{h&&(h(),b.set(_,[o]))})}),J=Array.isArray(n)?[]:Object.create(Object.getPrototypeOf(n)),$=t(J,{deleteProperty(i,a){const o=Reflect.get(i,a);te(a);const h=Reflect.deleteProperty(i,a);return h&&w(["delete",[a],o]),h},set(i,a,o,h){const _=Reflect.has(i,a),T=Reflect.get(i,a,h);if(_&&(e(T,o)||m.has(o)&&e(T,m.get(o))))return!0;te(a),F(o)&&(o=ge(o)||o);let V=o;if(o instanceof Promise)o.then(C=>{o.status="fulfilled",o.value=C,w(["resolve",[a],C])}).catch(C=>{o.status="rejected",o.reason=C,w(["reject",[a],C])});else{!A.has(o)&&s(o)&&(V=E(o));const C=!x.has(V)&&A.get(V);C&&q(a,C)}return Reflect.set(i,a,V,h),w(["set",[a],o,T]),!0}});m.set(n,$);const pe=[J,O,c,fe];return A.set($,pe),Reflect.ownKeys(n).forEach(i=>{const a=Object.getOwnPropertyDescriptor(n,i);"value"in a&&($[i]=n[i],delete a.value,delete a.writable),Object.defineProperty(J,i,a)}),$})=>[E,A,x,e,t,s,r,l,c,m,p],[ye]=be();function j(e={}){return ye(e)}function D(e,t,s){const r=A.get(e);(H?"production":void 0)!=="production"&&!r&&console.warn("Please use proxy object");let l;const c=[],m=r[3];let p=!1;const n=m(g=>{c.push(g),l||(l=Promise.resolve().then(()=>{l=void 0,p&&t(c.splice(0))}))});return p=!0,()=>{p=!1,n()}}function ve(e,t){const s=A.get(e);(H?"production":void 0)!=="production"&&!s&&console.warn("Please use proxy object");const[r,l,c]=s;return c(r,l(),t)}const d=j({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),ee={state:d,subscribe(e){return D(d,()=>e(d))},push(e,t){e!==d.view&&(d.view=e,t&&(d.data=t),d.history.push(e))},reset(e){d.view=e,d.history=[e]},replace(e){d.history.length>1&&(d.history[d.history.length-1]=e,d.view=e)},goBack(){if(d.history.length>1){d.history.pop();const[e]=d.history.slice(-1);d.view=e}},setData(e){d.data=e}},u={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return u.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return u.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},isArray(e){return Array.isArray(e)&&e.length>0},formatNativeUrl(e,t,s){if(u.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let r=e;r.includes("://")||(r=e.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`),this.setWalletConnectDeepLink(r,s);const l=encodeURIComponent(t);return`${r}wc?uri=${l}`},formatUniversalUrl(e,t,s){if(!u.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let r=e;r.endsWith("/")||(r=`${r}/`),this.setWalletConnectDeepLink(r,s);const l=encodeURIComponent(t);return`${r}wc?uri=${l}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){window.open(e,t,"noreferrer noopener")},setWalletConnectDeepLink(e,t){try{localStorage.setItem(u.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(e){try{const[t]=e.split("?");localStorage.setItem(u.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(u.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(u.WCM_VERSION,"2.6.2")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var e;const t=(e=ee.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t}},we=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),f=j({enabled:we,userSessionId:"",events:[],connectedWalletId:void 0}),ue={state:f,subscribe(e){return D(f.events,()=>e(ve(f.events[f.events.length-1])))},initialize(){f.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(f.userSessionId=crypto.randomUUID())},setConnectedWalletId(e){f.connectedWalletId=e},click(e){if(f.enabled){const t={type:"CLICK",name:e.name,userSessionId:f.userSessionId,timestamp:Date.now(),data:e};f.events.push(t)}},track(e){if(f.enabled){const t={type:"TRACK",name:e.name,userSessionId:f.userSessionId,timestamp:Date.now(),data:e};f.events.push(t)}},view(e){if(f.enabled){const t={type:"VIEW",name:e.name,userSessionId:f.userSessionId,timestamp:Date.now(),data:e};f.events.push(t)}}},L=j({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),y={state:L,subscribe(e){return D(L,()=>e(L))},setChains(e){L.chains=e},setWalletConnectUri(e){L.walletConnectUri=e},setIsCustomDesktop(e){L.isCustomDesktop=e},setIsCustomMobile(e){L.isCustomMobile=e},setIsDataLoaded(e){L.isDataLoaded=e},setIsUiLoaded(e){L.isUiLoaded=e},setIsAuth(e){L.isAuth=e}},B=j({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),S={state:B,subscribe(e){return D(B,()=>e(B))},setConfig(e){var t,s;ue.initialize(),y.setChains(e.chains),y.setIsAuth(!!e.enableAuthMode),y.setIsCustomMobile(!!((t=e.mobileWallets)!=null&&t.length)),y.setIsCustomDesktop(!!((s=e.desktopWallets)!=null&&s.length)),u.setModalVersionInStorage(),Object.assign(B,e)}};var Ie=Object.defineProperty,oe=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,We=Object.prototype.propertyIsEnumerable,re=(e,t,s)=>t in e?Ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Oe=(e,t)=>{for(var s in t||(t={}))Le.call(t,s)&&re(e,s,t[s]);if(oe)for(var s of oe(t))We.call(t,s)&&re(e,s,t[s]);return e};const Q="https://explorer-api.walletconnect.com",X="wcm",Y="js-2.6.2";async function K(e,t){const s=Oe({sdkType:X,sdkVersion:Y},t),r=new URL(e,Q);return r.searchParams.append("projectId",S.state.projectId),Object.entries(s).forEach(([l,c])=>{c&&r.searchParams.append(l,String(c))}),(await fetch(r)).json()}const U={async getDesktopListings(e){return K("/w3m/v1/getDesktopListings",e)},async getMobileListings(e){return K("/w3m/v1/getMobileListings",e)},async getInjectedListings(e){return K("/w3m/v1/getInjectedListings",e)},async getAllListings(e){return K("/w3m/v1/getAllListings",e)},getWalletImageUrl(e){return`${Q}/w3m/v1/getWalletImage/${e}?projectId=${S.state.projectId}&sdkType=${X}&sdkVersion=${Y}`},getAssetImageUrl(e){return`${Q}/w3m/v1/getAssetImage/${e}?projectId=${S.state.projectId}&sdkType=${X}&sdkVersion=${Y}`}};var Ee=Object.defineProperty,ae=Object.getOwnPropertySymbols,Ce=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable,ie=(e,t,s)=>t in e?Ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,je=(e,t)=>{for(var s in t||(t={}))Ce.call(t,s)&&ie(e,s,t[s]);if(ae)for(var s of ae(t))Ae.call(t,s)&&ie(e,s,t[s]);return e};const le=u.isMobile(),W=j({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),Me={state:W,async getRecomendedWallets(){const{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=S.state;if(e==="NONE"||t==="ALL"&&!e)return W.recomendedWallets;if(u.isArray(e)){const s={recommendedIds:e.join(",")},{listings:r}=await U.getAllListings(s),l=Object.values(r);l.sort((c,m)=>{const p=e.indexOf(c.id),E=e.indexOf(m.id);return p-E}),W.recomendedWallets=l}else{const{chains:s,isAuth:r}=y.state,l=s==null?void 0:s.join(","),c=u.isArray(t),m={page:1,sdks:r?"auth_v1":void 0,entries:u.RECOMMENDED_WALLET_AMOUNT,chains:l,version:2,excludedIds:c?t.join(","):void 0},{listings:p}=le?await U.getMobileListings(m):await U.getDesktopListings(m);W.recomendedWallets=Object.values(p)}return W.recomendedWallets},async getWallets(e){const t=je({},e),{explorerRecommendedWalletIds:s,explorerExcludedWalletIds:r}=S.state,{recomendedWallets:l}=W;if(r==="ALL")return W.wallets;l.length?t.excludedIds=l.map(I=>I.id).join(","):u.isArray(s)&&(t.excludedIds=s.join(",")),u.isArray(r)&&(t.excludedIds=[t.excludedIds,r].filter(Boolean).join(",")),y.state.isAuth&&(t.sdks="auth_v1");const{page:c,search:m}=e,{listings:p,total:E}=le?await U.getMobileListings(t):await U.getDesktopListings(t),n=Object.values(p),g=m?"search":"wallets";return W[g]={listings:[...W[g].listings,...n],total:E,page:c??1},{listings:n,total:E}},getWalletImageUrl(e){return U.getWalletImageUrl(e)},getAssetImageUrl(e){return U.getAssetImageUrl(e)},resetSearch(){W.search={listings:[],total:0,page:1}}},N=j({open:!1}),z={state:N,subscribe(e){return D(N,()=>e(N))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:r}=y.state;if(u.removeWalletConnectDeepLink(),y.setWalletConnectUri(e==null?void 0:e.uri),y.setChains(e==null?void 0:e.chains),ee.reset("ConnectWallet"),s&&r)N.open=!0,t();else{const l=setInterval(()=>{const c=y.state;c.isUiLoaded&&c.isDataLoaded&&(clearInterval(l),N.open=!0,t())},200)}})},close(){N.open=!1}};var Ue=Object.defineProperty,ce=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable,de=(e,t,s)=>t in e?Ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,De=(e,t)=>{for(var s in t||(t={}))Pe.call(t,s)&&de(e,s,t[s]);if(ce)for(var s of ce(t))Se.call(t,s)&&de(e,s,t[s]);return e};function ke(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const R=j({themeMode:ke()?"dark":"light"}),Z={state:R,subscribe(e){return D(R,()=>e(R))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(R.themeMode=t),s&&(R.themeVariables=De({},s))}},P=j({open:!1,message:"",variant:"success"}),_e={state:P,subscribe(e){return D(P,()=>e(P))},openToast(e,t){P.open=!0,P.message=e,P.variant=t},closeToast(){P.open=!1}};class Ne{constructor(t){this.openModal=z.open,this.closeModal=z.close,this.subscribeModal=z.subscribe,this.setTheme=Z.setThemeConfig,Z.setThemeConfig(t),S.setConfig(t),this.initUi()}async initUi(){if(typeof window<"u"){await Promise.resolve().then(()=>require("./index-tWdeaq3O.js"));const t=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",t),y.setIsUiLoaded(!0)}}}const Te=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectModal:Ne},Symbol.toStringTag,{value:"Module"}));exports.R=ue;exports.T=ee;exports.a=u;exports.index=Te;exports.ne=Z;exports.oe=_e;exports.p=y;exports.se=z;exports.te=Me;exports.y=S;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var l=Object.defineProperty;var y=(i,e,t)=>e in i?l(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var o=(i,e,t)=>y(i,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index-
|
|
1
|
+
"use strict";var l=Object.defineProperty;var y=(i,e,t)=>e in i?l(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var o=(i,e,t)=>y(i,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index-BpqVHbdc.js"),g=require("./unsignedTransaction-C1YeEl4G.js"),f=require("./aptos-DWjNHjEr.js"),w=[{name:"tokenBridgeAddress",...s.universalAddressItem},{name:"chain",...s.chainItem()},{name:"domainSeparator",binary:"bytes",custom:s.bytes.encode(s.APTOS_SEPARATOR),omit:!0},{name:"tokenId",...s.universalAddressItem},{name:"domainSeparator",binary:"bytes",custom:new Uint8Array([255]),omit:!0}],T=i=>s.serialize$1(w,i);class d{constructor(e,t,n,r){o(this,"network");o(this,"chain");o(this,"connection");o(this,"contracts");o(this,"chainId");o(this,"tokenBridgeAddress");this.network=e,this.chain=t,this.connection=n,this.contracts=r,this.chainId=s.toChainId(t);const a=r.tokenBridge;if(!a)throw new Error(`TokenBridge contract Address for chain ${t} not found`);this.tokenBridgeAddress=a}static async fromRpc(e,t){const[n,r]=await f.AptosPlatform.chainFromRpc(e),a=t[r];if(a.network!==n)throw new Error("Network mismatch "+a.network+" !== "+n);return new d(n,r,e,a.contracts)}async isWrappedAsset(e){try{return await this.getOriginalAsset(e),!0}catch{return!1}}async getOriginalAsset(e){const t=e.toString().split(s.APTOS_SEPARATOR),n=await this.connection.getAccountResource({accountAddress:t[0],resourceType:`${this.tokenBridgeAddress}::state::OriginInfo`});if(!n)throw s.ErrNotWrapped(e.toString());const r=s.toChain(parseInt(n.token_chain.number)),a=new s.UniversalAddress(n.token_address.external_address);return{chain:r,address:a}}async getTokenUniversalAddress(e){return new s.UniversalAddress(s.hex.encode(s.sha3_256(e.toString()),!0))}async getTokenNativeAddress(e,t){const n=e===this.chain?await this.getTypeFromExternalAddress(t.toString()):await this.getAssetFullyQualifiedType({chain:e,address:t});if(!n)throw new Error("Invalid asset address.");return new s.AptosAddress(n)}async hasWrappedAsset(e){try{return await this.getWrappedAsset(e),!0}catch{}return!1}async getWrappedAsset(e){if(s.isNative(e.address))throw new Error("native asset cannot be a wrapped asset");const t=await this.getAssetFullyQualifiedType(e);if(!t)throw new Error("Invalid asset address.");return await this.connection.getAccountResource({accountAddress:s.coalesceModuleAddress(t),resourceType:`${this.tokenBridgeAddress}::state::OriginInfo`}),s.toNative(this.chain,t)}async isTransferCompleted(e){const n=(await this.connection.getAccountResource({accountAddress:this.tokenBridgeAddress,resourceType:`${this.tokenBridgeAddress}::state::State`})).consumed_vaas.elems.handle;try{return await this.connection.getTableItem({handle:n,data:{key_type:"vector<u8>",value_type:"u8",key:`0x${s.dist.Buffer.from(s.keccak_256(e.hash)).toString("hex")}`}}),!0}catch{return!1}}async getWrappedNative(){return s.toNative(this.chain,s.APTOS_COIN)}async*createAttestation(e,t){const n={chain:this.chain,address:new s.AptosAddress(e)},r=await this.getAssetFullyQualifiedType(n);if(!r)throw new Error("Invalid asset address.");yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::attest_token::attest_token_entry`,typeArguments:[r],functionArguments:[]},"Aptos.AttestToken")}async*submitAttestation(e,t){yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::wrapped::create_wrapped_coin_type`,typeArguments:[],functionArguments:[s.serialize(e)]},"Aptos.CreateWrappedCoinType");const n=await this.getAssetFullyQualifiedType(e.payload.token);if(!n)throw new Error("Invalid asset address.");yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::wrapped::create_wrapped_coin`,typeArguments:[n],functionArguments:[s.serialize(e)]},"Aptos.CreateWrappedCoin")}async*transfer(e,t,n,r,a){const p=0n,c=0n,h=s.isNative(n)?s.APTOS_COIN:n.toString(),u=t.address.toUniversalAddress().toUint8Array(),A=s.toChainId(t.chain);a?yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::transfer_tokens::transfer_tokens_with_payload_entry`,typeArguments:[h],functionArguments:[r,A,u,c,a]},"Aptos.TransferTokensWithPayload"):yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::transfer_tokens::transfer_tokens_entry`,typeArguments:[h],functionArguments:[r,A,u,p,c]},"Aptos.TransferTokens")}async*redeem(e,t,n=!0){const r=t.payload.token.chain===this.chain?await this.getTypeFromExternalAddress(t.payload.token.address.toString()):await this.getAssetFullyQualifiedType(t.payload.token);if(!r)throw new Error("Invalid asset address.");yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::complete_transfer::submit_vaa_and_register_entry`,typeArguments:[r],functionArguments:[s.serialize(t)]},"Aptos.CompleteTransfer")}async getAssetFullyQualifiedType(e){return e.chain===this.chain?s.isValidAptosType(e.address.toString())?e.address.toString():null:`${d.getForeignAssetAddress(this.chain,this.tokenBridgeAddress,e)}::coin::T`}async getTypeFromExternalAddress(e){try{const t=await this.connection.getAccountResource({accountAddress:this.tokenBridgeAddress,resourceType:`${this.tokenBridgeAddress}::state::State`}),{handle:n}=t.native_infos,r=await this.connection.getTableItem({handle:n,data:{key_type:`${this.tokenBridgeAddress}::token_hash::TokenHash`,value_type:"0x1::type_info::TypeInfo",key:{hash:e}}});return r?[r.account_address,String.fromCharCode(...s.hex.decode(r.module_name)),String.fromCharCode(...s.hex.decode(r.struct_name))].join(s.APTOS_SEPARATOR):null}catch{return null}}static getForeignAssetAddress(e,t,n){if(s.isNative(n.address))throw new Error("Invalid token address");const r=T({chain:n.chain,tokenBridgeAddress:new s.AptosAddress(t).toUniversalAddress(),tokenId:n.address.toUniversalAddress()});return s.hex.encode(s.sha3_256(r),!0)}createUnsignedTx(e,t,n=!1){return new g.AptosUnsignedTransaction(e,this.network,this.chain,t,n)}}s.registerProtocol("Aptos","TokenBridge",d);exports.AptosTokenBridge=d;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var d = Object.defineProperty;
|
|
2
2
|
var h = (i, e, r) => e in i ? d(i, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : i[e] = r;
|
|
3
3
|
var o = (i, e, r) => h(i, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
-
import { b2 as m, I as w, cg as g, K as p, bf as u } from "./index-
|
|
4
|
+
import { b2 as m, I as w, cg as g, K as p, bf as u } from "./index-6NRj6D5S.mjs";
|
|
5
5
|
class c {
|
|
6
6
|
constructor(e, r, t, n) {
|
|
7
7
|
o(this, "network");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("./index-
|
|
1
|
+
"use strict";const e=require("./index-BpqVHbdc.js");function I(n,t,o,s){e.ahash(n);const a=e.checkOpts({dkLen:32,asyncTick:10},s),{c:d,dkLen:i,asyncTick:r}=a;if(e.anumber(d),e.anumber(i),e.anumber(r),d<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const l=e.toBytes(t),u=e.toBytes(o),f=new Uint8Array(i),p=e.hmac.create(n,l),c=p._cloneInto().update(u);return{c:d,dkLen:i,asyncTick:r,DK:f,PRF:p,PRFSalt:c}}function L(n,t,o,s,a){return n.destroy(),t.destroy(),s&&s.destroy(),a.fill(0),o}function g(n,t,o,s){const{c:a,dkLen:d,DK:i,PRF:r,PRFSalt:l}=I(n,t,o,s);let u;const f=new Uint8Array(4),p=e.createView(f),c=new Uint8Array(r.outputLen);for(let w=1,y=0;y<d;w++,y+=r.outputLen){const m=i.subarray(y,y+r.outputLen);p.setInt32(0,w,!1),(u=l._cloneInto(u)).update(f).digestInto(c),m.set(c.subarray(0,m.length));for(let h=1;h<a;h++){r._cloneInto(u).update(c).digestInto(c);for(let k=0;k<m.length;k++)m[k]^=c[k]}}return L(r,l,i,u,c)}/*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */function b(n){if(typeof n!="string")throw new TypeError("invalid mnemonic type: "+typeof n);return n.normalize("NFKD")}function F(n){const t=b(n),o=t.split(" ");if(![12,15,18,21,24].includes(o.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:o}}const S=n=>b("mnemonic"+n);function T(n,t=""){return g(e.sha512,F(n).nfkd,S(t),{c:2048,dkLen:64})}exports.mnemonicToSeedSync=T;
|
|
@@ -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 { b4 as E, E as o, bw as x, b2 as l, b9 as z, bx as L, b as c, m as k, by as j, bz as Z, ba as g, bA as W, bB as T, b8 as s, bC as _, bd as P, be as N, bv as F, b1 as q, $ as D, bf as H, _ as O } from "./index-
|
|
4
|
+
import { b4 as E, E as o, bw as x, b2 as l, b9 as z, bx as L, b as c, m as k, by as j, bz as Z, ba as g, bA as W, bB as T, b8 as s, bC as _, bd as P, be as N, bv as F, b1 as q, $ as D, bf as H, _ as O } from "./index-6NRj6D5S.mjs";
|
|
5
5
|
class B {
|
|
6
6
|
constructor(e, b, a, t) {
|
|
7
7
|
d(this, "network");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var H = Object.defineProperty;
|
|
2
2
|
var Q = (n, t, e) => t in n ? H(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
3
|
var d = (n, t, e) => Q(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
import { a9 as s, O as c, b2 as h, aW as X, aX as E, aY as W, aZ as Y, a_ as J, a$ as j, bE as $, bF as ee, bG as te, e as ne, f as K, bL as ie, bM as se, bN as ae, bO as re, bP as oe, bJ as x, bQ as ce, bR as N, bS as de, bT as v, ac as O, bU as ue, bV as ge, bW as me, bK as fe, bf as le, g as he } from "./index-
|
|
5
|
-
import { deriveWrappedMetaKey as G, deriveTokenBridgeConfigKey as R, deriveAuthoritySignerKey as pe, deriveSenderAccountKey as ye, deriveMintAuthorityKey as we, deriveEndpointKey as Se } from "./index-
|
|
4
|
+
import { a9 as s, O as c, b2 as h, aW as X, aX as E, aY as W, aZ as Y, a_ as J, a$ as j, bE as $, bF as ee, bG as te, e as ne, f as K, bL as ie, bM as se, bN as ae, bO as re, bP as oe, bJ as x, bQ as ce, bR as N, bS as de, bT as v, ac as O, bU as ue, bV as ge, bW as me, bK as fe, bf as le, g as he } from "./index-6NRj6D5S.mjs";
|
|
5
|
+
import { deriveWrappedMetaKey as G, deriveTokenBridgeConfigKey as R, deriveAuthoritySignerKey as pe, deriveSenderAccountKey as ye, deriveMintAuthorityKey as we, deriveEndpointKey as Se } from "./index-DV3sBKmN.mjs";
|
|
6
6
|
const ke = {
|
|
7
7
|
version: "0.1.0",
|
|
8
8
|
name: "wormhole_gateway",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Q = Object.defineProperty;
|
|
2
2
|
var j = (t, e, s) => e in t ? Q(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
|
|
3
3
|
var y = (t, e, s) => j(t, typeof e != "symbol" ? e + "" : e, s);
|
|
4
|
-
import { a9 as u, aW as Y, aX as I, aY as x, aZ as ee, a_ as ne, a$ as se, O as M, bE as O, bF as ae, bG as E, bH as N, bI as B, bJ as _, br as U, r as te, f as b, e as ie, bs as D, ad as T, bq as re, ao as me, bt as R, bK as oe, bf as ue, g as le } from "./index-
|
|
4
|
+
import { a9 as u, aW as Y, aX as I, aY as x, aZ as ee, a_ as ne, a$ as se, O as M, bE as O, bF as ae, bG as E, bH as N, bI as B, bJ as _, br as U, r as te, f as b, e as ie, bs as D, ad as T, bq as re, ao as me, bt as R, bK as oe, bf as ue, g as le } from "./index-6NRj6D5S.mjs";
|
|
5
5
|
const h = new u("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
|
6
6
|
new u("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");
|
|
7
7
|
const A = new u("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var V = Object.defineProperty;
|
|
2
2
|
var j = (p, e, t) => e in p ? V(p, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : p[e] = t;
|
|
3
3
|
var u = (p, e, t) => j(p, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { b1 as D, m as C, r as T, b2 as S, av as I, j as s, b3 as z, b4 as G, E as B, b as F, b5 as f, b6 as h, b7 as H, b8 as g, b9 as M, $ as v, ba as Y, bb as J, bc as K, bd as X, be as Z, bf as tt, _ as et } from "./index-
|
|
5
|
-
import { EvmTokenBridge as nt } from "./index-
|
|
4
|
+
import { b1 as D, m as C, r as T, b2 as S, av as I, j as s, b3 as z, b4 as G, E as B, b as F, b5 as f, b6 as h, b7 as H, b8 as g, b9 as M, $ as v, ba as Y, bb as J, bc as K, bd as X, be as Z, bf as tt, _ as et } from "./index-6NRj6D5S.mjs";
|
|
5
|
+
import { EvmTokenBridge as nt } from "./index-CbNgmtU7.mjs";
|
|
6
6
|
const y = new D([
|
|
7
7
|
"function start((bytes32,address,address,address,address,address,uint256,uint256,uint256,uint256)) returns (address,uint16,uint64)",
|
|
8
8
|
"function receiveMessageAndSwap(bytes)"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var b=Object.defineProperty;var T=(g,s,t)=>s in g?b(g,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):g[s]=t;var o=(g,s,t)=>T(g,typeof s!="symbol"?s+"":s,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index-
|
|
1
|
+
"use strict";var b=Object.defineProperty;var T=(g,s,t)=>s in g?b(g,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):g[s]=t;var o=(g,s,t)=>T(g,typeof s!="symbol"?s+"":s,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index-BpqVHbdc.js"),I=[["Testnet",{tokenMessengerState:"0x5252abd1137094ed1db3e0d75bc36abcd287aee4bc310f8e047727ef5682e7c2",messageTransmitterState:"0x98234bd0fa9ac12cc0a20a144a22e36d6a32f7e0a97baaeaf9c76cdc6d122d2e",usdcTreasury:"0x7170137d4a6431bf83351ac025baf462909bffe2877d87716374fb42b9629ebe"}],["Mainnet",{tokenMessengerState:"0x45993eecc0382f37419864992c12faee2238f5cfe22b98ad3bf455baf65c8a2f",messageTransmitterState:"0xf68268c3d9b1df3215f2439400c1c4ea08ac4ef4bb7d6f3ca6a2a239e17510af",usdcTreasury:"0x57d6725e7a8b49a7b2a612f6bd66ab5f39fc95332ca48be421c3229d514a6de7"}]],k=a.constMap(I,[0,1]);class l{constructor(s,t,r,e){o(this,"network");o(this,"chain");o(this,"provider");o(this,"contracts");o(this,"usdcId");o(this,"usdcTreasuryId");o(this,"tokenMessengerId");o(this,"tokenMessengerStateId");o(this,"messageTransmitterId");o(this,"messageTransmitterStateId");var u,m,h,f;if(this.network=s,this.chain=t,this.provider=r,this.contracts=e,s==="Devnet")throw new Error("CircleBridge not supported on Devnet");const n=a.usdcContract.get(this.network,this.chain);if(!n)throw new Error(`No USDC contract configured for network=${this.network} chain=${this.chain}`);const{tokenMessengerState:c,messageTransmitterState:i,usdcTreasury:d}=k(s);if(!((u=e.cctp)!=null&&u.tokenMessenger))throw new Error(`Circle Token Messenger contract for domain ${t} not found`);if(!((m=e.cctp)!=null&&m.messageTransmitter))throw new Error(`Circle Message Transmitter contract for domain ${t} not found`);this.usdcId=n,this.usdcTreasuryId=d,this.tokenMessengerId=(h=e.cctp)==null?void 0:h.tokenMessenger,this.messageTransmitterId=(f=e.cctp)==null?void 0:f.messageTransmitter,this.tokenMessengerStateId=c,this.messageTransmitterStateId=i}async*transfer(s,t,r){const e=new a.Transaction$1,n=a.circleChainId.get(this.network,t.chain),[c,...i]=await a.SuiPlatform.getCoins(this.provider,s,this.usdcId);if(c===void 0)throw new Error("No USDC in wallet");const d=e.object(c.coinObjectId);i.length>0&&e.mergeCoins(d,i.map(m=>e.object(m.coinObjectId)));const[u]=e.splitCoins(d,[r]);e.moveCall({target:`${this.tokenMessengerId}::deposit_for_burn::deposit_for_burn`,arguments:[u,e.pure.u32(n),e.pure.address(t.address.toUniversalAddress().toString()),e.object(this.tokenMessengerStateId),e.object(this.messageTransmitterStateId),e.object("0x403"),e.object(this.usdcTreasuryId)],typeArguments:[this.usdcId]}),yield this.createUnsignedTx(e,"Sui.CircleBridge.Transfer")}async isTransferCompleted(s){const t=new a.Transaction$1;t.moveCall({target:`${this.messageTransmitterId}::state::is_nonce_used`,arguments:[t.object(this.messageTransmitterStateId),t.pure.u32(s.sourceDomain),t.pure.u64(s.nonce)]});const r=await this.provider.devInspectTransactionBlock({sender:"0x0000000000000000000000000000000000000000000000000000000000000000",transactionBlock:t});try{return!!r.results[0].returnValues[0][0][0]}catch(e){return console.error(`Error reading if nonce was used: ${e}`),!1}}async*redeem(s,t,r){const e=new a.Transaction$1,[n]=e.moveCall({target:`${this.messageTransmitterId}::receive_message::receive_message`,arguments:[e.pure.vector("u8",a.CircleBridge.serialize(t)),e.pure.vector("u8",a.hex.decode(r)),e.object(this.messageTransmitterStateId)]});if(!n)throw new Error("Failed to produce receipt");const[c]=e.moveCall({target:`${this.tokenMessengerId}::handle_receive_message::handle_receive_message`,arguments:[n,e.object(this.tokenMessengerStateId),e.object("0x403"),e.object(this.usdcTreasuryId)],typeArguments:[this.usdcId]});if(!c)throw new Error("Failed to produce stamp receipt ticket with burn message");const[i]=e.moveCall({target:`${this.tokenMessengerId}::handle_receive_message::deconstruct_stamp_receipt_ticket_with_burn_message`,arguments:[c]});if(!i)throw new Error("Failed to produce stamp receipt ticket");const[d]=e.moveCall({target:`${this.messageTransmitterId}::receive_message::stamp_receipt`,arguments:[i,e.object(this.messageTransmitterStateId)],typeArguments:[`${this.tokenMessengerId}::message_transmitter_authenticator::MessageTransmitterAuthenticator`]});if(!d)throw new Error("Failed to produce stamped receipt");e.moveCall({target:`${this.messageTransmitterId}::receive_message::complete_receive_message`,arguments:[d,e.object(this.messageTransmitterStateId)]}),yield this.createUnsignedTx(e,"Sui.CircleBridge.Redeem")}async parseTransactionDetails(s){var p;const t=await this.provider.waitForTransaction({digest:s,options:{showEvents:!0,showEffects:!0,showInput:!0}});if(!t)throw new Error("Transaction not found");if(!t.events)throw new Error("Transaction events not found");const r=(p=t.events)==null?void 0:p.find(w=>w.type.includes("send_message::MessageSent"));if(!r)throw new Error("No MessageSent event found");const e=new Uint8Array((r==null?void 0:r.parsedJson).message),[n,c]=a.CircleBridge.deserialize(e),{payload:i}=n,d=i.messageSender,u=i.mintRecipient,m=a.toCircleChain(this.network,n.sourceDomain),h=a.toCircleChain(this.network,n.destinationDomain),f={chain:m,address:i.burnToken};return{from:{chain:m,address:d},to:{chain:h,address:u},token:f,amount:i.amount,message:n,id:{hash:c}}}static async fromRpc(s,t){const[r,e]=await a.SuiPlatform.chainFromRpc(s),n=t[e];if(n.network!==r)throw new Error(`Network mismatch: ${n.network} != ${r}`);return new l(r,e,s,n.contracts)}createUnsignedTx(s,t,r=!1){return new a.SuiUnsignedTransaction(s,this.network,this.chain,t,r)}}a.registerProtocol("Sui","CircleBridge",l);exports.SuiCircleBridge=l;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { aU as f, aV as c, a9 as s, aW as O, aX as t, aY as o, aZ as d, a_ as A, a$ as p } from "./index-
|
|
2
|
-
import { b0 as R } from "./index-
|
|
1
|
+
import { aU as f, aV as c, a9 as s, aW as O, aX as t, aY as o, aZ as d, a_ as A, a$ as p } from "./index-6NRj6D5S.mjs";
|
|
2
|
+
import { b0 as R } from "./index-6NRj6D5S.mjs";
|
|
3
3
|
class l extends Error {
|
|
4
4
|
constructor(r) {
|
|
5
5
|
super(r);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { s as ce, T as N, o as ot, n as _t, R as Do, t as H, y as gt, a as C, p as K } from "./index-
|
|
1
|
+
import { s as ce, T as N, o as ot, n as _t, R as Do, t as H, y as gt, a as C, p as K } from "./index-BRWk1KLF.mjs";
|
|
2
2
|
import { d as Uo } from "./dijkstra-BZM-8g-B.mjs";
|
|
3
|
-
import { O as Wo } from "./index-
|
|
3
|
+
import { O as Wo } from "./index-6NRj6D5S.mjs";
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2019 Google LLC
|
|
@@ -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 { N as y, bg as f0, bh as W, bi as p, bj as e0, bk as a0, bl as t0, bm as _, bn as b0, bo as n0, bp as d0, b4 as L, bq as O, E as v, b as C, br as D, r as N, b8 as u, bs as q, bb as c0, bt as U, bd as H, be as j, b2 as s0, bu as i0, bv as I, b1 as S, $, bf as V, _ as G } from "./index-
|
|
5
|
-
import "./index-
|
|
4
|
+
import { N as y, bg as f0, bh as W, bi as p, bj as e0, bk as a0, bl as t0, bm as _, bn as b0, bo as n0, bp as d0, b4 as L, bq as O, E as v, b as C, br as D, r as N, b8 as u, bs as q, bb as c0, bt as U, bd as H, be as j, b2 as s0, bu as i0, bv as I, b1 as S, $, bf as V, _ as G } from "./index-6NRj6D5S.mjs";
|
|
5
|
+
import "./index-CbNgmtU7.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) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var G=Object.defineProperty;var V=(n,i,t)=>i in n?G(n,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[i]=t;var c=(n,i,t)=>V(n,typeof i!="symbol"?i+"":i,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-Cvtp4dgE.js"),d=require("./index-ZK1P1tUH.js"),U={version:"0.1.0",name:"wormhole_gateway",instructions:[{name:"initialize",accounts:[{name:"authority",isMut:!0,isSigner:!0},{name:"custodian",isMut:!0,isSigner:!1},{name:"tbtcMint",isMut:!1,isSigner:!1,docs:["TBTC Program's mint PDA address bump is saved in this program's config. Ordinarily, we would","not have to deserialize this account. But we do in this case to make sure the TBTC program","has been initialized before this program."]},{name:"wrappedTbtcMint",isMut:!1,isSigner:!1},{name:"wrappedTbtcToken",isMut:!0,isSigner:!1},{name:"tokenBridgeSender",isMut:!1,isSigner:!1,docs:["sign for transferring via Token Bridge program with a message."]},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1}],args:[{name:"mintingLimit",type:"u64"}]},{name:"changeAuthority",accounts:[{name:"custodian",isMut:!0,isSigner:!1},{name:"authority",isMut:!1,isSigner:!0},{name:"newAuthority",isMut:!1,isSigner:!1}],args:[]},{name:"cancelAuthorityChange",accounts:[{name:"custodian",isMut:!0,isSigner:!1},{name:"authority",isMut:!1,isSigner:!0}],args:[]},{name:"takeAuthority",accounts:[{name:"custodian",isMut:!0,isSigner:!1},{name:"pendingAuthority",isMut:!1,isSigner:!0}],args:[]},{name:"updateGatewayAddress",accounts:[{name:"custodian",isMut:!1,isSigner:!1},{name:"gatewayInfo",isMut:!0,isSigner:!1},{name:"authority",isMut:!0,isSigner:!0},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"args",type:{defined:"UpdateGatewayAddressArgs"}}]},{name:"updateMintingLimit",accounts:[{name:"custodian",isMut:!0,isSigner:!1},{name:"authority",isMut:!1,isSigner:!0}],args:[{name:"newLimit",type:"u64"}]},{name:"receiveTbtc",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"custodian",isMut:!0,isSigner:!1},{name:"postedVaa",isMut:!1,isSigner:!1},{name:"tokenBridgeClaim",isMut:!0,isSigner:!1,docs:["transfer. By checking whether this account exists is a short-circuit way of bailing out","early if this transfer has already been redeemed (as opposed to letting the Token Bridge","instruction fail)."]},{name:"wrappedTbtcToken",isMut:!0,isSigner:!1,docs:["Custody account."]},{name:"wrappedTbtcMint",isMut:!0,isSigner:!1,docs:["This mint is owned by the Wormhole Token Bridge program. This PDA address is stored in the","custodian account."]},{name:"tbtcMint",isMut:!0,isSigner:!1},{name:"recipientToken",isMut:!0,isSigner:!1,docs:["Token account for minted tBTC.","","NOTE: Because the recipient is encoded in the transfer message payload, we can check the","authority from the deserialized VAA. But we should still check whether the authority is the","zero address in access control."]},{name:"recipient",isMut:!1,isSigner:!1,docs:["be created for him."]},{name:"recipientWrappedToken",isMut:!0,isSigner:!1,docs:["The gateway will create an associated token account for the recipient if it doesn't exist.","","NOTE: When the minting limit increases, the recipient can use this token account to mint","tBTC using the deposit_wormhole_tbtc instruction."]},{name:"tbtcConfig",isMut:!1,isSigner:!1},{name:"tbtcMinterInfo",isMut:!1,isSigner:!1},{name:"tokenBridgeConfig",isMut:!1,isSigner:!1},{name:"tokenBridgeRegisteredEmitter",isMut:!1,isSigner:!1},{name:"tokenBridgeWrappedAsset",isMut:!1,isSigner:!1},{name:"tokenBridgeMintAuthority",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"tbtcProgram",isMut:!1,isSigner:!1},{name:"tokenBridgeProgram",isMut:!1,isSigner:!1},{name:"coreBridgeProgram",isMut:!1,isSigner:!1},{name:"associatedTokenProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"messageHash",type:{array:["u8",32]}}]},{name:"sendTbtcGateway",accounts:[{name:"custodian",isMut:!0,isSigner:!1},{name:"gatewayInfo",isMut:!1,isSigner:!1},{name:"wrappedTbtcToken",isMut:!0,isSigner:!1,docs:["Custody account."]},{name:"wrappedTbtcMint",isMut:!0,isSigner:!1},{name:"tbtcMint",isMut:!0,isSigner:!1},{name:"senderToken",isMut:!0,isSigner:!1},{name:"sender",isMut:!0,isSigner:!0},{name:"tokenBridgeConfig",isMut:!1,isSigner:!1},{name:"tokenBridgeWrappedAsset",isMut:!1,isSigner:!1},{name:"tokenBridgeTransferAuthority",isMut:!1,isSigner:!1},{name:"coreBridgeData",isMut:!0,isSigner:!1},{name:"coreMessage",isMut:!0,isSigner:!1},{name:"tokenBridgeCoreEmitter",isMut:!1,isSigner:!1},{name:"coreEmitterSequence",isMut:!0,isSigner:!1},{name:"coreFeeCollector",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"tokenBridgeSender",isMut:!1,isSigner:!1,docs:["sign for transferring via Token Bridge program with a message."]},{name:"rent",isMut:!1,isSigner:!1},{name:"tokenBridgeProgram",isMut:!1,isSigner:!1},{name:"coreBridgeProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"args",type:{defined:"SendTbtcGatewayArgs"}}]},{name:"sendTbtcWrapped",accounts:[{name:"custodian",isMut:!0,isSigner:!1},{name:"wrappedTbtcToken",isMut:!0,isSigner:!1,docs:["Custody account."]},{name:"wrappedTbtcMint",isMut:!0,isSigner:!1},{name:"tbtcMint",isMut:!0,isSigner:!1},{name:"senderToken",isMut:!0,isSigner:!1},{name:"sender",isMut:!0,isSigner:!0},{name:"tokenBridgeConfig",isMut:!1,isSigner:!1},{name:"tokenBridgeWrappedAsset",isMut:!1,isSigner:!1},{name:"tokenBridgeTransferAuthority",isMut:!1,isSigner:!1},{name:"coreBridgeData",isMut:!0,isSigner:!1},{name:"coreMessage",isMut:!0,isSigner:!1},{name:"tokenBridgeCoreEmitter",isMut:!1,isSigner:!1},{name:"coreEmitterSequence",isMut:!0,isSigner:!1},{name:"coreFeeCollector",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"tokenBridgeProgram",isMut:!1,isSigner:!1},{name:"coreBridgeProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"args",type:{defined:"SendTbtcWrappedArgs"}}]},{name:"depositWormholeTbtc",accounts:[{name:"custodian",isMut:!0,isSigner:!1,docs:["NOTE: This account also acts as a minter for the TBTC program."]},{name:"wrappedTbtcToken",isMut:!0,isSigner:!1,docs:["This token account is owned by this program, whose mint is the wrapped TBTC mint. This PDA","address is stored in the custodian account."]},{name:"wrappedTbtcMint",isMut:!1,isSigner:!1,docs:["This mint is owned by the Wormhole Token Bridge program. This PDA address is stored in the","custodian account."]},{name:"tbtcMint",isMut:!0,isSigner:!1,docs:["This mint is owned by the TBTC program. This PDA address is stored in the custodian account."]},{name:"recipientWrappedToken",isMut:!0,isSigner:!1},{name:"recipientToken",isMut:!0,isSigner:!1},{name:"recipient",isMut:!1,isSigner:!0,docs:["This program requires that the owner of the TBTC token account sign for TBTC being minted","into his account."]},{name:"tbtcConfig",isMut:!1,isSigner:!1},{name:"tbtcMinterInfo",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"tbtcProgram",isMut:!1,isSigner:!1}],args:[{name:"amount",type:"u64"}]}],accounts:[{name:"custodian",type:{kind:"struct",fields:[{name:"bump",type:"u8"},{name:"authority",type:"publicKey"},{name:"pendingAuthority",type:{option:"publicKey"}},{name:"tbtcMint",type:"publicKey"},{name:"wrappedTbtcMint",type:"publicKey"},{name:"wrappedTbtcToken",type:"publicKey"},{name:"tokenBridgeSender",type:"publicKey"},{name:"tokenBridgeSenderBump",type:"u8"},{name:"mintingLimit",type:"u64"},{name:"mintedAmount",type:"u64"}]}},{name:"GatewayInfo",type:{kind:"struct",fields:[{name:"bump",type:"u8"},{name:"address",type:{array:["u8",32]}}]}}],types:[{name:"UpdateGatewayAddressArgs",type:{kind:"struct",fields:[{name:"chain",type:"u16"},{name:"address",type:{array:["u8",32]}}]}},{name:"SendTbtcGatewayArgs",type:{kind:"struct",fields:[{name:"amount",type:"u64"},{name:"recipientChain",type:"u16"},{name:"recipient",type:{array:["u8",32]}},{name:"nonce",type:"u32"}]}},{name:"SendTbtcWrappedArgs",type:{kind:"struct",fields:[{name:"amount",type:"u64"},{name:"recipientChain",type:"u16"},{name:"recipient",type:{array:["u8",32]}},{name:"arbiterFee",type:"u64"},{name:"nonce",type:"u32"}]}}],events:[{name:"WormholeTbtcReceived",fields:[{name:"receiver",type:"publicKey",index:!1},{name:"amount",type:"u64",index:!1}]},{name:"WormholeTbtcSent",fields:[{name:"amount",type:"u64",index:!1},{name:"recipientChain",type:"u16",index:!1},{name:"gateway",type:{array:["u8",32]},index:!1},{name:"recipient",type:{array:["u8",32]},index:!1},{name:"arbiterFee",type:"u64",index:!1},{name:"nonce",type:"u32",index:!1}]},{name:"WormholeTbtcDeposited",fields:[{name:"depositor",type:"publicKey",index:!1},{name:"amount",type:"u64",index:!1}]},{name:"GatewayAddressUpdated",fields:[{name:"chain",type:"u16",index:!1},{name:"gateway",type:{array:["u8",32]},index:!1}]},{name:"MintingLimitUpdated",fields:[{name:"mintingLimit",type:"u64",index:!1}]}],errors:[{code:6016,name:"MintingLimitExceeded",msg:"Cannot mint more than the minting limit"},{code:6032,name:"IsNotAuthority",msg:"Only custodian authority is permitted for this action"},{code:6034,name:"IsNotPendingAuthority",msg:"Not valid pending authority to take authority"},{code:6036,name:"NoPendingAuthorityChange",msg:"No pending authority"},{code:6048,name:"ZeroRecipient",msg:"0x0 recipient not allowed"},{code:6064,name:"NotEnoughWrappedTbtc",msg:"Not enough wormhole tBTC in the gateway to bridge"},{code:6080,name:"ZeroAmount",msg:"Amount must not be 0"},{code:6112,name:"TransferAlreadyRedeemed",msg:"Token Bridge transfer already redeemed"},{code:6128,name:"InvalidEthereumTbtc",msg:"Token chain and address do not match Ethereum's tBTC"},{code:6144,name:"NoTbtcTransferred",msg:"No tBTC transferred"},{code:6160,name:"RecipientZeroAddress",msg:"0x0 receiver not allowed"},{code:6176,name:"MintedAmountUnderflow",msg:"Not enough minted by the gateway to satisfy sending tBTC"},{code:6178,name:"MintedAmountOverflow",msg:"Minted amount after deposit exceeds u64"}]};function I(n){return e.PublicKey.findProgramAddressSync([e.dist.Buffer.from("redeemer")],new e.PublicKey(n))[0]}function q(n,i){const t=e.dist.Buffer.alloc(8);return t.writeBigUInt64LE(i),e.PublicKey.findProgramAddressSync([e.dist.Buffer.from("msg"),t],new e.PublicKey(n))[0]}function L(n,i){const t=e.dist.Buffer.alloc(2);return t.writeUInt16LE(e.toChainId(i)),e.PublicKey.findProgramAddressSync([e.dist.Buffer.from("gateway-info"),t],new e.PublicKey(n))[0]}const T=new e.PublicKey("Gj93RRt6QB7FjmyokAD5rcMAku7pq3Fk2Aa8y6nNbwsV");function D(){return e.PublicKey.findProgramAddressSync([e.dist.Buffer.from("config")],T)[0]}function _(n){return e.PublicKey.findProgramAddressSync([e.dist.Buffer.from("minter-info"),n.toBuffer()],T)[0]}const B=new e.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");new e.PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");const b=new e.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");new e.PublicKey("So11111111111111111111111111111111111111112");new e.PublicKey("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP");class F extends Error{constructor(i){super(i)}}class z extends F{constructor(){super(...arguments),this.name="TokenOwnerOffCurveError"}}const Y=e.struct([e.u32("mintAuthorityOption"),e.publicKey("mintAuthority"),e.u64("supply"),e.u8("decimals"),e.bool("isInitialized"),e.u32("freezeAuthorityOption"),e.publicKey("freezeAuthority")]);Y.span;async function M(n,i,t=!1,a=B,s=b){if(!t&&!e.PublicKey.isOnCurve(i.toBuffer()))throw new z;const[r]=await e.PublicKey.findProgramAddress([i.toBuffer(),a.toBuffer(),n.toBuffer()],s);return r}function H(n,i,t,a,s=B,r=b){return Z(n,i,t,a,e.dist.Buffer.alloc(0),s,r)}function Z(n,i,t,a,s,r=B,o=b){const u=[{pubkey:n,isSigner:!0,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:t,isSigner:!1,isWritable:!1},{pubkey:a,isSigner:!1,isWritable:!1},{pubkey:e.SystemProgram.programId,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!1}];return new e.TransactionInstruction({keys:u,programId:o,data:s})}class h{constructor(i,t,a,s){c(this,"network");c(this,"chain");c(this,"connection");c(this,"contracts");c(this,"gateway");c(this,"tokenBridgeId");c(this,"coreBridgeId");if(this.network=i,this.chain=t,this.connection=a,this.contracts=s,this.network!=="Mainnet")throw new Error("TBTC is only supported on Mainnet");if(!this.contracts.tbtc)throw new Error("TBTC contract address is required");if(!this.contracts.tokenBridge)throw new Error("TokenBridge contract address is required");if(!this.contracts.coreBridge)throw new Error("CoreBridge contract address is required");this.gateway=new e.Program(U,this.contracts.tbtc,{connection:a}),this.tokenBridgeId=new e.PublicKey(this.contracts.tokenBridge),this.coreBridgeId=new e.PublicKey(this.contracts.coreBridge)}static async fromRpc(i,t){const[a,s]=await e.SolanaPlatform.chainFromRpc(i),r=t[s];if(r.network!==a)throw new Error(`Network mismatch: ${r.network} != ${a}`);return new h(a,s,i,r.contracts)}async*transfer(i,t,a){const s=new e.SolanaAddress(i).unwrap(),r=I(this.gateway.programId),{tbtcMint:o,wrappedTbtcToken:u,wrappedTbtcMint:g}=await this.gateway.account.custodian.fetch(r),p=d.deriveWrappedMetaKey(this.tokenBridgeId,g),m=d.deriveTokenBridgeConfigKey(this.tokenBridgeId),l=d.deriveAuthoritySignerKey(this.tokenBridgeId),A=e.deriveFeeCollectorKey(this.coreBridgeId),{sequence:y}=await e.getProgramSequenceTracker(this.connection,this.tokenBridgeId,this.coreBridgeId),S=q(this.gateway.programId,y),w=e.deriveWormholeBridgeDataKey(this.coreBridgeId),f=e.deriveWormholeEmitterKey(this.tokenBridgeId),k=e.deriveEmitterSequenceKey(f,this.coreBridgeId),K=L(this.gateway.programId,t.chain),E=d.deriveSenderAccountKey(this.gateway.programId),P={amount:new e.BN(a.toString()),recipientChain:e.toChainId(t.chain),recipient:[...t.address.toUniversalAddress().toUint8Array()],nonce:0},W=await M(o,s),v=e.tbtc.get(this.network,t.chain),C={custodian:r,wrappedTbtcToken:u,wrappedTbtcMint:g,tbtcMint:o,senderToken:W,sender:s,tokenBridgeConfig:m,tokenBridgeWrappedAsset:p,tokenBridgeTransferAuthority:l,coreBridgeData:w,coreMessage:S,tokenBridgeCoreEmitter:f,coreEmitterSequence:k,coreFeeCollector:A,clock:e.SYSVAR_CLOCK_PUBKEY,rent:e.SYSVAR_RENT_PUBKEY,tokenBridgeProgram:this.tokenBridgeId,coreBridgeProgram:this.coreBridgeId},x=v?await this.gateway.methods.sendTbtcGateway({...P}).accounts({...C,gatewayInfo:K,tokenBridgeSender:E}).instruction():await this.gateway.methods.sendTbtcWrapped({...P,arbiterFee:new e.BN(0)}).accounts(C).instruction(),{blockhash:N}=await this.connection.getLatestBlockhash(),O=e.MessageV0.compile({instructions:[x],payerKey:s,recentBlockhash:N}),R=new e.VersionedTransaction(O);yield this.createUnsignedTransaction({transaction:R},"TBTCBridge.Send")}async*redeem(i,t){if(t.payloadName!=="GatewayTransfer")throw new Error("Invalid VAA payload");yield*new e.SolanaWormholeCore(this.network,this.chain,this.connection,this.contracts).postVaa(i,t);const s=[],r=new e.SolanaAddress(i).unwrap(),o=t.payload.payload.recipient.toNative(this.chain).unwrap(),u=I(this.gateway.programId),{tbtcMint:g,wrappedTbtcToken:p,wrappedTbtcMint:m}=await this.gateway.account.custodian.fetch(u),l=await M(g,o);await this.connection.getAccountInfo(l)||s.push(H(r,l,o,g));const y=d.deriveWrappedMetaKey(this.tokenBridgeId,m),S=await M(m,o);s.push(await this.gateway.methods.receiveTbtc([...t.hash]).accounts({payer:r,custodian:u,postedVaa:e.derivePostedVaaKey(this.coreBridgeId,e.dist.Buffer.from(t.hash)),tokenBridgeClaim:e.deriveClaimKey(this.tokenBridgeId,t.emitterAddress.toUint8Array(),e.toChainId(t.emitterChain),t.sequence),wrappedTbtcToken:p,wrappedTbtcMint:m,tbtcMint:g,recipientToken:l,recipient:o,recipientWrappedToken:S,tbtcConfig:D(),tbtcMinterInfo:_(u),tokenBridgeConfig:d.deriveTokenBridgeConfigKey(this.tokenBridgeId),tokenBridgeRegisteredEmitter:d.deriveEndpointKey(this.tokenBridgeId,e.toChainId(t.emitterChain),t.emitterAddress.toUint8Array()),tokenBridgeWrappedAsset:y,tokenBridgeMintAuthority:d.deriveMintAuthorityKey(this.tokenBridgeId),rent:e.SYSVAR_RENT_PUBKEY,tbtcProgram:T,tokenBridgeProgram:this.tokenBridgeId,coreBridgeProgram:this.coreBridgeId}).instruction());const{blockhash:w}=await this.connection.getLatestBlockhash(),f=e.MessageV0.compile({instructions:s,payerKey:r,recentBlockhash:w}),k=new e.VersionedTransaction(f);yield this.createUnsignedTransaction({transaction:k},"TBTCBridge.Send")}createUnsignedTransaction(i,t){return new e.SolanaUnsignedTransaction(i,this.network,this.chain,t,!1)}}e.registerProtocol(e._platform$1,"TBTCBridge",h);exports.SolanaTBTCBridge=h;
|
|
1
|
+
"use strict";var G=Object.defineProperty;var V=(n,i,t)=>i in n?G(n,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[i]=t;var c=(n,i,t)=>V(n,typeof i!="symbol"?i+"":i,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BpqVHbdc.js"),d=require("./index-BH76Gm64.js"),U={version:"0.1.0",name:"wormhole_gateway",instructions:[{name:"initialize",accounts:[{name:"authority",isMut:!0,isSigner:!0},{name:"custodian",isMut:!0,isSigner:!1},{name:"tbtcMint",isMut:!1,isSigner:!1,docs:["TBTC Program's mint PDA address bump is saved in this program's config. Ordinarily, we would","not have to deserialize this account. But we do in this case to make sure the TBTC program","has been initialized before this program."]},{name:"wrappedTbtcMint",isMut:!1,isSigner:!1},{name:"wrappedTbtcToken",isMut:!0,isSigner:!1},{name:"tokenBridgeSender",isMut:!1,isSigner:!1,docs:["sign for transferring via Token Bridge program with a message."]},{name:"systemProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1}],args:[{name:"mintingLimit",type:"u64"}]},{name:"changeAuthority",accounts:[{name:"custodian",isMut:!0,isSigner:!1},{name:"authority",isMut:!1,isSigner:!0},{name:"newAuthority",isMut:!1,isSigner:!1}],args:[]},{name:"cancelAuthorityChange",accounts:[{name:"custodian",isMut:!0,isSigner:!1},{name:"authority",isMut:!1,isSigner:!0}],args:[]},{name:"takeAuthority",accounts:[{name:"custodian",isMut:!0,isSigner:!1},{name:"pendingAuthority",isMut:!1,isSigner:!0}],args:[]},{name:"updateGatewayAddress",accounts:[{name:"custodian",isMut:!1,isSigner:!1},{name:"gatewayInfo",isMut:!0,isSigner:!1},{name:"authority",isMut:!0,isSigner:!0},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"args",type:{defined:"UpdateGatewayAddressArgs"}}]},{name:"updateMintingLimit",accounts:[{name:"custodian",isMut:!0,isSigner:!1},{name:"authority",isMut:!1,isSigner:!0}],args:[{name:"newLimit",type:"u64"}]},{name:"receiveTbtc",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"custodian",isMut:!0,isSigner:!1},{name:"postedVaa",isMut:!1,isSigner:!1},{name:"tokenBridgeClaim",isMut:!0,isSigner:!1,docs:["transfer. By checking whether this account exists is a short-circuit way of bailing out","early if this transfer has already been redeemed (as opposed to letting the Token Bridge","instruction fail)."]},{name:"wrappedTbtcToken",isMut:!0,isSigner:!1,docs:["Custody account."]},{name:"wrappedTbtcMint",isMut:!0,isSigner:!1,docs:["This mint is owned by the Wormhole Token Bridge program. This PDA address is stored in the","custodian account."]},{name:"tbtcMint",isMut:!0,isSigner:!1},{name:"recipientToken",isMut:!0,isSigner:!1,docs:["Token account for minted tBTC.","","NOTE: Because the recipient is encoded in the transfer message payload, we can check the","authority from the deserialized VAA. But we should still check whether the authority is the","zero address in access control."]},{name:"recipient",isMut:!1,isSigner:!1,docs:["be created for him."]},{name:"recipientWrappedToken",isMut:!0,isSigner:!1,docs:["The gateway will create an associated token account for the recipient if it doesn't exist.","","NOTE: When the minting limit increases, the recipient can use this token account to mint","tBTC using the deposit_wormhole_tbtc instruction."]},{name:"tbtcConfig",isMut:!1,isSigner:!1},{name:"tbtcMinterInfo",isMut:!1,isSigner:!1},{name:"tokenBridgeConfig",isMut:!1,isSigner:!1},{name:"tokenBridgeRegisteredEmitter",isMut:!1,isSigner:!1},{name:"tokenBridgeWrappedAsset",isMut:!1,isSigner:!1},{name:"tokenBridgeMintAuthority",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"tbtcProgram",isMut:!1,isSigner:!1},{name:"tokenBridgeProgram",isMut:!1,isSigner:!1},{name:"coreBridgeProgram",isMut:!1,isSigner:!1},{name:"associatedTokenProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"messageHash",type:{array:["u8",32]}}]},{name:"sendTbtcGateway",accounts:[{name:"custodian",isMut:!0,isSigner:!1},{name:"gatewayInfo",isMut:!1,isSigner:!1},{name:"wrappedTbtcToken",isMut:!0,isSigner:!1,docs:["Custody account."]},{name:"wrappedTbtcMint",isMut:!0,isSigner:!1},{name:"tbtcMint",isMut:!0,isSigner:!1},{name:"senderToken",isMut:!0,isSigner:!1},{name:"sender",isMut:!0,isSigner:!0},{name:"tokenBridgeConfig",isMut:!1,isSigner:!1},{name:"tokenBridgeWrappedAsset",isMut:!1,isSigner:!1},{name:"tokenBridgeTransferAuthority",isMut:!1,isSigner:!1},{name:"coreBridgeData",isMut:!0,isSigner:!1},{name:"coreMessage",isMut:!0,isSigner:!1},{name:"tokenBridgeCoreEmitter",isMut:!1,isSigner:!1},{name:"coreEmitterSequence",isMut:!0,isSigner:!1},{name:"coreFeeCollector",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"tokenBridgeSender",isMut:!1,isSigner:!1,docs:["sign for transferring via Token Bridge program with a message."]},{name:"rent",isMut:!1,isSigner:!1},{name:"tokenBridgeProgram",isMut:!1,isSigner:!1},{name:"coreBridgeProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"args",type:{defined:"SendTbtcGatewayArgs"}}]},{name:"sendTbtcWrapped",accounts:[{name:"custodian",isMut:!0,isSigner:!1},{name:"wrappedTbtcToken",isMut:!0,isSigner:!1,docs:["Custody account."]},{name:"wrappedTbtcMint",isMut:!0,isSigner:!1},{name:"tbtcMint",isMut:!0,isSigner:!1},{name:"senderToken",isMut:!0,isSigner:!1},{name:"sender",isMut:!0,isSigner:!0},{name:"tokenBridgeConfig",isMut:!1,isSigner:!1},{name:"tokenBridgeWrappedAsset",isMut:!1,isSigner:!1},{name:"tokenBridgeTransferAuthority",isMut:!1,isSigner:!1},{name:"coreBridgeData",isMut:!0,isSigner:!1},{name:"coreMessage",isMut:!0,isSigner:!1},{name:"tokenBridgeCoreEmitter",isMut:!1,isSigner:!1},{name:"coreEmitterSequence",isMut:!0,isSigner:!1},{name:"coreFeeCollector",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"tokenBridgeProgram",isMut:!1,isSigner:!1},{name:"coreBridgeProgram",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"args",type:{defined:"SendTbtcWrappedArgs"}}]},{name:"depositWormholeTbtc",accounts:[{name:"custodian",isMut:!0,isSigner:!1,docs:["NOTE: This account also acts as a minter for the TBTC program."]},{name:"wrappedTbtcToken",isMut:!0,isSigner:!1,docs:["This token account is owned by this program, whose mint is the wrapped TBTC mint. This PDA","address is stored in the custodian account."]},{name:"wrappedTbtcMint",isMut:!1,isSigner:!1,docs:["This mint is owned by the Wormhole Token Bridge program. This PDA address is stored in the","custodian account."]},{name:"tbtcMint",isMut:!0,isSigner:!1,docs:["This mint is owned by the TBTC program. This PDA address is stored in the custodian account."]},{name:"recipientWrappedToken",isMut:!0,isSigner:!1},{name:"recipientToken",isMut:!0,isSigner:!1},{name:"recipient",isMut:!1,isSigner:!0,docs:["This program requires that the owner of the TBTC token account sign for TBTC being minted","into his account."]},{name:"tbtcConfig",isMut:!1,isSigner:!1},{name:"tbtcMinterInfo",isMut:!1,isSigner:!1},{name:"tokenProgram",isMut:!1,isSigner:!1},{name:"tbtcProgram",isMut:!1,isSigner:!1}],args:[{name:"amount",type:"u64"}]}],accounts:[{name:"custodian",type:{kind:"struct",fields:[{name:"bump",type:"u8"},{name:"authority",type:"publicKey"},{name:"pendingAuthority",type:{option:"publicKey"}},{name:"tbtcMint",type:"publicKey"},{name:"wrappedTbtcMint",type:"publicKey"},{name:"wrappedTbtcToken",type:"publicKey"},{name:"tokenBridgeSender",type:"publicKey"},{name:"tokenBridgeSenderBump",type:"u8"},{name:"mintingLimit",type:"u64"},{name:"mintedAmount",type:"u64"}]}},{name:"GatewayInfo",type:{kind:"struct",fields:[{name:"bump",type:"u8"},{name:"address",type:{array:["u8",32]}}]}}],types:[{name:"UpdateGatewayAddressArgs",type:{kind:"struct",fields:[{name:"chain",type:"u16"},{name:"address",type:{array:["u8",32]}}]}},{name:"SendTbtcGatewayArgs",type:{kind:"struct",fields:[{name:"amount",type:"u64"},{name:"recipientChain",type:"u16"},{name:"recipient",type:{array:["u8",32]}},{name:"nonce",type:"u32"}]}},{name:"SendTbtcWrappedArgs",type:{kind:"struct",fields:[{name:"amount",type:"u64"},{name:"recipientChain",type:"u16"},{name:"recipient",type:{array:["u8",32]}},{name:"arbiterFee",type:"u64"},{name:"nonce",type:"u32"}]}}],events:[{name:"WormholeTbtcReceived",fields:[{name:"receiver",type:"publicKey",index:!1},{name:"amount",type:"u64",index:!1}]},{name:"WormholeTbtcSent",fields:[{name:"amount",type:"u64",index:!1},{name:"recipientChain",type:"u16",index:!1},{name:"gateway",type:{array:["u8",32]},index:!1},{name:"recipient",type:{array:["u8",32]},index:!1},{name:"arbiterFee",type:"u64",index:!1},{name:"nonce",type:"u32",index:!1}]},{name:"WormholeTbtcDeposited",fields:[{name:"depositor",type:"publicKey",index:!1},{name:"amount",type:"u64",index:!1}]},{name:"GatewayAddressUpdated",fields:[{name:"chain",type:"u16",index:!1},{name:"gateway",type:{array:["u8",32]},index:!1}]},{name:"MintingLimitUpdated",fields:[{name:"mintingLimit",type:"u64",index:!1}]}],errors:[{code:6016,name:"MintingLimitExceeded",msg:"Cannot mint more than the minting limit"},{code:6032,name:"IsNotAuthority",msg:"Only custodian authority is permitted for this action"},{code:6034,name:"IsNotPendingAuthority",msg:"Not valid pending authority to take authority"},{code:6036,name:"NoPendingAuthorityChange",msg:"No pending authority"},{code:6048,name:"ZeroRecipient",msg:"0x0 recipient not allowed"},{code:6064,name:"NotEnoughWrappedTbtc",msg:"Not enough wormhole tBTC in the gateway to bridge"},{code:6080,name:"ZeroAmount",msg:"Amount must not be 0"},{code:6112,name:"TransferAlreadyRedeemed",msg:"Token Bridge transfer already redeemed"},{code:6128,name:"InvalidEthereumTbtc",msg:"Token chain and address do not match Ethereum's tBTC"},{code:6144,name:"NoTbtcTransferred",msg:"No tBTC transferred"},{code:6160,name:"RecipientZeroAddress",msg:"0x0 receiver not allowed"},{code:6176,name:"MintedAmountUnderflow",msg:"Not enough minted by the gateway to satisfy sending tBTC"},{code:6178,name:"MintedAmountOverflow",msg:"Minted amount after deposit exceeds u64"}]};function I(n){return e.PublicKey.findProgramAddressSync([e.dist.Buffer.from("redeemer")],new e.PublicKey(n))[0]}function q(n,i){const t=e.dist.Buffer.alloc(8);return t.writeBigUInt64LE(i),e.PublicKey.findProgramAddressSync([e.dist.Buffer.from("msg"),t],new e.PublicKey(n))[0]}function L(n,i){const t=e.dist.Buffer.alloc(2);return t.writeUInt16LE(e.toChainId(i)),e.PublicKey.findProgramAddressSync([e.dist.Buffer.from("gateway-info"),t],new e.PublicKey(n))[0]}const T=new e.PublicKey("Gj93RRt6QB7FjmyokAD5rcMAku7pq3Fk2Aa8y6nNbwsV");function D(){return e.PublicKey.findProgramAddressSync([e.dist.Buffer.from("config")],T)[0]}function _(n){return e.PublicKey.findProgramAddressSync([e.dist.Buffer.from("minter-info"),n.toBuffer()],T)[0]}const B=new e.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");new e.PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");const b=new e.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");new e.PublicKey("So11111111111111111111111111111111111111112");new e.PublicKey("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP");class F extends Error{constructor(i){super(i)}}class z extends F{constructor(){super(...arguments),this.name="TokenOwnerOffCurveError"}}const Y=e.struct([e.u32("mintAuthorityOption"),e.publicKey("mintAuthority"),e.u64("supply"),e.u8("decimals"),e.bool("isInitialized"),e.u32("freezeAuthorityOption"),e.publicKey("freezeAuthority")]);Y.span;async function M(n,i,t=!1,a=B,s=b){if(!t&&!e.PublicKey.isOnCurve(i.toBuffer()))throw new z;const[r]=await e.PublicKey.findProgramAddress([i.toBuffer(),a.toBuffer(),n.toBuffer()],s);return r}function H(n,i,t,a,s=B,r=b){return Z(n,i,t,a,e.dist.Buffer.alloc(0),s,r)}function Z(n,i,t,a,s,r=B,o=b){const u=[{pubkey:n,isSigner:!0,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:t,isSigner:!1,isWritable:!1},{pubkey:a,isSigner:!1,isWritable:!1},{pubkey:e.SystemProgram.programId,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!1}];return new e.TransactionInstruction({keys:u,programId:o,data:s})}class h{constructor(i,t,a,s){c(this,"network");c(this,"chain");c(this,"connection");c(this,"contracts");c(this,"gateway");c(this,"tokenBridgeId");c(this,"coreBridgeId");if(this.network=i,this.chain=t,this.connection=a,this.contracts=s,this.network!=="Mainnet")throw new Error("TBTC is only supported on Mainnet");if(!this.contracts.tbtc)throw new Error("TBTC contract address is required");if(!this.contracts.tokenBridge)throw new Error("TokenBridge contract address is required");if(!this.contracts.coreBridge)throw new Error("CoreBridge contract address is required");this.gateway=new e.Program(U,this.contracts.tbtc,{connection:a}),this.tokenBridgeId=new e.PublicKey(this.contracts.tokenBridge),this.coreBridgeId=new e.PublicKey(this.contracts.coreBridge)}static async fromRpc(i,t){const[a,s]=await e.SolanaPlatform.chainFromRpc(i),r=t[s];if(r.network!==a)throw new Error(`Network mismatch: ${r.network} != ${a}`);return new h(a,s,i,r.contracts)}async*transfer(i,t,a){const s=new e.SolanaAddress(i).unwrap(),r=I(this.gateway.programId),{tbtcMint:o,wrappedTbtcToken:u,wrappedTbtcMint:g}=await this.gateway.account.custodian.fetch(r),p=d.deriveWrappedMetaKey(this.tokenBridgeId,g),m=d.deriveTokenBridgeConfigKey(this.tokenBridgeId),l=d.deriveAuthoritySignerKey(this.tokenBridgeId),A=e.deriveFeeCollectorKey(this.coreBridgeId),{sequence:y}=await e.getProgramSequenceTracker(this.connection,this.tokenBridgeId,this.coreBridgeId),S=q(this.gateway.programId,y),w=e.deriveWormholeBridgeDataKey(this.coreBridgeId),f=e.deriveWormholeEmitterKey(this.tokenBridgeId),k=e.deriveEmitterSequenceKey(f,this.coreBridgeId),K=L(this.gateway.programId,t.chain),E=d.deriveSenderAccountKey(this.gateway.programId),P={amount:new e.BN(a.toString()),recipientChain:e.toChainId(t.chain),recipient:[...t.address.toUniversalAddress().toUint8Array()],nonce:0},W=await M(o,s),v=e.tbtc.get(this.network,t.chain),C={custodian:r,wrappedTbtcToken:u,wrappedTbtcMint:g,tbtcMint:o,senderToken:W,sender:s,tokenBridgeConfig:m,tokenBridgeWrappedAsset:p,tokenBridgeTransferAuthority:l,coreBridgeData:w,coreMessage:S,tokenBridgeCoreEmitter:f,coreEmitterSequence:k,coreFeeCollector:A,clock:e.SYSVAR_CLOCK_PUBKEY,rent:e.SYSVAR_RENT_PUBKEY,tokenBridgeProgram:this.tokenBridgeId,coreBridgeProgram:this.coreBridgeId},x=v?await this.gateway.methods.sendTbtcGateway({...P}).accounts({...C,gatewayInfo:K,tokenBridgeSender:E}).instruction():await this.gateway.methods.sendTbtcWrapped({...P,arbiterFee:new e.BN(0)}).accounts(C).instruction(),{blockhash:N}=await this.connection.getLatestBlockhash(),O=e.MessageV0.compile({instructions:[x],payerKey:s,recentBlockhash:N}),R=new e.VersionedTransaction(O);yield this.createUnsignedTransaction({transaction:R},"TBTCBridge.Send")}async*redeem(i,t){if(t.payloadName!=="GatewayTransfer")throw new Error("Invalid VAA payload");yield*new e.SolanaWormholeCore(this.network,this.chain,this.connection,this.contracts).postVaa(i,t);const s=[],r=new e.SolanaAddress(i).unwrap(),o=t.payload.payload.recipient.toNative(this.chain).unwrap(),u=I(this.gateway.programId),{tbtcMint:g,wrappedTbtcToken:p,wrappedTbtcMint:m}=await this.gateway.account.custodian.fetch(u),l=await M(g,o);await this.connection.getAccountInfo(l)||s.push(H(r,l,o,g));const y=d.deriveWrappedMetaKey(this.tokenBridgeId,m),S=await M(m,o);s.push(await this.gateway.methods.receiveTbtc([...t.hash]).accounts({payer:r,custodian:u,postedVaa:e.derivePostedVaaKey(this.coreBridgeId,e.dist.Buffer.from(t.hash)),tokenBridgeClaim:e.deriveClaimKey(this.tokenBridgeId,t.emitterAddress.toUint8Array(),e.toChainId(t.emitterChain),t.sequence),wrappedTbtcToken:p,wrappedTbtcMint:m,tbtcMint:g,recipientToken:l,recipient:o,recipientWrappedToken:S,tbtcConfig:D(),tbtcMinterInfo:_(u),tokenBridgeConfig:d.deriveTokenBridgeConfigKey(this.tokenBridgeId),tokenBridgeRegisteredEmitter:d.deriveEndpointKey(this.tokenBridgeId,e.toChainId(t.emitterChain),t.emitterAddress.toUint8Array()),tokenBridgeWrappedAsset:y,tokenBridgeMintAuthority:d.deriveMintAuthorityKey(this.tokenBridgeId),rent:e.SYSVAR_RENT_PUBKEY,tbtcProgram:T,tokenBridgeProgram:this.tokenBridgeId,coreBridgeProgram:this.coreBridgeId}).instruction());const{blockhash:w}=await this.connection.getLatestBlockhash(),f=e.MessageV0.compile({instructions:s,payerKey:r,recentBlockhash:w}),k=new e.VersionedTransaction(f);yield this.createUnsignedTransaction({transaction:k},"TBTCBridge.Send")}createUnsignedTransaction(i,t){return new e.SolanaUnsignedTransaction(i,this.network,this.chain,t,!1)}}e.registerProtocol(e._platform$1,"TBTCBridge",h);exports.SolanaTBTCBridge=h;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var _t = Object.defineProperty;
|
|
2
2
|
var Pt = (e, t, r) => t in e ? _t(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
3
|
var f = (e, t, r) => Pt(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
import { a9 as c, O as l, aW as A, bF as le, a_ as z, aZ as U, a$ as Z, aY as S, aX as V, bX as Ze, bY as Ge, bZ as Wt, b_ as It, b$ as Ut, c0 as Nt, bR as O, bE as E, b2 as y, c1 as T, c2 as Ft, c3 as ye, bx as dt, c4 as xt, bG as lt, bH as zt, c5 as Ot, c6 as X, c7 as Lt, bV as G, bW as H, c8 as Dt, bS as qt, c9 as Kt, ca as Vt, cb as Se, cc as Zt, bJ as v, bU as Gt, e as oe, f as k, bw as Ce, b9 as Ht, m as $, bC as Be, cd as Yt, ce as Xt, ao as ae, ad as L, cf as Qt, bK as ft, bf as mt, g as gt } from "./index-
|
|
4
|
+
import { a9 as c, O as l, aW as A, bF as le, a_ as z, aZ as U, a$ as Z, aY as S, aX as V, bX as Ze, bY as Ge, bZ as Wt, b_ as It, b$ as Ut, c0 as Nt, bR as O, bE as E, b2 as y, c1 as T, c2 as Ft, c3 as ye, bx as dt, c4 as xt, bG as lt, bH as zt, c5 as Ot, c6 as X, c7 as Lt, bV as G, bW as H, c8 as Dt, bS as qt, c9 as Kt, ca as Vt, cb as Se, cc as Zt, bJ as v, bU as Gt, e as oe, f as k, bw as Ce, b9 as Ht, m as $, bC as Be, cd as Yt, ce as Xt, ao as ae, ad as L, cf as Qt, bK as ft, bf as mt, g as gt } from "./index-6NRj6D5S.mjs";
|
|
5
5
|
const M = new c("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
|
6
6
|
new c("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");
|
|
7
7
|
const Ae = new c("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), D = new c("So11111111111111111111111111111111111111112");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aG as F, aQ as L, aR as g, aS as k, aT as I, D as T, F as D } from "./index-
|
|
1
|
+
import { aG as F, aQ as L, aR as g, aS as k, aT as I, D as T, F as D } from "./index-6NRj6D5S.mjs";
|
|
2
2
|
function P(n, t, e, s) {
|
|
3
3
|
L(n);
|
|
4
4
|
const i = g({ dkLen: 32, asyncTick: 10 }, s), { c: u, dkLen: a, asyncTick: o } = i;
|