@cityofzion/bs-neo-legacy 1.12.8 → 1.13.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.
@@ -1,6 +1,6 @@
1
- import { Account, BDSClaimable, BlockchainDataService, BlockchainService, BSClaimable, ExchangeDataService, Token, Network, TransferParam, BSWithExplorerService, ExplorerService, BSWithLedger, GetLedgerTransport, BalanceResponse } from '@cityofzion/blockchain-service';
2
- import { BSNeoLegacyNetworkId } from '../constants/BSNeoLegacyConstants';
3
- import { NeonJsLedgerServiceNeoLegacy } from './ledger/NeonJsLedgerServiceNeoLegacy';
1
+ import { Account, BDSClaimable, BlockchainDataService, BlockchainService, BSClaimable, ExchangeDataService, Token, Network, TransferParam, BSWithExplorerService, ExplorerService, BSWithLedger, GetLedgerTransport, BalanceResponse, BSWithEncryption, ITokenService } from '@cityofzion/blockchain-service';
2
+ import { BSNeoLegacyNetworkId } from './constants/BSNeoLegacyConstants';
3
+ import { NeonJsLedgerServiceNeoLegacy } from './services/ledger/NeonJsLedgerServiceNeoLegacy';
4
4
  export type MigrateParams<BSName extends string = string> = {
5
5
  account: Account<BSName>;
6
6
  neo3Address: string;
@@ -18,7 +18,7 @@ export type CalculateNeoLegacyMigrationAmountsResponse = {
18
18
  gasBalance?: BalanceResponse;
19
19
  neoBalance?: BalanceResponse;
20
20
  };
21
- export declare class BSNeoLegacy<BSName extends string = string> implements BlockchainService<BSName, BSNeoLegacyNetworkId>, BSClaimable<BSName>, BSWithExplorerService, BSWithLedger<BSName> {
21
+ export declare class BSNeoLegacy<BSName extends string = string> implements BlockchainService<BSName, BSNeoLegacyNetworkId>, BSClaimable<BSName>, BSWithExplorerService, BSWithLedger<BSName>, BSWithEncryption<BSName> {
22
22
  #private;
23
23
  NATIVE_ASSETS: {
24
24
  symbol: string;
@@ -36,6 +36,7 @@ export declare class BSNeoLegacy<BSName extends string = string> implements Bloc
36
36
  exchangeDataService: ExchangeDataService;
37
37
  ledgerService: NeonJsLedgerServiceNeoLegacy<BSName>;
38
38
  explorerService: ExplorerService;
39
+ tokenService: ITokenService;
39
40
  tokens: Token[];
40
41
  network: Network<BSNeoLegacyNetworkId>;
41
42
  legacyNetwork: string;
@@ -30,12 +30,13 @@ exports.BSNeoLegacy = void 0;
30
30
  const blockchain_service_1 = require("@cityofzion/blockchain-service");
31
31
  const neon_js_1 = require("@cityofzion/neon-js");
32
32
  const bs_asteroid_sdk_1 = require("@cityofzion/bs-asteroid-sdk");
33
- const BSNeoLegacyConstants_1 = require("../constants/BSNeoLegacyConstants");
34
- const BSNeoLegacyHelper_1 = require("../helpers/BSNeoLegacyHelper");
35
- const CryptoCompareEDSNeoLegacy_1 = require("./exchange-data/CryptoCompareEDSNeoLegacy");
36
- const DoraBDSNeoLegacy_1 = require("./blockchain-data/DoraBDSNeoLegacy");
37
- const NeoTubeESNeoLegacy_1 = require("./explorer/NeoTubeESNeoLegacy");
38
- const NeonJsLedgerServiceNeoLegacy_1 = require("./ledger/NeonJsLedgerServiceNeoLegacy");
33
+ const BSNeoLegacyConstants_1 = require("./constants/BSNeoLegacyConstants");
34
+ const BSNeoLegacyHelper_1 = require("./helpers/BSNeoLegacyHelper");
35
+ const CryptoCompareEDSNeoLegacy_1 = require("./services/exchange-data/CryptoCompareEDSNeoLegacy");
36
+ const DoraBDSNeoLegacy_1 = require("./services/blockchain-data/DoraBDSNeoLegacy");
37
+ const NeoTubeESNeoLegacy_1 = require("./services/explorer/NeoTubeESNeoLegacy");
38
+ const NeonJsLedgerServiceNeoLegacy_1 = require("./services/ledger/NeonJsLedgerServiceNeoLegacy");
39
+ const TokenServiceNeoLegacy_1 = require("./services/token/TokenServiceNeoLegacy");
39
40
  class BSNeoLegacy {
40
41
  constructor(name, network, getLedgerTransport) {
41
42
  _BSNeoLegacy_instances.add(this);
@@ -49,7 +50,7 @@ class BSNeoLegacy {
49
50
  }
50
51
  testNetwork(network) {
51
52
  return __awaiter(this, void 0, void 0, function* () {
52
- const blockchainDataServiceClone = new DoraBDSNeoLegacy_1.DoraBDSNeoLegacy(network, this.feeToken, this.claimToken, this.tokens, this.explorerService);
53
+ const blockchainDataServiceClone = new DoraBDSNeoLegacy_1.DoraBDSNeoLegacy(network, this.feeToken, this.claimToken, this.tokens, this.explorerService, this.tokenService);
53
54
  yield blockchainDataServiceClone.getBlockHeight();
54
55
  });
55
56
  }
@@ -58,8 +59,9 @@ class BSNeoLegacy {
58
59
  throw new Error('Custom network is not supported');
59
60
  __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_setTokens).call(this, network);
60
61
  this.network = network;
61
- this.explorerService = new NeoTubeESNeoLegacy_1.NeoTubeESNeoLegacy(network);
62
- this.blockchainDataService = new DoraBDSNeoLegacy_1.DoraBDSNeoLegacy(network, this.feeToken, this.claimToken, this.tokens, this.explorerService);
62
+ this.tokenService = new TokenServiceNeoLegacy_1.TokenServiceNeoLegacy();
63
+ this.explorerService = new NeoTubeESNeoLegacy_1.NeoTubeESNeoLegacy(network, this.tokenService);
64
+ this.blockchainDataService = new DoraBDSNeoLegacy_1.DoraBDSNeoLegacy(network, this.feeToken, this.claimToken, this.tokens, this.explorerService, this.tokenService);
63
65
  this.exchangeDataService = new CryptoCompareEDSNeoLegacy_1.CryptoCompareEDSNeoLegacy(network);
64
66
  }
65
67
  validateAddress(address) {
@@ -117,8 +119,8 @@ class BSNeoLegacy {
117
119
  const nep5ScriptBuilder = new neon_js_1.sc.ScriptBuilder();
118
120
  const concatIntents = [...intents, ...(tipIntent ? [tipIntent] : [])];
119
121
  for (const intent of concatIntents) {
120
- const normalizeTokenHash = blockchain_service_1.BSTokenHelper.normalizeHash(intent.tokenHash);
121
- const nativeAsset = this.NATIVE_ASSETS.find(blockchain_service_1.BSTokenHelper.predicateByHash(normalizeTokenHash));
122
+ const normalizeTokenHash = this.tokenService.normalizeHash(intent.tokenHash);
123
+ const nativeAsset = this.NATIVE_ASSETS.find(this.tokenService.predicateByHash(normalizeTokenHash));
122
124
  if (nativeAsset) {
123
125
  nativeIntents.push(...neon_js_1.api.makeIntent({ [nativeAsset.symbol]: Number(intent.amount) }, intent.receiverAddress));
124
126
  continue;
@@ -229,8 +231,8 @@ class BSNeoLegacy {
229
231
  return response;
230
232
  }
231
233
  calculateNeoLegacyMigrationAmounts(balance) {
232
- const gasBalance = balance.find(({ token }) => blockchain_service_1.BSTokenHelper.predicateByHash(BSNeoLegacyConstants_1.BSNeoLegacyConstants.GAS_ASSET)(token));
233
- const neoBalance = balance.find(({ token }) => blockchain_service_1.BSTokenHelper.predicateByHash(BSNeoLegacyConstants_1.BSNeoLegacyConstants.NEO_ASSET)(token));
234
+ const gasBalance = balance.find(({ token }) => this.tokenService.predicateByHash(BSNeoLegacyConstants_1.BSNeoLegacyConstants.GAS_ASSET)(token));
235
+ const neoBalance = balance.find(({ token }) => this.tokenService.predicateByHash(BSNeoLegacyConstants_1.BSNeoLegacyConstants.NEO_ASSET)(token));
234
236
  let hasEnoughGasBalance = false;
235
237
  let hasEnoughNeoBalance = false;
236
238
  if (gasBalance) {
@@ -288,7 +290,7 @@ _BSNeoLegacy_instances = new WeakSet(), _BSNeoLegacy_generateSigningCallback = f
288
290
  }, _BSNeoLegacy_getRequiredTransactionFeeConfig = function _BSNeoLegacy_getRequiredTransactionFeeConfig(config) {
289
291
  var _a, _b, _c;
290
292
  config.fees = BSNeoLegacyConstants_1.BSNeoLegacyConstants.FEE_APPLIED_TO_PLAYABLE_TRANSACTION;
291
- const gasIntent = (_c = (_b = (_a = config.intents) === null || _a === void 0 ? void 0 : _a.filter((intent) => blockchain_service_1.BSTokenHelper.normalizeHash(intent.assetId) === BSNeoLegacyConstants_1.BSNeoLegacyConstants.GAS_ASSET.hash)) === null || _b === void 0 ? void 0 : _b.sort((a, b) => { var _a; return (_a = b.value.comparedTo(a.value)) !== null && _a !== void 0 ? _a : 0; })) === null || _c === void 0 ? void 0 : _c[0];
293
+ const gasIntent = (_c = (_b = (_a = config.intents) === null || _a === void 0 ? void 0 : _a.filter((intent) => this.tokenService.normalizeHash(intent.assetId) === BSNeoLegacyConstants_1.BSNeoLegacyConstants.GAS_ASSET.hash)) === null || _b === void 0 ? void 0 : _b.sort((a, b) => { var _a; return (_a = b.value.comparedTo(a.value)) !== null && _a !== void 0 ? _a : 0; })) === null || _c === void 0 ? void 0 : _c[0];
292
294
  if (gasIntent === null || gasIntent === void 0 ? void 0 : gasIntent.value) {
293
295
  gasIntent.value = gasIntent.value.sub(BSNeoLegacyConstants_1.BSNeoLegacyConstants.FEE_APPLIED_TO_PLAYABLE_TRANSACTION);
294
296
  }
@@ -1,6 +1,7 @@
1
1
  import { Network, NetworkId, Token } from '@cityofzion/blockchain-service';
2
2
  export type BSNeoLegacyNetworkId = NetworkId<'mainnet' | 'testnet'>;
3
3
  export declare class BSNeoLegacyConstants {
4
+ #private;
4
5
  static EXTRA_TOKENS_BY_NETWORK_ID: Partial<Record<BSNeoLegacyNetworkId, Token[]>>;
5
6
  static NATIVE_ASSETS: {
6
7
  symbol: string;
@@ -1,23 +1,29 @@
1
1
  "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
2
7
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
8
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
9
  };
5
- var _a;
10
+ var _a, _BSNeoLegacyConstants_tokenService;
6
11
  Object.defineProperty(exports, "__esModule", { value: true });
7
12
  exports.BSNeoLegacyConstants = void 0;
8
13
  const mainnet_json_1 = __importDefault(require("../assets/tokens/mainnet.json"));
9
14
  const native_json_1 = __importDefault(require("../assets/tokens/native.json"));
10
- const blockchain_service_1 = require("@cityofzion/blockchain-service");
15
+ const TokenServiceNeoLegacy_1 = require("../services/token/TokenServiceNeoLegacy");
11
16
  class BSNeoLegacyConstants {
12
17
  }
13
18
  exports.BSNeoLegacyConstants = BSNeoLegacyConstants;
14
19
  _a = BSNeoLegacyConstants;
20
+ _BSNeoLegacyConstants_tokenService = { value: new TokenServiceNeoLegacy_1.TokenServiceNeoLegacy() };
15
21
  BSNeoLegacyConstants.EXTRA_TOKENS_BY_NETWORK_ID = {
16
- mainnet: mainnet_json_1.default,
22
+ mainnet: __classPrivateFieldGet(_a, _a, "f", _BSNeoLegacyConstants_tokenService).normalizeToken(mainnet_json_1.default),
17
23
  };
18
- BSNeoLegacyConstants.NATIVE_ASSETS = blockchain_service_1.BSTokenHelper.normalizeToken(native_json_1.default);
19
- BSNeoLegacyConstants.GAS_ASSET = _a.NATIVE_ASSETS.find(blockchain_service_1.BSTokenHelper.predicateBySymbol('GAS'));
20
- BSNeoLegacyConstants.NEO_ASSET = _a.NATIVE_ASSETS.find(blockchain_service_1.BSTokenHelper.predicateBySymbol('NEO'));
24
+ BSNeoLegacyConstants.NATIVE_ASSETS = __classPrivateFieldGet(_a, _a, "f", _BSNeoLegacyConstants_tokenService).normalizeToken(native_json_1.default);
25
+ BSNeoLegacyConstants.GAS_ASSET = _a.NATIVE_ASSETS.find(__classPrivateFieldGet(_a, _a, "f", _BSNeoLegacyConstants_tokenService).predicateBySymbol('GAS'));
26
+ BSNeoLegacyConstants.NEO_ASSET = _a.NATIVE_ASSETS.find(__classPrivateFieldGet(_a, _a, "f", _BSNeoLegacyConstants_tokenService).predicateBySymbol('NEO'));
21
27
  BSNeoLegacyConstants.RPC_LIST_BY_NETWORK_ID = {
22
28
  mainnet: [
23
29
  'https://mainnet1.neo2.coz.io:443',
@@ -7,6 +7,7 @@ export type WaitForMigrationParams = {
7
7
  neoLegacyService: BlockchainService;
8
8
  };
9
9
  export declare class BSNeoLegacyHelper {
10
+ #private;
10
11
  static getLegacyNetwork(network: Network<BSNeoLegacyNetworkId>): string;
11
12
  static getTokens(network: Network<BSNeoLegacyNetworkId>): {
12
13
  symbol: string;
@@ -8,14 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
11
+ var _a, _BSNeoLegacyHelper_tokenService;
14
12
  Object.defineProperty(exports, "__esModule", { value: true });
15
13
  exports.BSNeoLegacyHelper = void 0;
16
14
  const blockchain_service_1 = require("@cityofzion/blockchain-service");
17
- const native_json_1 = __importDefault(require("../assets/tokens/native.json"));
18
15
  const BSNeoLegacyConstants_1 = require("../constants/BSNeoLegacyConstants");
16
+ const TokenServiceNeoLegacy_1 = require("../services/token/TokenServiceNeoLegacy");
19
17
  class BSNeoLegacyHelper {
20
18
  static getLegacyNetwork(network) {
21
19
  const legacyNetwork = BSNeoLegacyConstants_1.BSNeoLegacyConstants.LEGACY_NETWORK_BY_NETWORK_ID[network.id];
@@ -24,13 +22,14 @@ class BSNeoLegacyHelper {
24
22
  return legacyNetwork;
25
23
  }
26
24
  static getTokens(network) {
27
- var _a;
28
- const extraTokens = (_a = BSNeoLegacyConstants_1.BSNeoLegacyConstants.EXTRA_TOKENS_BY_NETWORK_ID[network.id]) !== null && _a !== void 0 ? _a : [];
29
- return blockchain_service_1.BSTokenHelper.normalizeToken([...extraTokens, ...native_json_1.default]);
25
+ var _b;
26
+ const extraTokens = (_b = BSNeoLegacyConstants_1.BSNeoLegacyConstants.EXTRA_TOKENS_BY_NETWORK_ID[network.id]) !== null && _b !== void 0 ? _b : [];
27
+ const nativeTokens = BSNeoLegacyConstants_1.BSNeoLegacyConstants.NATIVE_ASSETS;
28
+ return nativeTokens.concat(extraTokens);
30
29
  }
31
30
  static getRpcList(network) {
32
- var _a;
33
- return (_a = BSNeoLegacyConstants_1.BSNeoLegacyConstants.RPC_LIST_BY_NETWORK_ID[network.id]) !== null && _a !== void 0 ? _a : [];
31
+ var _b;
32
+ return (_b = BSNeoLegacyConstants_1.BSNeoLegacyConstants.RPC_LIST_BY_NETWORK_ID[network.id]) !== null && _b !== void 0 ? _b : [];
34
33
  }
35
34
  static isMainnet(network) {
36
35
  return BSNeoLegacyConstants_1.BSNeoLegacyConstants.MAINNET_NETWORK_IDS.includes(network.id);
@@ -52,7 +51,7 @@ class BSNeoLegacyHelper {
52
51
  response.isTransactionConfirmed = true;
53
52
  break;
54
53
  }
55
- catch (_a) {
54
+ catch (_b) {
56
55
  // Empty block
57
56
  }
58
57
  }
@@ -71,7 +70,7 @@ class BSNeoLegacyHelper {
71
70
  break;
72
71
  }
73
72
  }
74
- catch (_b) {
73
+ catch (_c) {
75
74
  // Empty block
76
75
  }
77
76
  }
@@ -80,3 +79,5 @@ class BSNeoLegacyHelper {
80
79
  }
81
80
  }
82
81
  exports.BSNeoLegacyHelper = BSNeoLegacyHelper;
82
+ _a = BSNeoLegacyHelper;
83
+ _BSNeoLegacyHelper_tokenService = { value: new TokenServiceNeoLegacy_1.TokenServiceNeoLegacy() };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- export * from './services/BSNeoLegacy';
1
+ export * from './BSNeoLegacy';
2
2
  export * from './constants/BSNeoLegacyConstants';
3
3
  export * from './helpers/BSNeoLegacyHelper';
4
4
  export * from './services/blockchain-data/DoraBDSNeoLegacy';
5
5
  export * from './services/exchange-data/CryptoCompareEDSNeoLegacy';
6
6
  export * from './services/explorer/NeoTubeESNeoLegacy';
7
7
  export * from './services/ledger/NeonJsLedgerServiceNeoLegacy';
8
+ export * from './services/token/TokenServiceNeoLegacy';
package/dist/index.js CHANGED
@@ -14,10 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./services/BSNeoLegacy"), exports);
17
+ __exportStar(require("./BSNeoLegacy"), exports);
18
18
  __exportStar(require("./constants/BSNeoLegacyConstants"), exports);
19
19
  __exportStar(require("./helpers/BSNeoLegacyHelper"), exports);
20
20
  __exportStar(require("./services/blockchain-data/DoraBDSNeoLegacy"), exports);
21
21
  __exportStar(require("./services/exchange-data/CryptoCompareEDSNeoLegacy"), exports);
22
22
  __exportStar(require("./services/explorer/NeoTubeESNeoLegacy"), exports);
23
23
  __exportStar(require("./services/ledger/NeonJsLedgerServiceNeoLegacy"), exports);
24
+ __exportStar(require("./services/token/TokenServiceNeoLegacy"), exports);
@@ -1,9 +1,9 @@
1
- import { BalanceResponse, BDSClaimable, BlockchainDataService, ContractResponse, ExplorerService, ExportTransactionsByAddressParams, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, Network, RpcResponse, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
1
+ import { BalanceResponse, BDSClaimable, BlockchainDataService, ContractResponse, ExplorerService, ExportTransactionsByAddressParams, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, Network, RpcResponse, Token, TokenService, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
2
2
  import { BSNeoLegacyNetworkId } from '../../constants/BSNeoLegacyConstants';
3
3
  export declare class DoraBDSNeoLegacy implements BlockchainDataService, BDSClaimable {
4
4
  #private;
5
5
  maxTimeToConfirmTransactionInMs: number;
6
- constructor(network: Network<BSNeoLegacyNetworkId>, feeToken: Token, claimToken: Token, tokens: Token[], explorerService: ExplorerService);
6
+ constructor(network: Network<BSNeoLegacyNetworkId>, feeToken: Token, claimToken: Token, tokens: Token[], explorerService: ExplorerService, tokenService: TokenService);
7
7
  getTransaction(hash: string): Promise<TransactionResponse>;
8
8
  getTransactionsByAddress({ address, nextPageParams, }: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
9
9
  getFullTransactionsByAddress({ nextCursor, ...params }: FullTransactionsByAddressParams): Promise<FullTransactionsByAddressResponse>;
@@ -30,7 +30,7 @@ var __rest = (this && this.__rest) || function (s, e) {
30
30
  }
31
31
  return t;
32
32
  };
33
- var _DoraBDSNeoLegacy_instances, _DoraBDSNeoLegacy_supportedNep5Standards, _DoraBDSNeoLegacy_network, _DoraBDSNeoLegacy_claimToken, _DoraBDSNeoLegacy_feeToken, _DoraBDSNeoLegacy_tokens, _DoraBDSNeoLegacy_tokenCache, _DoraBDSNeoLegacy_explorerService, _DoraBDSNeoLegacy_validateFullTransactionsByAddressParams, _DoraBDSNeoLegacy_validateGetFullTransactionsByAddressParams;
33
+ var _DoraBDSNeoLegacy_instances, _DoraBDSNeoLegacy_supportedNep5Standards, _DoraBDSNeoLegacy_network, _DoraBDSNeoLegacy_claimToken, _DoraBDSNeoLegacy_feeToken, _DoraBDSNeoLegacy_tokens, _DoraBDSNeoLegacy_tokenCache, _DoraBDSNeoLegacy_explorerService, _DoraBDSNeoLegacy_tokenService, _DoraBDSNeoLegacy_validateFullTransactionsByAddressParams, _DoraBDSNeoLegacy_validateGetFullTransactionsByAddressParams;
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
35
  exports.DoraBDSNeoLegacy = void 0;
36
36
  const blockchain_service_1 = require("@cityofzion/blockchain-service");
@@ -38,7 +38,7 @@ const dora_ts_1 = require("@cityofzion/dora-ts");
38
38
  const neon_js_1 = require("@cityofzion/neon-js");
39
39
  const BSNeoLegacyHelper_1 = require("../../helpers/BSNeoLegacyHelper");
40
40
  class DoraBDSNeoLegacy {
41
- constructor(network, feeToken, claimToken, tokens, explorerService) {
41
+ constructor(network, feeToken, claimToken, tokens, explorerService, tokenService) {
42
42
  _DoraBDSNeoLegacy_instances.add(this);
43
43
  _DoraBDSNeoLegacy_supportedNep5Standards.set(this, ['nep5', 'nep-5']);
44
44
  _DoraBDSNeoLegacy_network.set(this, void 0);
@@ -47,12 +47,14 @@ class DoraBDSNeoLegacy {
47
47
  _DoraBDSNeoLegacy_tokens.set(this, void 0);
48
48
  _DoraBDSNeoLegacy_tokenCache.set(this, new Map());
49
49
  _DoraBDSNeoLegacy_explorerService.set(this, void 0);
50
+ _DoraBDSNeoLegacy_tokenService.set(this, void 0);
50
51
  this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 2;
51
52
  __classPrivateFieldSet(this, _DoraBDSNeoLegacy_network, network, "f");
52
53
  __classPrivateFieldSet(this, _DoraBDSNeoLegacy_claimToken, claimToken, "f");
53
54
  __classPrivateFieldSet(this, _DoraBDSNeoLegacy_feeToken, feeToken, "f");
54
55
  __classPrivateFieldSet(this, _DoraBDSNeoLegacy_tokens, tokens, "f");
55
56
  __classPrivateFieldSet(this, _DoraBDSNeoLegacy_explorerService, explorerService, "f");
57
+ __classPrivateFieldSet(this, _DoraBDSNeoLegacy_tokenService, tokenService, "f");
56
58
  }
57
59
  getTransaction(hash) {
58
60
  var _a, _b, _c;
@@ -81,6 +83,7 @@ class DoraBDSNeoLegacy {
81
83
  time: Number(data.time),
82
84
  notifications: [],
83
85
  transfers,
86
+ type: 'default',
84
87
  };
85
88
  });
86
89
  }
@@ -112,6 +115,7 @@ class DoraBDSNeoLegacy {
112
115
  time: entry.time,
113
116
  transfers: [transfer],
114
117
  notifications: [],
118
+ type: 'default',
115
119
  });
116
120
  }));
117
121
  yield Promise.all(promises);
@@ -140,7 +144,7 @@ class DoraBDSNeoLegacy {
140
144
  const addressTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_explorerService, "f").getAddressTemplateUrl();
141
145
  const txTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_explorerService, "f").getTxTemplateUrl();
142
146
  const contractTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_explorerService, "f").getContractTemplateUrl();
143
- const itemPromises = items.map((_d) => __awaiter(this, void 0, void 0, function* () {
147
+ const itemPromises = items.map((_d, index) => __awaiter(this, void 0, void 0, function* () {
144
148
  var { networkFeeAmount, systemFeeAmount } = _d, item = __rest(_d, ["networkFeeAmount", "systemFeeAmount"]);
145
149
  const txId = item.transactionID;
146
150
  const newItem = {
@@ -157,16 +161,17 @@ class DoraBDSNeoLegacy {
157
161
  ? blockchain_service_1.BSBigNumberHelper.format(systemFeeAmount, { decimals: __classPrivateFieldGet(this, _DoraBDSNeoLegacy_feeToken, "f").decimals })
158
162
  : undefined,
159
163
  events: [],
164
+ type: 'default',
160
165
  };
161
- const eventPromises = item.events.map((event) => __awaiter(this, void 0, void 0, function* () {
166
+ const eventPromises = item.events.map((event, eventIndex) => __awaiter(this, void 0, void 0, function* () {
162
167
  var _e, _f, _g, _h;
163
- const { contractHash: hash, amount, from, to } = event;
164
- const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(hash));
168
+ const { contractHash, amount, from, to } = event;
169
+ const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(contractHash));
165
170
  const standard = (_g = (_f = (_e = event.supportedStandards) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.toLowerCase()) !== null && _g !== void 0 ? _g : '';
166
171
  const isNep5 = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_supportedNep5Standards, "f").includes(standard);
167
172
  const fromUrl = from ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', from) : undefined;
168
173
  const toUrl = to ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', to) : undefined;
169
- const hashUrl = hash ? contractTemplateUrl === null || contractTemplateUrl === void 0 ? void 0 : contractTemplateUrl.replace('{hash}', hash) : undefined;
174
+ const contractHashUrl = contractHash ? contractTemplateUrl === null || contractTemplateUrl === void 0 ? void 0 : contractTemplateUrl.replace('{hash}', contractHash) : undefined;
170
175
  const assetEvent = {
171
176
  eventType: 'token',
172
177
  amount: amount
@@ -177,15 +182,15 @@ class DoraBDSNeoLegacy {
177
182
  fromUrl,
178
183
  to: to !== null && to !== void 0 ? to : undefined,
179
184
  toUrl,
180
- hash,
181
- hashUrl,
185
+ contractHash,
186
+ contractHashUrl,
182
187
  token: token !== null && token !== void 0 ? token : undefined,
183
188
  tokenType: isNep5 ? 'nep-5' : 'generic',
184
189
  };
185
- newItem.events.push(assetEvent);
190
+ newItem.events.splice(eventIndex, 0, assetEvent);
186
191
  }));
187
192
  yield Promise.allSettled(eventPromises);
188
- data.push(newItem);
193
+ data.splice(index, 0, newItem);
189
194
  }));
190
195
  yield Promise.allSettled(itemPromises);
191
196
  return { nextCursor: response.nextCursor, data };
@@ -220,7 +225,7 @@ class DoraBDSNeoLegacy {
220
225
  if (cachedToken) {
221
226
  return cachedToken;
222
227
  }
223
- let token = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokens, "f").find(blockchain_service_1.BSTokenHelper.predicateByHash(tokenHash));
228
+ let token = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokens, "f").find(__classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokenService, "f").predicateByHash(tokenHash));
224
229
  if (!token) {
225
230
  const data = yield dora_ts_1.api.NeoLegacyREST.asset(tokenHash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").id);
226
231
  if (!data || 'error' in data)
@@ -232,7 +237,7 @@ class DoraBDSNeoLegacy {
232
237
  name: data.name,
233
238
  };
234
239
  }
235
- __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokenCache, "f").set(tokenHash, blockchain_service_1.BSTokenHelper.normalizeToken(token));
240
+ __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokenCache, "f").set(tokenHash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokenService, "f").normalizeToken(token));
236
241
  return token;
237
242
  });
238
243
  }
@@ -240,7 +245,7 @@ class DoraBDSNeoLegacy {
240
245
  return __awaiter(this, void 0, void 0, function* () {
241
246
  const data = yield dora_ts_1.api.NeoLegacyREST.balance(address, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").id);
242
247
  const promises = data.map((balance) => __awaiter(this, void 0, void 0, function* () {
243
- let token = blockchain_service_1.BSTokenHelper.normalizeToken({
248
+ let token = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokenService, "f").normalizeToken({
244
249
  hash: balance.asset,
245
250
  name: balance.asset_name,
246
251
  symbol: balance.symbol,
@@ -303,7 +308,7 @@ class DoraBDSNeoLegacy {
303
308
  }
304
309
  }
305
310
  exports.DoraBDSNeoLegacy = DoraBDSNeoLegacy;
306
- _DoraBDSNeoLegacy_supportedNep5Standards = new WeakMap(), _DoraBDSNeoLegacy_network = new WeakMap(), _DoraBDSNeoLegacy_claimToken = new WeakMap(), _DoraBDSNeoLegacy_feeToken = new WeakMap(), _DoraBDSNeoLegacy_tokens = new WeakMap(), _DoraBDSNeoLegacy_tokenCache = new WeakMap(), _DoraBDSNeoLegacy_explorerService = new WeakMap(), _DoraBDSNeoLegacy_instances = new WeakSet(), _DoraBDSNeoLegacy_validateFullTransactionsByAddressParams = function _DoraBDSNeoLegacy_validateFullTransactionsByAddressParams(params) {
311
+ _DoraBDSNeoLegacy_supportedNep5Standards = new WeakMap(), _DoraBDSNeoLegacy_network = new WeakMap(), _DoraBDSNeoLegacy_claimToken = new WeakMap(), _DoraBDSNeoLegacy_feeToken = new WeakMap(), _DoraBDSNeoLegacy_tokens = new WeakMap(), _DoraBDSNeoLegacy_tokenCache = new WeakMap(), _DoraBDSNeoLegacy_explorerService = new WeakMap(), _DoraBDSNeoLegacy_tokenService = new WeakMap(), _DoraBDSNeoLegacy_instances = new WeakSet(), _DoraBDSNeoLegacy_validateFullTransactionsByAddressParams = function _DoraBDSNeoLegacy_validateFullTransactionsByAddressParams(params) {
307
312
  if (!BSNeoLegacyHelper_1.BSNeoLegacyHelper.isMainnet(__classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f")))
308
313
  throw new Error('Only Mainnet is supported');
309
314
  blockchain_service_1.BSFullTransactionsByAddressHelper.validateFullTransactionsByAddressParams(params);
@@ -1,8 +1,8 @@
1
- import { BuildNftUrlParams, ExplorerService, Network } from '@cityofzion/blockchain-service';
1
+ import { BuildNftUrlParams, ExplorerService, Network, TokenService } from '@cityofzion/blockchain-service';
2
2
  import { BSNeoLegacyNetworkId } from '../../constants/BSNeoLegacyConstants';
3
3
  export declare class NeoTubeESNeoLegacy implements ExplorerService {
4
4
  #private;
5
- constructor(network: Network<BSNeoLegacyNetworkId>);
5
+ constructor(network: Network<BSNeoLegacyNetworkId>, tokenService: TokenService);
6
6
  buildTransactionUrl(hash: string): string;
7
7
  buildContractUrl(contractHash: string): string;
8
8
  buildNftUrl(_params: BuildNftUrlParams): string;
@@ -10,26 +10,27 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _NeoTubeESNeoLegacy_BASE_URL, _NeoTubeESNeoLegacy_network;
13
+ var _NeoTubeESNeoLegacy_BASE_URL, _NeoTubeESNeoLegacy_network, _NeoTubeESNeoLegacy_tokenService;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.NeoTubeESNeoLegacy = void 0;
16
- const blockchain_service_1 = require("@cityofzion/blockchain-service");
17
16
  const BSNeoLegacyHelper_1 = require("../../helpers/BSNeoLegacyHelper");
18
17
  class NeoTubeESNeoLegacy {
19
- constructor(network) {
18
+ constructor(network, tokenService) {
20
19
  _NeoTubeESNeoLegacy_BASE_URL.set(this, 'https://neo2.neotube.io');
21
20
  _NeoTubeESNeoLegacy_network.set(this, void 0);
21
+ _NeoTubeESNeoLegacy_tokenService.set(this, void 0);
22
22
  __classPrivateFieldSet(this, _NeoTubeESNeoLegacy_network, network, "f");
23
+ __classPrivateFieldSet(this, _NeoTubeESNeoLegacy_tokenService, tokenService, "f");
23
24
  }
24
25
  buildTransactionUrl(hash) {
25
26
  if (!BSNeoLegacyHelper_1.BSNeoLegacyHelper.isMainnet(__classPrivateFieldGet(this, _NeoTubeESNeoLegacy_network, "f")))
26
27
  throw new Error('NeoTube is only available on mainnet');
27
- return `${__classPrivateFieldGet(this, _NeoTubeESNeoLegacy_BASE_URL, "f")}/transaction/${blockchain_service_1.BSTokenHelper.normalizeHash(hash)}`;
28
+ return `${__classPrivateFieldGet(this, _NeoTubeESNeoLegacy_BASE_URL, "f")}/transaction/${__classPrivateFieldGet(this, _NeoTubeESNeoLegacy_tokenService, "f").normalizeHash(hash)}`;
28
29
  }
29
30
  buildContractUrl(contractHash) {
30
31
  if (!BSNeoLegacyHelper_1.BSNeoLegacyHelper.isMainnet(__classPrivateFieldGet(this, _NeoTubeESNeoLegacy_network, "f")))
31
32
  throw new Error('NeoTube is only available on mainnet');
32
- return `${__classPrivateFieldGet(this, _NeoTubeESNeoLegacy_BASE_URL, "f")}/asset/${blockchain_service_1.BSTokenHelper.normalizeHash(contractHash)}/page/1`;
33
+ return `${__classPrivateFieldGet(this, _NeoTubeESNeoLegacy_BASE_URL, "f")}/asset/${__classPrivateFieldGet(this, _NeoTubeESNeoLegacy_tokenService, "f").normalizeHash(contractHash)}/page/1`;
33
34
  }
34
35
  buildNftUrl(_params) {
35
36
  throw new Error('NeoTube does not support nft');
@@ -54,4 +55,4 @@ class NeoTubeESNeoLegacy {
54
55
  }
55
56
  }
56
57
  exports.NeoTubeESNeoLegacy = NeoTubeESNeoLegacy;
57
- _NeoTubeESNeoLegacy_BASE_URL = new WeakMap(), _NeoTubeESNeoLegacy_network = new WeakMap();
58
+ _NeoTubeESNeoLegacy_BASE_URL = new WeakMap(), _NeoTubeESNeoLegacy_network = new WeakMap(), _NeoTubeESNeoLegacy_tokenService = new WeakMap();
@@ -1,5 +1,5 @@
1
1
  import { Account, GetLedgerTransport, LedgerService, LedgerServiceEmitter, UntilIndexRecord } from '@cityofzion/blockchain-service';
2
- import { BSNeoLegacy } from '../BSNeoLegacy';
2
+ import { BSNeoLegacy } from '../../BSNeoLegacy';
3
3
  import Transport from '@ledgerhq/hw-transport';
4
4
  export declare class NeonJsLedgerServiceNeoLegacy<BSName extends string = string> implements LedgerService<BSName> {
5
5
  #private;
@@ -0,0 +1,4 @@
1
+ import { TokenService } from '@cityofzion/blockchain-service';
2
+ export declare class TokenServiceNeoLegacy extends TokenService {
3
+ normalizeHash(hash: string): string;
4
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TokenServiceNeoLegacy = void 0;
4
+ const blockchain_service_1 = require("@cityofzion/blockchain-service");
5
+ class TokenServiceNeoLegacy extends blockchain_service_1.TokenService {
6
+ normalizeHash(hash) {
7
+ const fixed = hash.startsWith('0x') ? hash : `0x${hash}`;
8
+ return fixed.toLowerCase();
9
+ }
10
+ }
11
+ exports.TokenServiceNeoLegacy = TokenServiceNeoLegacy;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityofzion/bs-neo-legacy",
3
- "version": "1.12.8",
3
+ "version": "1.13.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "Coz",
@@ -14,7 +14,7 @@
14
14
  "@ledgerhq/hw-transport": "~6.31.8",
15
15
  "axios": "~1.8.2",
16
16
  "date-fns": "~4.1.0",
17
- "@cityofzion/blockchain-service": "1.19.3",
17
+ "@cityofzion/blockchain-service": "1.21.0",
18
18
  "@cityofzion/bs-asteroid-sdk": "0.9.1"
19
19
  },
20
20
  "devDependencies": {