@raac/rpc 1.1.0-beta.10 → 1.1.0-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,12 +2,8 @@ import { Provider } from "ethers";
2
2
  import { AssetType } from "../../utils/artifacts";
3
3
  import { ChainId } from "../../configs/chains/index";
4
4
  declare function getBalance(chainId: ChainId, assetId: AssetType, address: string, provider: Provider): Promise<{
5
- balance: number;
5
+ balance: string;
6
6
  symbol: string;
7
7
  decimals: number;
8
- } | {
9
- balance: string;
10
- symbol: any;
11
- decimals: any;
12
8
  }>;
13
9
  export default getBalance;
@@ -7,7 +7,7 @@ async function getBalance(chainId, assetId, address, provider) {
7
7
  try {
8
8
  if (assetId === "eth") {
9
9
  const balance = await provider.getBalance(address);
10
- const parsedBalance = parseFloat(ethers_1.ethers.formatEther(balance));
10
+ const parsedBalance = (ethers_1.ethers.formatEther(balance));
11
11
  return {
12
12
  balance: parsedBalance,
13
13
  symbol: "ETH",
@@ -17,19 +17,19 @@ async function getBalance(chainId, assetId, address, provider) {
17
17
  const contractAddress = (0, contracts_1.getContractAddress)(chainId, assetId);
18
18
  const contract = new ethers_1.ethers.Contract(contractAddress, BALANCE_OF_ABI, provider);
19
19
  const balance = await contract.balanceOf(address);
20
- const symbol = await contract.symbol();
21
- const decimals = await contract.decimals();
20
+ const symbol = (await contract.symbol())?.toString() || "";
21
+ const decimals = parseInt(await contract.decimals()) || 0;
22
22
  const parsedBalance = ethers_1.ethers.formatUnits(balance, decimals);
23
23
  return {
24
24
  balance: parsedBalance,
25
- symbol,
25
+ symbol: symbol,
26
26
  decimals,
27
27
  };
28
28
  }
29
29
  catch (error) {
30
30
  console.error(`Error getting balance for asset ${assetId}:`, error);
31
31
  return {
32
- balance: 0,
32
+ balance: "0",
33
33
  symbol: "",
34
34
  decimals: 0,
35
35
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raac/rpc",
3
- "version": "1.1.0-beta.10",
3
+ "version": "1.1.0-beta.11",
4
4
  "description": "RPC Library for RAAC ",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",