@zerochain/sdk
Version:
The Züs JS SDK is a JavaScript client library that provides a convenient interface for interacting with the Züs Network. It allows developers to perform various operations such as creating and managing allocations, uploading and downloading files, executi
36 lines (33 loc) • 912 B
text/typescript
import { getWasm } from '@/setup/wasm'
import type { NetworkDomain } from '@/types/wallet'
type TokenSymbol = 'zcn' | 'eth' | (string & {})
/** Retrieves the USD rate for a given token symbol. */
export const getUSDRate = async ({
domain,
symbol = 'zcn',
}: {
domain: NetworkDomain
/** Token symbol for which the USD rate is fetched. */
symbol?: TokenSymbol
}): Promise<number> => {
const goWasm = await getWasm({ domain })
return await goWasm.sdk.getUSDRate(symbol)
}
type Balance = {
zcn: number
usd: number
nonce: number
}
/** getWalletBalance retrieves the wallet balance of the client from the network */
export const getWalletBalance = async ({
domain,
clientId,
}: {
domain: NetworkDomain
/** Wallet ID */
clientId: string
}): Promise<Balance> => {
const goWasm = await getWasm({ domain })
const balance = await goWasm.sdk.getWalletBalance(clientId)
return balance
}