"use strict";var m=Object.defineProperty;var C=(h,t,a)=>t in h?m(h,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):h[t]=a;var d=(h,t,a)=>C(h,typeof t!="symbol"?t+"":t,a);const l=require("./chunk-IMTC3J2M-D-un3eDX.js"),o=require("./address-RcMobNYE.js"),g=require("./chain-itK5uGYL.js"),u=require("./address-B-_yHNB2.js");class p extends g.ChainContext{}const c=class c extends g.PlatformContext{constructor(t,a){super(t,a??o.networkPlatformConfigs(t,c._platform))}getRpc(t){if(t in this.config){const a=this.network==="Mainnet"?l.e.MAINNET:l.e.TESTNET,e=new l.s({fullnode:this.config[t].rpc,network:a});return new l.t(e)}throw new Error("No configuration available for chain: "+t)}getChain(t,a){if(t in this.config)return new p(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 o.Wormhole.tokenId(a,u.APTOS_COIN)}static isNativeTokenId(t,a,e){return!this.isSupportedChain(a)||e.chain!==a?!1:this.nativeTokenId(t,a)==e}static isSupportedChain(t){return o.chainToPlatform(t)===c._platform}static async getDecimals(t,a,e){if(o.isNative(e)||e===u.APTOS_COIN)return o.nativeDecimals(c._platform);const n=e.toString();return(await a.getFungibleAssetMetadataByAssetType({assetType:n})).decimals}static async getBalance(t,a,e,n){var r;const i=o.isNative(n)?u.APTOS_COIN:n.toString();try{return((r=(await a.getCurrentFungibleAssetBalances({options:{where:{owner_address:{_eq:e},asset_type:{_eq:i}}}}))[0])==null?void 0:r.amount)??null}catch(s){if(s.status===404)return null;throw s}}static async getBalances(t,a,e,n){try{const i=await a.getCurrentFungibleAssetBalances({options:{where:{owner_address:{_eq:e}}}});let r={};for(const s of i)if(s.asset_type){let w=s.asset_type==="0x1::aptos_coin::AptosCoin"?"native":s.asset_type;r[w]=s.amount}return r}catch(i){if(i.status===404)return{};throw i}}static async sendWait(t,a,e){const n=[];for(const i of e){const r=await a.transaction.submit.simple(i.transaction),s=await a.waitForTransaction({transactionHash:r.hash});n.push(s.hash)}return n}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=o.platformNativeChainIdToNetworkChain(c._platform,BigInt(t));if(!a)throw new Error(`No matching chainId to determine network and chain: ${t}`);const[e,n]=a;return[e,n]}static async chainFromRpc(t){const a=await t.getLedgerInfo();return this.chainFromChainId(a.chain_id.toString())}};d(c,"_platform",u._platform);let f=c;exports.AptosChain=p;exports.AptosPlatform=f;
