@cityofzion/bs-ethereum 2.7.8 → 2.7.10

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.
@@ -4,6 +4,7 @@ export declare class BSEthereumConstants {
4
4
  static DEFAULT_DECIMALS: number;
5
5
  static DEFAULT_GAS_LIMIT: number;
6
6
  static NATIVE_SYMBOL_BY_NETWORK_ID: Record<BSEthereumNetworkId, string>;
7
+ static NATIVE_WRAPPED_HASH_BY_NETWORK_ID: Partial<Record<BSEthereumNetworkId, string>>;
7
8
  static RPC_LIST_BY_NETWORK_ID: Record<BSEthereumNetworkId, string[]>;
8
9
  static DEFAULT_BIP44_DERIVATION_PATH: string;
9
10
  static NEOX_TESTNET_NETWORK_ID: BSEthereumNetworkId;
@@ -26,6 +26,9 @@ BSEthereumConstants.NATIVE_SYMBOL_BY_NETWORK_ID = {
26
26
  '47763': 'GAS',
27
27
  '12227332': 'GAS',
28
28
  };
29
+ BSEthereumConstants.NATIVE_WRAPPED_HASH_BY_NETWORK_ID = {
30
+ '1': '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
31
+ };
29
32
  BSEthereumConstants.RPC_LIST_BY_NETWORK_ID = {
30
33
  '1': [
31
34
  'https://eth.llamarpc.com',
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.BSEthereumHelper = void 0;
13
+ const blockchain_service_1 = require("@cityofzion/blockchain-service");
13
14
  const BSEthereumConstants_1 = require("../constants/BSEthereumConstants");
14
15
  class BSEthereumHelper {
15
16
  static getNativeAsset(network) {
@@ -28,7 +29,7 @@ class BSEthereumHelper {
28
29
  return BSEthereumConstants_1.BSEthereumConstants.MAINNET_NETWORK_IDS.includes(network.id);
29
30
  }
30
31
  static normalizeHash(hash) {
31
- return hash.startsWith('0x') ? hash.slice(2) : hash;
32
+ return (0, blockchain_service_1.normalizeHash)(hash);
32
33
  }
33
34
  static wait(duration) {
34
35
  return new Promise(resolve => {
@@ -280,7 +280,7 @@ class MoralisBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
280
280
  }
281
281
  }
282
282
  exports.MoralisBDSEthereum = MoralisBDSEthereum;
283
- MoralisBDSEthereum.BASE_URL = 'https://nxlrja2d1a.execute-api.us-east-1.amazonaws.com/production';
283
+ MoralisBDSEthereum.BASE_URL = 'https://dora.coz.io/api/v2/meta';
284
284
  MoralisBDSEthereum.SUPPORTED_CHAINS = [
285
285
  '1',
286
286
  '11155111',
@@ -23,6 +23,7 @@ var _MoralisEDSEthereum_instances, _MoralisEDSEthereum_network, _MoralisEDSEther
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.MoralisEDSEthereum = void 0;
25
25
  const blockchain_service_1 = require("@cityofzion/blockchain-service");
26
+ const BSEthereumConstants_1 = require("../../constants/BSEthereumConstants");
26
27
  const BSEthereumHelper_1 = require("../../helpers/BSEthereumHelper");
27
28
  const MoralisBDSEthereum_1 = require("../blockchain-data/MoralisBDSEthereum");
28
29
  class MoralisEDSEthereum extends blockchain_service_1.CryptoCompareEDS {
@@ -47,17 +48,25 @@ class MoralisEDSEthereum extends blockchain_service_1.CryptoCompareEDS {
47
48
  const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(__classPrivateFieldGet(this, _MoralisEDSEthereum_network, "f"));
48
49
  let wrappedNativeToken;
49
50
  if (params.tokens.some(token => token.symbol === nativeToken.symbol)) {
50
- wrappedNativeToken = yield __classPrivateFieldGet(this, _MoralisEDSEthereum_instances, "m", _MoralisEDSEthereum_getWrappedNativeToken).call(this);
51
+ try {
52
+ wrappedNativeToken = yield __classPrivateFieldGet(this, _MoralisEDSEthereum_instances, "m", _MoralisEDSEthereum_getWrappedNativeToken).call(this);
53
+ }
54
+ catch (_a) {
55
+ /* empty */
56
+ }
51
57
  }
52
- const tokensBody = params.tokens.map(token => {
58
+ const tokensBody = [];
59
+ params.tokens.map(token => {
53
60
  if (token.symbol !== nativeToken.symbol) {
54
- return {
61
+ tokensBody.push({
55
62
  token_address: token.hash,
56
- };
63
+ });
64
+ }
65
+ if (wrappedNativeToken) {
66
+ tokensBody.push({
67
+ token_address: wrappedNativeToken.hash,
68
+ });
57
69
  }
58
- return {
59
- token_address: wrappedNativeToken.hash,
60
- };
61
70
  });
62
71
  const splitTokensBody = [];
63
72
  for (let i = 0; i < tokensBody.length; i += __classPrivateFieldGet(this, _MoralisEDSEthereum_maxTokenPricesPerCall, "f")) {
@@ -69,10 +78,10 @@ class MoralisEDSEthereum extends blockchain_service_1.CryptoCompareEDS {
69
78
  tokens: body,
70
79
  });
71
80
  data.forEach(item => {
72
- var _a;
73
81
  let token;
74
- if (BSEthereumHelper_1.BSEthereumHelper.normalizeHash(item.tokenAddress) ===
75
- BSEthereumHelper_1.BSEthereumHelper.normalizeHash((_a = wrappedNativeToken === null || wrappedNativeToken === void 0 ? void 0 : wrappedNativeToken.hash) !== null && _a !== void 0 ? _a : '')) {
82
+ if (wrappedNativeToken &&
83
+ BSEthereumHelper_1.BSEthereumHelper.normalizeHash(item.tokenAddress) ===
84
+ BSEthereumHelper_1.BSEthereumHelper.normalizeHash(wrappedNativeToken.hash)) {
76
85
  token = nativeToken;
77
86
  }
78
87
  else {
@@ -135,10 +144,15 @@ exports.MoralisEDSEthereum = MoralisEDSEthereum;
135
144
  _MoralisEDSEthereum_network = new WeakMap(), _MoralisEDSEthereum_blockchainDataService = new WeakMap(), _MoralisEDSEthereum_numberOfBlockByHour = new WeakMap(), _MoralisEDSEthereum_numberOfBlockByDay = new WeakMap(), _MoralisEDSEthereum_maxTokenPricesPerCall = new WeakMap(), _MoralisEDSEthereum_instances = new WeakSet(), _MoralisEDSEthereum_getWrappedNativeToken = function _MoralisEDSEthereum_getWrappedNativeToken() {
136
145
  return __awaiter(this, void 0, void 0, function* () {
137
146
  const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(__classPrivateFieldGet(this, _MoralisEDSEthereum_network, "f"));
147
+ const wrappedSymbol = `W${nativeToken.symbol}`;
148
+ const localWrappedHash = BSEthereumConstants_1.BSEthereumConstants.NATIVE_WRAPPED_HASH_BY_NETWORK_ID[__classPrivateFieldGet(this, _MoralisEDSEthereum_network, "f").id];
149
+ if (localWrappedHash) {
150
+ return Object.assign(Object.assign({}, nativeToken), { symbol: wrappedSymbol, hash: localWrappedHash });
151
+ }
138
152
  const client = MoralisBDSEthereum_1.MoralisBDSEthereum.getClient(__classPrivateFieldGet(this, _MoralisEDSEthereum_network, "f"));
139
153
  const { data } = yield client.get('/erc20/metadata/symbols', {
140
154
  params: {
141
- symbols: [`W${nativeToken.symbol}`],
155
+ symbols: [wrappedSymbol],
142
156
  },
143
157
  });
144
158
  const wrapperToken = data.find(token => token.verified_contract && !token.possible_spam);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityofzion/bs-ethereum",
3
- "version": "2.7.8",
3
+ "version": "2.7.10",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": "https://github.com/CityOfZion/blockchain-services",
@@ -20,7 +20,7 @@
20
20
  "@ledgerhq/hw-app-eth": "~6.35.7",
21
21
  "@ethersproject/abstract-signer": "~5.7.0",
22
22
  "@ethersproject/properties": "~5.7.0",
23
- "@cityofzion/blockchain-service": "1.12.0"
23
+ "@cityofzion/blockchain-service": "1.13.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@ledgerhq/hw-transport-node-hid": "~6.28.5",