@cryptorubic/web3 0.12.7-alpha.solana-fail.6 → 0.12.7-alpha.tonapi.1

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": "@cryptorubic/web3",
3
- "version": "0.12.7-alpha.solana-fail.6",
3
+ "version": "0.12.7-alpha.tonapi.1",
4
4
  "dependencies": {
5
5
  "@ethersproject/bignumber": "^5.8.0",
6
6
  "@mysten/sui": "^1.24.0",
@@ -72,13 +72,13 @@ export interface TonApiTokenInfoForWalletResp {
72
72
  [k: string]: string;
73
73
  };
74
74
  };
75
- wallet_address: {
75
+ wallet_address?: {
76
76
  /** address of user's contract for this token */
77
77
  address: string;
78
78
  is_scam: boolean;
79
79
  is_wallet: boolean;
80
80
  };
81
- jetton: {
81
+ jetton?: {
82
82
  /** address of token(jetton) contract. Similaer to ERC20 contract address in EVM */
83
83
  address: string;
84
84
  name: string;
@@ -10,7 +10,7 @@ const web3_pure_1 = require("../../utils/web3-pure");
10
10
  class TonAdapter extends abstract_adapter_1.AbstractAdapter {
11
11
  constructor(httpClient, config, logger) {
12
12
  super(core_1.BLOCKCHAIN_NAME.TON, logger);
13
- this.tonApi = new ton_api_service_1.TonApiService(httpClient, config.tonApiConfig);
13
+ this.tonApi = new ton_api_service_1.TonApiService(httpClient, config.tonApiConfig, logger);
14
14
  this.tonClient = new ton_1.TonClient(config.tonClientConfig);
15
15
  }
16
16
  async callForTokensInfo(tokenAddresses) {
@@ -1,14 +1,15 @@
1
1
  import { TonApiAccountInfoResp, TonApiAllNonNullableTokenInfoForWalletResp, TonApiParseAddressResp, TonApiTokenInfoForWalletResp, TonApiTokenInfoResp, TonApiTxDataByBocResp } from '../models/tonapi-models';
2
2
  import { TonCenterBlockInfo } from '../models/toncenter-types';
3
- import { HttpClient } from '@cryptorubic/core';
3
+ import { HttpClient, ICustomLogger } from '@cryptorubic/core';
4
4
  import { TonApiConfig } from '../models/ton-api-config';
5
5
  import { Web3PrimitiveType } from '../../../utils/models/primitive-types';
6
6
  export declare class TonApiService {
7
7
  private readonly httpClient;
8
+ private readonly logger?;
8
9
  private readonly tonApiUrl;
9
10
  private readonly apiKey;
10
11
  private readonly tonCenterV3Url;
11
- constructor(httpClient: HttpClient, params: TonApiConfig);
12
+ constructor(httpClient: HttpClient, params: TonApiConfig, logger?: ICustomLogger | undefined);
12
13
  /**
13
14
  * @param walletAddress in any format: raw or friendly
14
15
  */
@@ -2,8 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TonApiService = void 0;
4
4
  class TonApiService {
5
- constructor(httpClient, params) {
5
+ constructor(httpClient, params, logger) {
6
6
  this.httpClient = httpClient;
7
+ this.logger = logger;
7
8
  this.apiKey = params.tonApiKey;
8
9
  this.tonApiUrl = params?.tonApiUrl || 'https://tonapi.io';
9
10
  this.tonCenterV3Url = params.tonCenterV3Url || 'https://toncenter.com/api/v3';
@@ -148,16 +149,23 @@ class TonApiService {
148
149
  * @returns balance, decimals, name, symbol, walletJettonAddress, jettonAddress
149
150
  */
150
151
  async fetchTokenInfoForWallet(walletAddress, tokenAddress) {
151
- const res = await this.httpClient.get(`${this.tonApiUrl}/v2/accounts/${walletAddress}/jettons/${tokenAddress}`, {
152
- headers: {
153
- apiKey: this.apiKey,
154
- referer: 'https://app.rubic.exchange'
152
+ try {
153
+ const res = await this.httpClient.get(`${this.tonApiUrl}/v2/accounts/${walletAddress}/jettons/${tokenAddress}`, {
154
+ headers: {
155
+ apiKey: this.apiKey,
156
+ referer: 'https://app.rubic.exchange'
157
+ }
158
+ });
159
+ if ('error' in res) {
160
+ this.logger?.customError('[TonApiService] ERROR IN fetchTokenInfoForWallet', res.error);
161
+ return { balance: '0' };
155
162
  }
156
- });
157
- if ('error' in res) {
158
- throw new Error(`[TonApiService] Error in fetchTokenInfoForWallet - ${res.error}`);
163
+ return res;
164
+ }
165
+ catch (err) {
166
+ this.logger?.customError('[TonApiService] ERROR IN fetchTokenInfoForWallet', err);
167
+ return { balance: '0' };
159
168
  }
160
- return res;
161
169
  }
162
170
  async fetchAllNonNullableTokensInfoForWallet(walletAddress) {
163
171
  const res = await this.httpClient.get(`${this.tonApiUrl}/v2/accounts/${walletAddress}/jettons`, {