UNPKG

@creit.tech/stellar-wallets-kit

Version:
1 lines 1.31 kB
{"version":3,"file":"account.service.cjs","sources":["../../src/services/account.service.ts"],"sourcesContent":["import { firstValueFrom } from 'rxjs';\nimport { horizonUrl$ } from '../state/store';\n\nexport async function fetchAccountBalance(pk: string): Promise<string> {\n const horizonUrl: string | undefined = await firstValueFrom(horizonUrl$);\n if (!horizonUrl) {\n throw new Error('There is no Horizon URL set');\n }\n const url: URL = new URL(horizonUrl);\n url.pathname = `/accounts/${pk}`;\n const response: Response = await fetch(url);\n const data = await response.json();\n const nativeBalance = data.balances.find((b: { asset_type: string }): boolean => b.asset_type === 'native');\n return nativeBalance.balance;\n}\n"],"names":["firstValueFrom","horizonUrl$"],"mappings":";;;;;AAGO,eAAe,mBAAmB,CAAC,EAAU,EAAA;AAClD,IAAA,MAAM,UAAU,GAAuB,MAAMA,mBAAc,CAACC,iBAAW,CAAC;IACxE,IAAI,CAAC,UAAU,EAAE;AACf,QAAA,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC;;AAEhD,IAAA,MAAM,GAAG,GAAQ,IAAI,GAAG,CAAC,UAAU,CAAC;AACpC,IAAA,GAAG,CAAC,QAAQ,GAAG,CAAa,UAAA,EAAA,EAAE,EAAE;AAChC,IAAA,MAAM,QAAQ,GAAa,MAAM,KAAK,CAAC,GAAG,CAAC;AAC3C,IAAA,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE;AAClC,IAAA,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAyB,KAAc,CAAC,CAAC,UAAU,KAAK,QAAQ,CAAC;IAC3G,OAAO,aAAa,CAAC,OAAO;AAC9B;;;;"}