const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-C9cy4cDs.js","main.mjs","main.css","assets/create-CbNCGANY.js","assets/chunk-KJH4KKG6-7L0Yrr0p.js","assets/index-S_2EIxuJ.js","assets/index-VWaDGczM.js","assets/index-ezhfpCvx.js","assets/unsignedTransaction-DgTB4Wlj.js","assets/index-C25bHdOM.js"])))=>i.map(i=>d[i]);
import{aw as f,ax as w,bf as g,az as m,aB as y,bg as h,aD as b,aE as d,aF as C,aH as v,bh as S,_ as u,bi as T,aK as A}from"../main.mjs";import{e as l,u as E,W as I,v as N,z as k}from"./chunk-KJH4KKG6-7L0Yrr0p.js";class _ extends f{}class o extends w{static _platform=g;constructor(t,a){super(t,a??m(t,o._platform))}getRpc(t){if(t in this.config){const a=this.network==="Mainnet"?l.MAINNET:l.TESTNET,n=new E({fullnode:this.config[t].rpc,network:a});return new I(n)}throw new Error("No configuration available for chain: "+t)}getChain(t,a){if(t in this.config)return new _(t,this);throw new Error("No configuration available for chain: "+t)}static nativeTokenId(t,a){if(!this.isSupportedChain(a))throw new Error(`invalid chain: ${a}`);return y.tokenId(a,h)}static isNativeTokenId(t,a,n){return!this.isSupportedChain(a)||n.chain!==a?!1:this.nativeTokenId(t,a)==n}static isSupportedChain(t){return b(t)===o._platform}static async getDecimals(t,a,n,e){if(d(e)||e===h)return C(o._platform);const s=e.toString();return(await n.getFungibleAssetMetadataByAssetType({assetType:s})).decimals}static async getBalance(t,a,n,e,s){const r=d(s)?h:s.toString();try{return(await n.getCurrentFungibleAssetBalances({options:{where:{owner_address:{_eq:e},asset_type:{_eq:r}}}}))[0]?.amount??null}catch(i){if(i.status===404)return null;throw i}}static async getBalances(t,a,n,e){try{const s=await n.getCurrentFungibleAssetBalances({options:{where:{owner_address:{_eq:e}}}});let r={};for(const i of s)if(i.asset_type){let p=i.asset_type==="0x1::aptos_coin::AptosCoin"?"native":i.asset_type;r[p]=i.amount}return r}catch(s){if(s.status===404)return{};throw s}}static async sendWait(t,a,n){const e=[];for(const s of n){const r=await a.transaction.submit.simple(s.transaction),i=await a.waitForTransaction({transactionHash:r.hash});e.push(i.hash)}return e}static async getLatestBlock(t){const a=await t.getLedgerInfo();return Number(a.block_height)}static async getLatestFinalizedBlock(t){const a=await t.getLedgerInfo();return Number(a.block_height)}static chainFromChainId(t){const a=v(o._platform,BigInt(t));if(!a)throw new Error(`No matching chainId to determine network and chain: ${t}`);const[n,e]=a;return[n,e]}static async chainFromRpc(t){const a=await t.getLedgerInfo();return this.chainFromChainId(a.chain_id.toString())}}async function x(c,t){const[a,n]=await o.chainFromRpc(c),e=N.fromPrivateKey({privateKey:new k(S.decode(t))});return new B(n,e,c)}class B{_chain;_account;_rpc;_debug;constructor(t,a,n,e){this._chain=t,this._account=a,this._rpc=n,this._debug=e}chain(){return this._chain}address(){return this._account.accountAddress.toString()}async signAndSend(t){const a=[];for(const n of t){const{description:e,transaction:s}=n;this._debug&&console.log(`Signing: ${e} for ${this.address()}`);const r=await this._rpc.transaction.build.simple({sender:this._account.accountAddress,data:s}),{hash:i}=await this._simSignSend(r);a.push(i)}return a}async _simSignSend(t){return await this._rpc.transaction.simulate.simple({signerPublicKey:this._account.publicKey,transaction:t}).then(a=>a.forEach(n=>{if(!n.success)throw new Error(`Transaction failed: ${n.vm_status}
${JSON.stringify(n,null,2)}`)})),this._rpc.signAndSubmitTransaction({signer:this._account,transaction:t}).then(a=>this._rpc.waitForTransaction({transactionHash:a.hash}))}}const F={Address:T,Platform:o,getSigner:x,protocols:{WormholeCore:()=>u(()=>import("./index-C9cy4cDs.js"),__vite__mapDeps([0,1,2,3,4,5,6])),TokenBridge:()=>u(()=>import("./index-ezhfpCvx.js"),__vite__mapDeps([7,1,2,4,5,6,8])),CircleBridge:()=>u(()=>import("./index-C25bHdOM.js"),__vite__mapDeps([9,4,1,2,5,6,8]))},getChain:(c,t,a)=>new _(t,new o(c,A(c,g,{[t]:a})))},L=Object.freeze(Object.defineProperty({__proto__:null,default:F},Symbol.toStringTag,{value:"Module"}));export{o as A,L as a};
