@otoplo/wallet-common 0.6.1 → 0.8.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@otoplo/wallet-common",
3
- "version": "0.6.1",
3
+ "version": "0.8.0",
4
4
  "description": "Shared common library for internal use in Otoplo wallet",
5
5
  "license": "MIT",
6
6
  "author": "vgrunner",
@@ -32,12 +32,11 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@otoplo/electrum-client": "^2.0.0",
35
- "@scure/bip39": "^2.4.0",
36
- "js-big-decimal": "^2.2.0"
35
+ "@scure/bip39": "^2.4.0"
37
36
  },
38
37
  "devDependencies": {
39
38
  "eslint": "^10.16.0",
40
- "tsdown": "^0.23.7",
39
+ "tsdown": "^0.23.8",
41
40
  "typescript": "^6.0.3",
42
41
  "typescript-eslint": "^8.74.0"
43
42
  },
@@ -1,6 +1,6 @@
1
1
  import type { NftEntity, TokenEntity } from "../types/db.types";
2
2
  import { getAssetFileUrl, getAssetMetadataUrl } from "../utils/asset";
3
- import { currentTimestamp, tokenIdToHex } from "../utils/common";
3
+ import { balanceTotal, currentTimestamp, tokenIdToHex } from "../utils/common";
4
4
  import type { WalletDB } from "../persistence/wallet-db";
5
5
  import type { WalletCache } from "./cache";
6
6
  import type { AssetInfo, Balance } from "../types/wallet.types";
@@ -76,7 +76,7 @@ export class AssetService {
76
76
  public async syncTokens(accountId: number, tokenBalances: Record<string, Balance>): Promise<void> {
77
77
  for (const tokenId in tokenBalances) {
78
78
  const balance = tokenBalances[tokenId];
79
- if (balance && BigInt(balance.confirmed) + BigInt(balance.unconfirmed) > 0n) {
79
+ if (balance && balanceTotal(balance) > 0n) {
80
80
  const token = await this.getAssetInfo(tokenId);
81
81
  if (token && token.type == 'token') {
82
82
  const tokenEntity: TokenEntity = {
@@ -102,7 +102,7 @@ export class AssetService {
102
102
 
103
103
  for (const [token, balance] of Object.entries(tokensBalance)) {
104
104
  const tokenId = tokenIdToHex(token);
105
- const hasBalance = balance && BigInt(balance.confirmed) + BigInt(balance.unconfirmed) > 0n;
105
+ const hasBalance = balance && balanceTotal(balance) > 0n;
106
106
  const isAssetExist = internalAssets?.some(a => a.tokenIdHex == tokenId);
107
107
  if ((!hasBalance && !isAssetExist) || (hasBalance && isAssetExist)) {
108
108
  continue;
@@ -21,6 +21,9 @@ interface MarketDataResponse {
21
21
  total_volume?: number | null;
22
22
  }
23
23
 
24
+ /** Key of NEXA in the market data (`market_data_updated`'s `data`). */
25
+ export const NEXA_MARKET_ID = 'nexa';
26
+
24
27
  export type MarketEvent =
25
28
  | { type: 'market_data_updated'; currency: CurrencyCode; data: Record<string, MarketData> }
26
29
  | { type: 'currency_updated'; currency: CurrencyCode };
@@ -32,7 +35,7 @@ export class MarketService {
32
35
  private static readonly POLL_INTERVAL_MS = 2 * 60 * 1000;
33
36
  private static readonly CURRENCY_SETTING = "market-currency";
34
37
  private static readonly SUPPORTED_TOKENS: Record<string, string> = {
35
- nexacoin: 'nexa'
38
+ nexacoin: NEXA_MARKET_ID
36
39
  };
37
40
 
38
41
  private readonly walletDb: WalletDB;