@cryptorubic/web3 1.1.0-alpha-stellar.21 → 1.1.0-alpha-stellar.23

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": "1.1.0-alpha-stellar.21",
3
+ "version": "1.1.0-alpha-stellar.23",
4
4
  "dependencies": {
5
5
  "@ethersproject/bignumber": "^5.8.0",
6
6
  "@mysten/sui": "^1.24.0",
@@ -38,8 +38,7 @@ class StellarAdapter extends abstract_adapter_1.AbstractAdapter {
38
38
  const resp = await this.public.getTrustline(userAddress, this.convertTokenAddressToAsset(tokenAddress));
39
39
  return new bignumber_js_1.default(resp.balance().toString());
40
40
  }
41
- catch (err) {
42
- console.error(err);
41
+ catch {
43
42
  return new bignumber_js_1.default(0);
44
43
  }
45
44
  }
@@ -13,6 +13,7 @@ const ton_web3_pure_1 = require("../web3-types/ton-web3-pure");
13
13
  const tron_web3_pure_1 = require("../web3-types/tron-web3-pure");
14
14
  const changenow_api_blockchain_1 = require("./changenow-api-blockchain");
15
15
  const zcash_web3_pure_1 = require("../web3-types/zcash-web3-pure");
16
+ const stellar_web3_pure_1 = require("../web3-types/stellar-web3-pure");
16
17
  exports.web3PureStore = {
17
18
  [core_1.CHAIN_TYPE.EVM]: new evm_web3_pure_1.EvmWeb3Pure(),
18
19
  [core_1.CHAIN_TYPE.SUI]: new sui_web3_pure_1.SuiWeb3Pure(),
@@ -25,6 +26,7 @@ exports.web3PureStore = {
25
26
  [core_1.CHAIN_TYPE.BSV]: new bitcoin_web3_pure_1.BitcoinWeb3Pure(),
26
27
  [core_1.CHAIN_TYPE.NEAR]: new near_web3_pure_1.NearWeb3Pure(),
27
28
  [core_1.CHAIN_TYPE.ZCASH]: new zcash_web3_pure_1.ZcashWeb3Pure(),
29
+ [core_1.CHAIN_TYPE.STELLAR]: new stellar_web3_pure_1.StellarWeb3Pure(),
28
30
  // Common Web3
29
31
  [core_1.CHAIN_TYPE.RIPPLE]: new common_web3_pure_1.CommonWeb3Pure({
30
32
  cnApiKey: changenow_api_blockchain_1.changenowApiBlockchain.RIPPLE,
@@ -133,10 +135,6 @@ exports.web3PureStore = {
133
135
  cnApiKey: changenow_api_blockchain_1.changenowApiBlockchain.WAX,
134
136
  regex: /^[a-z1-5.]{1,12}$/
135
137
  }),
136
- [core_1.CHAIN_TYPE.STELLAR]: new common_web3_pure_1.CommonWeb3Pure({
137
- cnApiKey: changenow_api_blockchain_1.changenowApiBlockchain.STEEM,
138
- regex: /^G[A-D]{1}[A-Z2-7]{54}$/
139
- }),
140
138
  [core_1.CHAIN_TYPE.XDC]: new common_web3_pure_1.CommonWeb3Pure({
141
139
  cnApiKey: changenow_api_blockchain_1.changenowApiBlockchain.XDC,
142
140
  regex: /^xdc[a-fA-F\d]{40}$/
@@ -0,0 +1,5 @@
1
+ import { CommonWeb3Pure } from './common-web3-pure';
2
+ export declare class StellarWeb3Pure extends CommonWeb3Pure {
3
+ constructor();
4
+ isAddressCorrect(address: string): Promise<boolean>;
5
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StellarWeb3Pure = void 0;
4
+ const stellar_sdk_1 = require("@stellar/stellar-sdk");
5
+ const changenow_api_blockchain_1 = require("../constants/changenow-api-blockchain");
6
+ const common_web3_pure_1 = require("./common-web3-pure");
7
+ class StellarWeb3Pure extends common_web3_pure_1.CommonWeb3Pure {
8
+ constructor() {
9
+ super({
10
+ cnApiKey: changenow_api_blockchain_1.changenowApiBlockchain.STELLAR,
11
+ regex: /^G[A-Z2-7]{55}$/
12
+ });
13
+ }
14
+ async isAddressCorrect(address) {
15
+ try {
16
+ if (address.includes('-')) {
17
+ const [code, issuer] = address.split('-');
18
+ if (!code || !issuer)
19
+ return false;
20
+ new stellar_sdk_1.Asset(code, issuer);
21
+ return true;
22
+ }
23
+ return this.regEx.test(address);
24
+ }
25
+ catch {
26
+ return false;
27
+ }
28
+ }
29
+ }
30
+ exports.StellarWeb3Pure = StellarWeb3Pure;