@cityofzion/bs-neo-legacy 1.0.4 → 1.1.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.
@@ -48,7 +48,7 @@ class BSNeoLegacy {
48
48
  __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_setTokens).call(this, network);
49
49
  this.network = network;
50
50
  this.blockchainDataService = new DoraBDSNeoLegacy_1.DoraBDSNeoLegacy(network, this.feeToken, this.claimToken, this.tokens);
51
- this.exchangeDataService = new CryptoCompareEDSNeoLegacy_1.CryptoCompareEDSNeoLegacy(network, this.tokens);
51
+ this.exchangeDataService = new CryptoCompareEDSNeoLegacy_1.CryptoCompareEDSNeoLegacy(network);
52
52
  this.explorerService = new NeoTubeESNeoLegacy_1.NeoTubeESNeoLegacy(network);
53
53
  }
54
54
  validateAddress(address) {
@@ -95,8 +95,8 @@ class BSNeoLegacy {
95
95
  const nep5ScriptBuilder = new neon_js_1.sc.ScriptBuilder();
96
96
  const intents = [transferIntent, ...(tipIntent ? [tipIntent] : [])];
97
97
  for (const intent of intents) {
98
- const tokenHashFixed = intent.tokenHash.replace('0x', '');
99
- const nativeAsset = BSNeoLegacyHelper_1.BSNeoLegacyHelper.NATIVE_ASSETS.find(asset => asset.hash === tokenHashFixed);
98
+ const tokenHashFixed = BSNeoLegacyHelper_1.BSNeoLegacyHelper.normalizeHash(intent.tokenHash);
99
+ const nativeAsset = BSNeoLegacyHelper_1.BSNeoLegacyHelper.NATIVE_ASSETS.find(asset => BSNeoLegacyHelper_1.BSNeoLegacyHelper.normalizeHash(asset.hash) === tokenHashFixed);
100
100
  if (nativeAsset) {
101
101
  nativeIntents.push(...neon_js_1.api.makeIntent({ [nativeAsset.symbol]: Number(intent.amount) }, intent.receiverAddress));
102
102
  continue;
@@ -26,4 +26,5 @@ export declare class BSNeoLegacyHelper {
26
26
  }[];
27
27
  static getRpcList(network: Network<BSNeoLegacyNetworkId>): string[];
28
28
  static isMainnet(network: Network<BSNeoLegacyNetworkId>): boolean;
29
+ static normalizeHash(hash: string): string;
29
30
  }
@@ -31,6 +31,9 @@ class BSNeoLegacyHelper {
31
31
  static isMainnet(network) {
32
32
  return this.MAINNET_NETWORK_IDS.includes(network.id);
33
33
  }
34
+ static normalizeHash(hash) {
35
+ return hash.startsWith('0x') ? hash.slice(2) : hash;
36
+ }
34
37
  }
35
38
  exports.BSNeoLegacyHelper = BSNeoLegacyHelper;
36
39
  _a = BSNeoLegacyHelper;
@@ -1,8 +1,8 @@
1
- import { CryptoCompareEDS, Currency, ExchangeDataService, GetTokenPriceHistory, Network, Token, TokenPricesHistoryResponse, TokenPricesResponse } from '@cityofzion/blockchain-service';
1
+ import { CryptoCompareEDS, ExchangeDataService, GetTokenPriceHistoryParams, GetTokenPricesParams, Network, TokenPricesHistoryResponse, TokenPricesResponse } from '@cityofzion/blockchain-service';
2
2
  import { BSNeoLegacyNetworkId } from './BSNeoLegacyHelper';
3
3
  export declare class CryptoCompareEDSNeoLegacy extends CryptoCompareEDS implements ExchangeDataService {
4
4
  #private;
5
- constructor(network: Network<BSNeoLegacyNetworkId>, tokens: Token[]);
6
- getTokenPriceHistory(params: GetTokenPriceHistory): Promise<TokenPricesHistoryResponse[]>;
7
- getTokenPrices(currency: Currency): Promise<TokenPricesResponse[]>;
5
+ constructor(network: Network<BSNeoLegacyNetworkId>);
6
+ getTokenPriceHistory(params: GetTokenPriceHistoryParams): Promise<TokenPricesHistoryResponse[]>;
7
+ getTokenPrices(params: GetTokenPricesParams): Promise<TokenPricesResponse[]>;
8
8
  }
@@ -25,8 +25,8 @@ exports.CryptoCompareEDSNeoLegacy = void 0;
25
25
  const blockchain_service_1 = require("@cityofzion/blockchain-service");
26
26
  const BSNeoLegacyHelper_1 = require("./BSNeoLegacyHelper");
27
27
  class CryptoCompareEDSNeoLegacy extends blockchain_service_1.CryptoCompareEDS {
28
- constructor(network, tokens) {
29
- super(tokens);
28
+ constructor(network) {
29
+ super();
30
30
  _CryptoCompareEDSNeoLegacy_network.set(this, void 0);
31
31
  __classPrivateFieldSet(this, _CryptoCompareEDSNeoLegacy_network, network, "f");
32
32
  }
@@ -40,14 +40,14 @@ class CryptoCompareEDSNeoLegacy extends blockchain_service_1.CryptoCompareEDS {
40
40
  return yield _super.getTokenPriceHistory.call(this, params);
41
41
  });
42
42
  }
43
- getTokenPrices(currency) {
43
+ getTokenPrices(params) {
44
44
  const _super = Object.create(null, {
45
45
  getTokenPrices: { get: () => super.getTokenPrices }
46
46
  });
47
47
  return __awaiter(this, void 0, void 0, function* () {
48
48
  if (!BSNeoLegacyHelper_1.BSNeoLegacyHelper.isMainnet(__classPrivateFieldGet(this, _CryptoCompareEDSNeoLegacy_network, "f")))
49
49
  throw new Error('Exchange is only available on mainnet');
50
- return yield _super.getTokenPrices.call(this, currency);
50
+ return yield _super.getTokenPrices.call(this, params);
51
51
  });
52
52
  }
53
53
  }
@@ -120,7 +120,7 @@ class DoraBDSNeoLegacy {
120
120
  }
121
121
  getTokenInfo(tokenHash) {
122
122
  return __awaiter(this, void 0, void 0, function* () {
123
- const localToken = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokens, "f").find(token => token.hash === tokenHash);
123
+ const localToken = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokens, "f").find(token => BSNeoLegacyHelper_1.BSNeoLegacyHelper.normalizeHash(token.hash) === BSNeoLegacyHelper_1.BSNeoLegacyHelper.normalizeHash(tokenHash));
124
124
  if (localToken)
125
125
  return localToken;
126
126
  if (__classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokenCache, "f").has(tokenHash)) {
@@ -143,7 +143,7 @@ class DoraBDSNeoLegacy {
143
143
  return __awaiter(this, void 0, void 0, function* () {
144
144
  const data = yield dora_ts_1.api.NeoLegacyREST.balance(address, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").id);
145
145
  const promises = data.map((balance) => __awaiter(this, void 0, void 0, function* () {
146
- const hash = balance.asset.replace('0x', '');
146
+ const hash = BSNeoLegacyHelper_1.BSNeoLegacyHelper.normalizeHash(balance.asset);
147
147
  let token = {
148
148
  hash,
149
149
  name: balance.asset_name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityofzion/bs-neo-legacy",
3
- "version": "1.0.4",
3
+ "version": "1.1.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "Coz",
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "@cityofzion/dora-ts": "0.0.11",
13
13
  "@cityofzion/neon-js": "4.8.3",
14
- "@cityofzion/blockchain-service": "1.0.2",
14
+ "@cityofzion/blockchain-service": "1.1.0",
15
15
  "@cityofzion/bs-asteroid-sdk": "0.9.0"
16
16
  },
17
17
  "devDependencies": {