const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CVqQ68io.js","main.js","main.css","assets/create-CbRd6EbF.js","assets/chain-DF9mIQM9.js","assets/chunk-KJH4KKG6-B7DCZZVY.js","assets/index-CVqXQiSE.js","assets/index-VWaDGczM.js","assets/index-DKdokzug.js","assets/unsignedTransaction-DsxtoHjl.js","assets/index-BTkoFKAW.js"])))=>i.map(i=>d[i]);
var w=Object.defineProperty;var y=(e,t,a)=>t in e?w(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;var h=(e,t,a)=>y(e,typeof t!="symbol"?t+"":t,a);import{a_ as g,an as C,ap as b,a$ as l,m as v,ar as p,as as S,au as T,aZ as A,_ as d,b0 as E,ax as I}from"../main.js";import{C as N,P as k}from"./chain-DF9mIQM9.js";import{e as _,u as x,W as P,v as B,z as F}from"./chunk-KJH4KKG6-B7DCZZVY.js";class f extends N{}const c=class c extends k{constructor(t,a){super(t,a??C(t,c._platform))}getRpc(t){if(t in this.config){const a=this.network==="Mainnet"?_.MAINNET:_.TESTNET,n=new x({fullnode:this.config[t].rpc,network:a});return new P(n)}throw new Error("No configuration available for chain: "+t)}getChain(t,a){if(t in this.config)return new f(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 b.tokenId(a,l)}static isNativeTokenId(t,a,n){return!this.isSupportedChain(a)||n.chain!==a?!1:this.nativeTokenId(t,a)==n}static isSupportedChain(t){return v(t)===c._platform}static async getDecimals(t,a,n){if(p(n)||n===l)return S(c._platform);const s=n.toString();return(await a.getFungibleAssetMetadataByAssetType({assetType:s})).decimals}static async getBalance(t,a,n,s){var o;const r=p(s)?l:s.toString();try{return((o=(await a.getCurrentFungibleAssetBalances({options:{where:{owner_address:{_eq:n},asset_type:{_eq:r}}}}))[0])==null?void 0:o.amount)??null}catch(i){if(i.status===404)return null;throw i}}static async getBalances(t,a,n,s){try{const r=await a.getCurrentFungibleAssetBalances({options:{where:{owner_address:{_eq:n}}}});let o={};for(const i of r)if(i.asset_type){let m=i.asset_type==="0x1::aptos_coin::AptosCoin"?"native":i.asset_type;o[m]=i.amount}return o}catch(r){if(r.status===404)return{};throw r}}static async sendWait(t,a,n){const s=[];for(const r of n){const o=await a.transaction.submit.simple(r.transaction),i=await a.waitForTransaction({transactionHash:o.hash});s.push(i.hash)}return s}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=T(c._platform,BigInt(t));if(!a)throw new Error(`No matching chainId to determine network and chain: ${t}`);const[n,s]=a;return[n,s]}static async chainFromRpc(t){const a=await t.getLedgerInfo();return this.chainFromChainId(a.chain_id.toString())}};h(c,"_platform",g);let u=c;async function O(e,t){const[a,n]=await u.chainFromRpc(e),s=B.fromPrivateKey({privateKey:new F(A.decode(t))});return new L(n,s,e)}class L{constructor(t,a,n,s){h(this,"_chain");h(this,"_account");h(this,"_rpc");h(this,"_debug");this._chain=t,this._account=a,this._rpc=n,this._debug=s}chain(){return this._chain}address(){return this._account.accountAddress.toString()}async signAndSend(t){const a=[];for(const n of t){const{description:s,transaction:r}=n;this._debug&&console.log(`Signing: ${s} for ${this.address()}`);const o=await this._rpc.transaction.build.simple({sender:this._account.accountAddress,data:r}),{hash:i}=await this._simSignSend(o);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 $={Address:E,Platform:u,getSigner:O,protocols:{WormholeCore:()=>d(()=>import("./index-CVqQ68io.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])),TokenBridge:()=>d(()=>import("./index-DKdokzug.js"),__vite__mapDeps([8,1,2,9,4,5,6,7])),CircleBridge:()=>d(()=>import("./index-BTkoFKAW.js"),__vite__mapDeps([10,5,1,2,6,7,9,4]))},getChain:(e,t,a)=>new f(t,new u(e,I(e,g,{[t]:a})))},M=Object.freeze(Object.defineProperty({__proto__:null,default:$},Symbol.toStringTag,{value:"Module"}));export{u as A,M as a};
