-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a13819
commit 788bfe3
Showing
7 changed files
with
88 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Coin } from "@cosmjs/amino"; | ||
import { Chain } from "./types/chains"; | ||
|
||
if (!process.env.DENO_SERVERLESS_URL) { | ||
throw new Error("DENO_SERVERLESS_URL not set..."); | ||
} | ||
export const denoUrl = process.env.DENO_SERVERLESS_URL; | ||
|
||
export interface CoinIBC extends Coin { | ||
ibc: boolean; | ||
ibc_denom?: string; | ||
display: string; | ||
} | ||
|
||
export interface ChainBalances extends Chain { | ||
balances: CoinIBC[]; | ||
} | ||
|
||
export const getBalances = async (chains: Chain[]): Promise<ChainBalances[]> => { | ||
try { | ||
const res = await fetch(`${denoUrl}/balances`, { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json', 'Cache-Control': 'no-cache' }, | ||
body: JSON.stringify({ chains: chains }) | ||
}); | ||
|
||
if (!res.ok) { | ||
throw new Error(`HTTP error ${res.status}`); | ||
} | ||
|
||
const data = await res.json(); | ||
|
||
return data.balances; | ||
} catch (error) { | ||
console.error(error); | ||
throw error; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters