@cityofzion/bs-neo-legacy 1.13.4 → 1.13.5

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,29 +1,24 @@
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
- };
7
- var __importDefault = (this && this.__importDefault) || function (mod) {
8
- return (mod && mod.__esModule) ? mod : { "default": mod };
9
- };
10
- var _a, _BSNeoLegacyConstants_tokenService;
2
+ var _a;
11
3
  Object.defineProperty(exports, "__esModule", { value: true });
12
4
  exports.BSNeoLegacyConstants = void 0;
13
- const mainnet_json_1 = __importDefault(require("../assets/tokens/mainnet.json"));
14
- const native_json_1 = __importDefault(require("../assets/tokens/native.json"));
15
- const TokenServiceNeoLegacy_1 = require("../services/token/TokenServiceNeoLegacy");
16
5
  class BSNeoLegacyConstants {
17
6
  }
18
7
  exports.BSNeoLegacyConstants = BSNeoLegacyConstants;
19
8
  _a = BSNeoLegacyConstants;
20
- _BSNeoLegacyConstants_tokenService = { value: new TokenServiceNeoLegacy_1.TokenServiceNeoLegacy() };
21
- BSNeoLegacyConstants.EXTRA_TOKENS_BY_NETWORK_ID = {
22
- mainnet: __classPrivateFieldGet(_a, _a, "f", _BSNeoLegacyConstants_tokenService).normalizeToken(mainnet_json_1.default),
9
+ BSNeoLegacyConstants.GAS_ASSET = {
10
+ symbol: 'GAS',
11
+ name: 'GAS',
12
+ hash: '0x602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7',
13
+ decimals: 8,
14
+ };
15
+ BSNeoLegacyConstants.NEO_ASSET = {
16
+ symbol: 'NEO',
17
+ name: 'NEO',
18
+ hash: '0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b',
19
+ decimals: 0,
23
20
  };
24
- BSNeoLegacyConstants.NATIVE_ASSETS = __classPrivateFieldGet(_a, _a, "f", _BSNeoLegacyConstants_tokenService).normalizeToken(native_json_1.default);
25
- BSNeoLegacyConstants.GAS_ASSET = _a.NATIVE_ASSETS.find(token => __classPrivateFieldGet(_a, _a, "f", _BSNeoLegacyConstants_tokenService).predicateBySymbol('GAS', token));
26
- BSNeoLegacyConstants.NEO_ASSET = _a.NATIVE_ASSETS.find(token => __classPrivateFieldGet(_a, _a, "f", _BSNeoLegacyConstants_tokenService).predicateBySymbol('NEO', token));
21
+ BSNeoLegacyConstants.NATIVE_ASSETS = [_a.NEO_ASSET, _a.GAS_ASSET];
27
22
  BSNeoLegacyConstants.RPC_LIST_BY_NETWORK_ID = {
28
23
  mainnet: [
29
24
  'https://mainnet1.neo2.coz.io:443',
@@ -47,27 +42,20 @@ BSNeoLegacyConstants.LEGACY_NETWORK_BY_NETWORK_ID = {
47
42
  mainnet: 'MainNet',
48
43
  testnet: 'TestNet',
49
44
  };
50
- BSNeoLegacyConstants.MAINNET_NETWORK_IDS = ['mainnet'];
51
- BSNeoLegacyConstants.TESTNET_NETWORK_IDS = ['testnet'];
52
- BSNeoLegacyConstants.ALL_NETWORK_IDS = [..._a.MAINNET_NETWORK_IDS, ..._a.TESTNET_NETWORK_IDS];
53
- BSNeoLegacyConstants.MAINNET_NETWORKS = [
54
- {
55
- id: 'mainnet',
56
- name: 'Mainnet',
57
- url: _a.RPC_LIST_BY_NETWORK_ID['mainnet'][0],
58
- },
59
- ];
60
- BSNeoLegacyConstants.TESTNET_NETWORKS = [
61
- {
62
- id: 'testnet',
63
- name: 'Testnet',
64
- url: _a.RPC_LIST_BY_NETWORK_ID['testnet'][0],
65
- },
66
- ];
67
- BSNeoLegacyConstants.ALL_NETWORKS = [..._a.MAINNET_NETWORKS, ..._a.TESTNET_NETWORKS];
45
+ BSNeoLegacyConstants.MAINNET_NETWORK = {
46
+ id: 'mainnet',
47
+ name: 'Mainnet',
48
+ url: _a.RPC_LIST_BY_NETWORK_ID['mainnet'][0],
49
+ type: 'mainnet',
50
+ };
51
+ BSNeoLegacyConstants.TESTNET_NETWORK = {
52
+ id: 'testnet',
53
+ name: 'Testnet',
54
+ url: _a.RPC_LIST_BY_NETWORK_ID['testnet'][0],
55
+ type: 'testnet',
56
+ };
57
+ BSNeoLegacyConstants.ALL_NETWORKS = [_a.MAINNET_NETWORK, _a.TESTNET_NETWORK];
68
58
  BSNeoLegacyConstants.DEFAULT_BIP44_DERIVATION_PATH = "m/44'/888'/0'/0/?";
69
- // If tou change this, make sure to update the tests accordingly
70
- BSNeoLegacyConstants.DEFAULT_NETWORK = _a.MAINNET_NETWORKS[0];
71
59
  BSNeoLegacyConstants.MIGRATION_COZ_LEGACY_ADDRESS = 'AaT27thuyPaqERPwERhk7QhfKrbj4xoyAV';
72
60
  BSNeoLegacyConstants.MIGRATION_COZ_FEE = 0.01; // 1%
73
61
  BSNeoLegacyConstants.MIGRATION_NEP_17_TRANSFER_FEE = 0.0112143;
@@ -1,24 +1,6 @@
1
- import { BlockchainService, Network } from '@cityofzion/blockchain-service';
2
- import { BSNeoLegacyNetworkId } from '../constants/BSNeoLegacyConstants';
3
- export type WaitForMigrationParams = {
4
- transactionHash: string;
5
- neo3Address: string;
6
- neo3Service: BlockchainService;
7
- neoLegacyService: BlockchainService;
8
- };
1
+ import { TBSNetwork } from '@cityofzion/blockchain-service';
2
+ import { TBSNeoLegacyNetworkId } from '../types';
9
3
  export declare class BSNeoLegacyHelper {
10
- #private;
11
- static getLegacyNetwork(network: Network<BSNeoLegacyNetworkId>): string;
12
- static getTokens(network: Network<BSNeoLegacyNetworkId>): {
13
- symbol: string;
14
- name: string;
15
- hash: string;
16
- decimals: number;
17
- }[];
18
- static getRpcList(network: Network<BSNeoLegacyNetworkId>): string[];
19
- static isMainnet(network: Network<BSNeoLegacyNetworkId>): boolean;
20
- static waitForMigration(params: WaitForMigrationParams): Promise<{
21
- isTransactionConfirmed: boolean;
22
- isNeo3TransactionConfirmed: boolean;
23
- }>;
4
+ static getLegacyNetwork(network: TBSNetwork<TBSNeoLegacyNetworkId>): string;
5
+ static isMainnetNetwork(network: TBSNetwork<TBSNeoLegacyNetworkId>): boolean;
24
6
  }
@@ -1,19 +1,7 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var _a, _BSNeoLegacyHelper_tokenService;
12
2
  Object.defineProperty(exports, "__esModule", { value: true });
13
3
  exports.BSNeoLegacyHelper = void 0;
14
- const blockchain_service_1 = require("@cityofzion/blockchain-service");
15
4
  const BSNeoLegacyConstants_1 = require("../constants/BSNeoLegacyConstants");
16
- const TokenServiceNeoLegacy_1 = require("../services/token/TokenServiceNeoLegacy");
17
5
  class BSNeoLegacyHelper {
18
6
  static getLegacyNetwork(network) {
19
7
  const legacyNetwork = BSNeoLegacyConstants_1.BSNeoLegacyConstants.LEGACY_NETWORK_BY_NETWORK_ID[network.id];
@@ -21,63 +9,8 @@ class BSNeoLegacyHelper {
21
9
  throw new Error('Unsupported network');
22
10
  return legacyNetwork;
23
11
  }
24
- static getTokens(network) {
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);
29
- }
30
- static getRpcList(network) {
31
- var _b;
32
- return (_b = BSNeoLegacyConstants_1.BSNeoLegacyConstants.RPC_LIST_BY_NETWORK_ID[network.id]) !== null && _b !== void 0 ? _b : [];
33
- }
34
- static isMainnet(network) {
35
- return BSNeoLegacyConstants_1.BSNeoLegacyConstants.MAINNET_NETWORK_IDS.includes(network.id);
36
- }
37
- static waitForMigration(params) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- const { neo3Address, neo3Service, transactionHash, neoLegacyService } = params;
40
- const MAX_ATTEMPTS = 10;
41
- const NEO3_MAX_ATTEMPTS = 20;
42
- const response = {
43
- isTransactionConfirmed: false,
44
- isNeo3TransactionConfirmed: false,
45
- };
46
- let transactionResponse;
47
- for (let i = 0; i < MAX_ATTEMPTS; i++) {
48
- yield blockchain_service_1.BSUtilsHelper.wait(30000);
49
- try {
50
- transactionResponse = yield neoLegacyService.blockchainDataService.getTransaction(transactionHash);
51
- response.isTransactionConfirmed = true;
52
- break;
53
- }
54
- catch (_b) {
55
- // Empty block
56
- }
57
- }
58
- if (!response.isTransactionConfirmed)
59
- return response;
60
- for (let i = 0; i < NEO3_MAX_ATTEMPTS; i++) {
61
- yield blockchain_service_1.BSUtilsHelper.wait(60000);
62
- try {
63
- const neo3Response = yield neo3Service.blockchainDataService.getTransactionsByAddress({
64
- address: neo3Address,
65
- });
66
- const isTransactionConfirmed = neo3Response.transactions.some(transaction => transaction.time > transactionResponse.time &&
67
- transaction.transfers.some(transfer => transfer.from === BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_COZ_NEO3_ADDRESS));
68
- if (isTransactionConfirmed) {
69
- response.isNeo3TransactionConfirmed = true;
70
- break;
71
- }
72
- }
73
- catch (_c) {
74
- // Empty block
75
- }
76
- }
77
- return response;
78
- });
12
+ static isMainnetNetwork(network) {
13
+ return network.id === BSNeoLegacyConstants_1.BSNeoLegacyConstants.MAINNET_NETWORK.id && network.type === 'mainnet';
79
14
  }
80
15
  }
81
16
  exports.BSNeoLegacyHelper = BSNeoLegacyHelper;
82
- _a = BSNeoLegacyHelper;
83
- _BSNeoLegacyHelper_tokenService = { value: new TokenServiceNeoLegacy_1.TokenServiceNeoLegacy() };
@@ -0,0 +1,6 @@
1
+ import type * as NeonJs from '@cityofzion/neon-js';
2
+ export declare class BSNeoLegacyNeonJsSingletonHelper {
3
+ #private;
4
+ static getInstance(): typeof NeonJs;
5
+ }
6
+ export type * from '@cityofzion/neon-js';
@@ -0,0 +1,26 @@
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
+ };
7
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8
+ if (kind === "m") throw new TypeError("Private method is not writable");
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
11
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
+ };
13
+ var _a, _BSNeoLegacyNeonJsSingletonHelper_instance;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.BSNeoLegacyNeonJsSingletonHelper = void 0;
16
+ class BSNeoLegacyNeonJsSingletonHelper {
17
+ static getInstance() {
18
+ if (!__classPrivateFieldGet(_a, _a, "f", _BSNeoLegacyNeonJsSingletonHelper_instance)) {
19
+ __classPrivateFieldSet(_a, _a, require('@cityofzion/neon-js'), "f", _BSNeoLegacyNeonJsSingletonHelper_instance);
20
+ }
21
+ return __classPrivateFieldGet(_a, _a, "f", _BSNeoLegacyNeonJsSingletonHelper_instance);
22
+ }
23
+ }
24
+ exports.BSNeoLegacyNeonJsSingletonHelper = BSNeoLegacyNeonJsSingletonHelper;
25
+ _a = BSNeoLegacyNeonJsSingletonHelper;
26
+ _BSNeoLegacyNeonJsSingletonHelper_instance = { value: void 0 };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  export * from './BSNeoLegacy';
2
2
  export * from './constants/BSNeoLegacyConstants';
3
3
  export * from './helpers/BSNeoLegacyHelper';
4
+ export * from './helpers/BSNeoLegacyNeonJsSingletonHelper';
4
5
  export * from './services/blockchain-data/DoraBDSNeoLegacy';
5
6
  export * from './services/exchange-data/CryptoCompareEDSNeoLegacy';
6
7
  export * from './services/explorer/NeoTubeESNeoLegacy';
7
8
  export * from './services/ledger/NeonJsLedgerServiceNeoLegacy';
8
9
  export * from './services/token/TokenServiceNeoLegacy';
10
+ export * from './types';
package/dist/index.js CHANGED
@@ -17,8 +17,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./BSNeoLegacy"), exports);
18
18
  __exportStar(require("./constants/BSNeoLegacyConstants"), exports);
19
19
  __exportStar(require("./helpers/BSNeoLegacyHelper"), exports);
20
+ __exportStar(require("./helpers/BSNeoLegacyNeonJsSingletonHelper"), exports);
20
21
  __exportStar(require("./services/blockchain-data/DoraBDSNeoLegacy"), exports);
21
22
  __exportStar(require("./services/exchange-data/CryptoCompareEDSNeoLegacy"), exports);
22
23
  __exportStar(require("./services/explorer/NeoTubeESNeoLegacy"), exports);
23
24
  __exportStar(require("./services/ledger/NeonJsLedgerServiceNeoLegacy"), exports);
24
25
  __exportStar(require("./services/token/TokenServiceNeoLegacy"), exports);
26
+ __exportStar(require("./types"), exports);
@@ -1,17 +1,18 @@
1
- import { BalanceResponse, BDSClaimable, BlockchainDataService, ContractResponse, ExplorerService, ExportTransactionsByAddressParams, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, Network, RpcResponse, Token, TokenService, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
2
- import { BSNeoLegacyNetworkId } from '../../constants/BSNeoLegacyConstants';
3
- export declare class DoraBDSNeoLegacy implements BlockchainDataService, BDSClaimable {
1
+ import { TBalanceResponse, ContractResponse, TExportTransactionsByAddressParams, TFullTransactionsByAddressParams, TFullTransactionsByAddressResponse, IBlockchainDataService, TBSToken, TTransactionResponse, TTransactionsByAddressParams, TTransactionsByAddressResponse } from '@cityofzion/blockchain-service';
2
+ import { IBSNeoLegacy, TBSNeoLegacyNetworkId } from '../../types';
3
+ export declare class DoraBDSNeoLegacy<N extends string> implements IBlockchainDataService {
4
4
  #private;
5
- maxTimeToConfirmTransactionInMs: number;
6
- constructor(network: Network<BSNeoLegacyNetworkId>, feeToken: Token, claimToken: Token, tokens: Token[], explorerService: ExplorerService, tokenService: TokenService);
7
- getTransaction(hash: string): Promise<TransactionResponse>;
8
- getTransactionsByAddress({ address, nextPageParams, }: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
9
- getFullTransactionsByAddress({ nextCursor, ...params }: FullTransactionsByAddressParams): Promise<FullTransactionsByAddressResponse>;
10
- exportFullTransactionsByAddress(params: ExportTransactionsByAddressParams): Promise<string>;
5
+ static readonly SUPPORTED_NEP5_STANDARDS: string[];
6
+ static readonly FULL_TRANSACTIONS_API_SUPPORTED_NETWORKS_IDS: TBSNeoLegacyNetworkId[];
7
+ readonly maxTimeToConfirmTransactionInMs: number;
8
+ constructor(service: IBSNeoLegacy<N>);
9
+ getTransaction(hash: string): Promise<TTransactionResponse>;
10
+ getTransactionsByAddress({ address, nextPageParams, }: TTransactionsByAddressParams): Promise<TTransactionsByAddressResponse>;
11
+ getFullTransactionsByAddress({ nextCursor, ...params }: TFullTransactionsByAddressParams): Promise<TFullTransactionsByAddressResponse>;
12
+ exportFullTransactionsByAddress(params: TExportTransactionsByAddressParams): Promise<string>;
11
13
  getContract(contractHash: string): Promise<ContractResponse>;
12
- getTokenInfo(tokenHash: string): Promise<Token>;
13
- getBalance(address: string): Promise<BalanceResponse[]>;
14
+ getTokenInfo(tokenHash: string): Promise<TBSToken>;
15
+ getBalance(address: string): Promise<TBalanceResponse[]>;
14
16
  getUnclaimed(address: string): Promise<string>;
15
17
  getBlockHeight(): Promise<number>;
16
- getRpcList(): Promise<RpcResponse[]>;
17
18
  }
@@ -30,45 +30,32 @@ 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_tokenService, _DoraBDSNeoLegacy_validateFullTransactionsByAddressParams, _DoraBDSNeoLegacy_validateGetFullTransactionsByAddressParams;
33
+ var _DoraBDSNeoLegacy_tokenCache, _DoraBDSNeoLegacy_service;
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
35
  exports.DoraBDSNeoLegacy = void 0;
36
36
  const blockchain_service_1 = require("@cityofzion/blockchain-service");
37
37
  const dora_ts_1 = require("@cityofzion/dora-ts");
38
- const neon_js_1 = require("@cityofzion/neon-js");
39
- const BSNeoLegacyHelper_1 = require("../../helpers/BSNeoLegacyHelper");
38
+ const BSNeoLegacyNeonJsSingletonHelper_1 = require("../../helpers/BSNeoLegacyNeonJsSingletonHelper");
40
39
  class DoraBDSNeoLegacy {
41
- constructor(network, feeToken, claimToken, tokens, explorerService, tokenService) {
42
- _DoraBDSNeoLegacy_instances.add(this);
43
- _DoraBDSNeoLegacy_supportedNep5Standards.set(this, ['nep5', 'nep-5']);
44
- _DoraBDSNeoLegacy_network.set(this, void 0);
45
- _DoraBDSNeoLegacy_claimToken.set(this, void 0);
46
- _DoraBDSNeoLegacy_feeToken.set(this, void 0);
47
- _DoraBDSNeoLegacy_tokens.set(this, void 0);
40
+ constructor(service) {
41
+ this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 2; // 2 minutes
48
42
  _DoraBDSNeoLegacy_tokenCache.set(this, new Map());
49
- _DoraBDSNeoLegacy_explorerService.set(this, void 0);
50
- _DoraBDSNeoLegacy_tokenService.set(this, void 0);
51
- this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 2;
52
- __classPrivateFieldSet(this, _DoraBDSNeoLegacy_network, network, "f");
53
- __classPrivateFieldSet(this, _DoraBDSNeoLegacy_claimToken, claimToken, "f");
54
- __classPrivateFieldSet(this, _DoraBDSNeoLegacy_feeToken, feeToken, "f");
55
- __classPrivateFieldSet(this, _DoraBDSNeoLegacy_tokens, tokens, "f");
56
- __classPrivateFieldSet(this, _DoraBDSNeoLegacy_explorerService, explorerService, "f");
57
- __classPrivateFieldSet(this, _DoraBDSNeoLegacy_tokenService, tokenService, "f");
43
+ _DoraBDSNeoLegacy_service.set(this, void 0);
44
+ __classPrivateFieldSet(this, _DoraBDSNeoLegacy_service, service, "f");
58
45
  }
59
46
  getTransaction(hash) {
60
- var _a, _b, _c;
61
47
  return __awaiter(this, void 0, void 0, function* () {
62
- const data = yield dora_ts_1.api.NeoLegacyREST.transaction(hash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").id);
48
+ var _a, _b, _c;
49
+ const data = yield dora_ts_1.api.NeoLegacyREST.transaction(hash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_service, "f").network.id);
63
50
  if (!data || 'error' in data)
64
51
  throw new Error(`Transaction ${hash} not found`);
65
52
  const vout = (_a = data.vout) !== null && _a !== void 0 ? _a : [];
66
53
  const promises = vout.map((transfer, _index, array) => __awaiter(this, void 0, void 0, function* () {
67
- var _d;
54
+ var _a;
68
55
  const token = yield this.getTokenInfo(transfer.asset);
69
56
  return {
70
57
  amount: String(transfer.value),
71
- from: (_d = array[array.length - 1]) === null || _d === void 0 ? void 0 : _d.address,
58
+ from: (_a = array[array.length - 1]) === null || _a === void 0 ? void 0 : _a.address,
72
59
  contractHash: transfer.asset,
73
60
  to: transfer.address,
74
61
  type: 'token',
@@ -79,17 +66,17 @@ class DoraBDSNeoLegacy {
79
66
  return {
80
67
  hash: data.txid,
81
68
  block: data.block,
82
- fee: (Number((_b = data.sys_fee) !== null && _b !== void 0 ? _b : 0) + Number((_c = data.net_fee) !== null && _c !== void 0 ? _c : 0)).toFixed(__classPrivateFieldGet(this, _DoraBDSNeoLegacy_feeToken, "f").decimals),
69
+ fee: blockchain_service_1.BSBigNumberHelper.toNumber(blockchain_service_1.BSBigNumberHelper.fromNumber((_b = data.sys_fee) !== null && _b !== void 0 ? _b : 0).plus((_c = data.net_fee) !== null && _c !== void 0 ? _c : 0), __classPrivateFieldGet(this, _DoraBDSNeoLegacy_service, "f").feeToken.decimals),
83
70
  time: Number(data.time),
84
- notifications: [],
71
+ notifications: [], //neoLegacy doesn't have notifications
85
72
  transfers,
86
73
  type: 'default',
87
74
  };
88
75
  });
89
76
  }
90
- getTransactionsByAddress({ address, nextPageParams = 1, }) {
91
- return __awaiter(this, void 0, void 0, function* () {
92
- const data = yield dora_ts_1.api.NeoLegacyREST.getAddressAbstracts(address, nextPageParams, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").id);
77
+ getTransactionsByAddress(_a) {
78
+ return __awaiter(this, arguments, void 0, function* ({ address, nextPageParams = 1, }) {
79
+ const data = yield dora_ts_1.api.NeoLegacyREST.getAddressAbstracts(address, nextPageParams, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_service, "f").network.id);
93
80
  const transactions = new Map();
94
81
  const promises = data.entries.map((entry) => __awaiter(this, void 0, void 0, function* () {
95
82
  var _a, _b;
@@ -127,10 +114,10 @@ class DoraBDSNeoLegacy {
127
114
  });
128
115
  }
129
116
  getFullTransactionsByAddress(_a) {
130
- var _b, _c;
131
- var { nextCursor } = _a, params = __rest(_a, ["nextCursor"]);
132
117
  return __awaiter(this, void 0, void 0, function* () {
133
- __classPrivateFieldGet(this, _DoraBDSNeoLegacy_instances, "m", _DoraBDSNeoLegacy_validateGetFullTransactionsByAddressParams).call(this, params);
118
+ var _b, _c;
119
+ var { nextCursor } = _a, params = __rest(_a, ["nextCursor"]);
120
+ blockchain_service_1.BSFullTransactionsByAddressHelper.validateFullTransactionsByAddressParams(Object.assign(Object.assign({}, params), { service: __classPrivateFieldGet(this, _DoraBDSNeoLegacy_service, "f"), supportedNetworksIds: DoraBDSNeoLegacy.FULL_TRANSACTIONS_API_SUPPORTED_NETWORKS_IDS, maxPageSize: 30 }));
134
121
  const data = [];
135
122
  const response = yield dora_ts_1.api.NeoLegacyREST.getFullTransactionsByAddress({
136
123
  address: params.address,
@@ -141,11 +128,11 @@ class DoraBDSNeoLegacy {
141
128
  pageLimit: (_b = params.pageSize) !== null && _b !== void 0 ? _b : 30,
142
129
  });
143
130
  const items = (_c = response.data) !== null && _c !== void 0 ? _c : [];
144
- const addressTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_explorerService, "f").getAddressTemplateUrl();
145
- const txTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_explorerService, "f").getTxTemplateUrl();
146
- const contractTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_explorerService, "f").getContractTemplateUrl();
147
- const itemPromises = items.map((_d, index) => __awaiter(this, void 0, void 0, function* () {
148
- var { networkFeeAmount, systemFeeAmount } = _d, item = __rest(_d, ["networkFeeAmount", "systemFeeAmount"]);
131
+ const addressTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_service, "f").explorerService.getAddressTemplateUrl();
132
+ const txTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_service, "f").explorerService.getTxTemplateUrl();
133
+ const contractTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_service, "f").explorerService.getContractTemplateUrl();
134
+ const itemPromises = items.map((_a, index) => __awaiter(this, void 0, void 0, function* () {
135
+ var { networkFeeAmount, systemFeeAmount } = _a, item = __rest(_a, ["networkFeeAmount", "systemFeeAmount"]);
149
136
  const txId = item.transactionID;
150
137
  const newItem = {
151
138
  txId,
@@ -155,27 +142,27 @@ class DoraBDSNeoLegacy {
155
142
  invocationCount: item.invocationCount,
156
143
  notificationCount: item.notificationCount,
157
144
  networkFeeAmount: networkFeeAmount
158
- ? blockchain_service_1.BSBigNumberHelper.format(networkFeeAmount, { decimals: __classPrivateFieldGet(this, _DoraBDSNeoLegacy_feeToken, "f").decimals })
145
+ ? blockchain_service_1.BSBigNumberHelper.format(networkFeeAmount, { decimals: __classPrivateFieldGet(this, _DoraBDSNeoLegacy_service, "f").feeToken.decimals })
159
146
  : undefined,
160
147
  systemFeeAmount: systemFeeAmount
161
- ? blockchain_service_1.BSBigNumberHelper.format(systemFeeAmount, { decimals: __classPrivateFieldGet(this, _DoraBDSNeoLegacy_feeToken, "f").decimals })
148
+ ? blockchain_service_1.BSBigNumberHelper.format(systemFeeAmount, { decimals: __classPrivateFieldGet(this, _DoraBDSNeoLegacy_service, "f").feeToken.decimals })
162
149
  : undefined,
163
150
  events: [],
164
151
  type: 'default',
165
152
  };
166
153
  const eventPromises = item.events.map((event, eventIndex) => __awaiter(this, void 0, void 0, function* () {
167
- var _e, _f, _g, _h;
154
+ var _a, _b, _c, _d;
168
155
  const { contractHash, amount, from, to } = event;
169
156
  const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(contractHash));
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 : '';
171
- const isNep5 = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_supportedNep5Standards, "f").includes(standard);
157
+ const standard = (_c = (_b = (_a = event.supportedStandards) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toLowerCase()) !== null && _c !== void 0 ? _c : '';
158
+ const isNep5 = DoraBDSNeoLegacy.SUPPORTED_NEP5_STANDARDS.includes(standard);
172
159
  const fromUrl = from ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', from) : undefined;
173
160
  const toUrl = to ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', to) : undefined;
174
161
  const contractHashUrl = contractHash ? contractTemplateUrl === null || contractTemplateUrl === void 0 ? void 0 : contractTemplateUrl.replace('{hash}', contractHash) : undefined;
175
162
  const assetEvent = {
176
163
  eventType: 'token',
177
164
  amount: amount
178
- ? blockchain_service_1.BSBigNumberHelper.format(amount, { decimals: (_h = token === null || token === void 0 ? void 0 : token.decimals) !== null && _h !== void 0 ? _h : event.tokenDecimals })
165
+ ? blockchain_service_1.BSBigNumberHelper.format(amount, { decimals: (_d = token === null || token === void 0 ? void 0 : token.decimals) !== null && _d !== void 0 ? _d : event.tokenDecimals })
179
166
  : undefined,
180
167
  methodName: event.methodName,
181
168
  from: from !== null && from !== void 0 ? from : undefined,
@@ -198,7 +185,7 @@ class DoraBDSNeoLegacy {
198
185
  }
199
186
  exportFullTransactionsByAddress(params) {
200
187
  return __awaiter(this, void 0, void 0, function* () {
201
- __classPrivateFieldGet(this, _DoraBDSNeoLegacy_instances, "m", _DoraBDSNeoLegacy_validateFullTransactionsByAddressParams).call(this, params);
188
+ blockchain_service_1.BSFullTransactionsByAddressHelper.validateFullTransactionsByAddressParams(Object.assign(Object.assign({}, params), { service: __classPrivateFieldGet(this, _DoraBDSNeoLegacy_service, "f"), supportedNetworksIds: DoraBDSNeoLegacy.FULL_TRANSACTIONS_API_SUPPORTED_NETWORKS_IDS, maxPageSize: 30 }));
202
189
  return yield dora_ts_1.api.NeoLegacyREST.exportFullTransactionsByAddress({
203
190
  address: params.address,
204
191
  timestampFrom: params.dateFrom,
@@ -209,7 +196,7 @@ class DoraBDSNeoLegacy {
209
196
  }
210
197
  getContract(contractHash) {
211
198
  return __awaiter(this, void 0, void 0, function* () {
212
- const response = yield dora_ts_1.api.NeoLegacyREST.contract(contractHash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").id);
199
+ const response = yield dora_ts_1.api.NeoLegacyREST.contract(contractHash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_service, "f").network.id);
213
200
  if (!response || 'error' in response)
214
201
  throw new Error(`Contract ${contractHash} not found`);
215
202
  return {
@@ -225,9 +212,9 @@ class DoraBDSNeoLegacy {
225
212
  if (cachedToken) {
226
213
  return cachedToken;
227
214
  }
228
- let token = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokens, "f").find(currentToken => __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokenService, "f").predicateByHash(tokenHash, currentToken));
215
+ let token = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_service, "f").tokens.find(token => __classPrivateFieldGet(this, _DoraBDSNeoLegacy_service, "f").tokenService.predicateByHash(tokenHash, token));
229
216
  if (!token) {
230
- const data = yield dora_ts_1.api.NeoLegacyREST.asset(tokenHash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").id);
217
+ const data = yield dora_ts_1.api.NeoLegacyREST.asset(tokenHash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_service, "f").network.id);
231
218
  if (!data || 'error' in data)
232
219
  throw new Error(`Token ${tokenHash} not found`);
233
220
  token = {
@@ -237,15 +224,15 @@ class DoraBDSNeoLegacy {
237
224
  name: data.name,
238
225
  };
239
226
  }
240
- __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokenCache, "f").set(tokenHash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokenService, "f").normalizeToken(token));
227
+ __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokenCache, "f").set(tokenHash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_service, "f").tokenService.normalizeToken(token));
241
228
  return token;
242
229
  });
243
230
  }
244
231
  getBalance(address) {
245
232
  return __awaiter(this, void 0, void 0, function* () {
246
- const data = yield dora_ts_1.api.NeoLegacyREST.balance(address, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").id);
233
+ const data = yield dora_ts_1.api.NeoLegacyREST.balance(address, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_service, "f").network.id);
247
234
  const promises = data.map((balance) => __awaiter(this, void 0, void 0, function* () {
248
- let token = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokenService, "f").normalizeToken({
235
+ let token = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_service, "f").tokenService.normalizeToken({
249
236
  hash: balance.asset,
250
237
  name: balance.asset_name,
251
238
  symbol: balance.symbol,
@@ -266,57 +253,23 @@ class DoraBDSNeoLegacy {
266
253
  });
267
254
  }
268
255
  getUnclaimed(address) {
269
- var _a;
270
256
  return __awaiter(this, void 0, void 0, function* () {
271
- const rpcClient = new neon_js_1.rpc.RPCClient(__classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").url);
257
+ var _a;
258
+ const { rpc } = BSNeoLegacyNeonJsSingletonHelper_1.BSNeoLegacyNeonJsSingletonHelper.getInstance();
259
+ const rpcClient = new rpc.RPCClient(__classPrivateFieldGet(this, _DoraBDSNeoLegacy_service, "f").network.url);
272
260
  const response = yield rpcClient.getUnclaimed(address);
273
- return ((_a = response === null || response === void 0 ? void 0 : response.unclaimed) !== null && _a !== void 0 ? _a : 0).toFixed(__classPrivateFieldGet(this, _DoraBDSNeoLegacy_claimToken, "f").decimals);
261
+ return ((_a = response === null || response === void 0 ? void 0 : response.unclaimed) !== null && _a !== void 0 ? _a : 0).toFixed(__classPrivateFieldGet(this, _DoraBDSNeoLegacy_service, "f").claimToken.decimals);
274
262
  });
275
263
  }
276
264
  getBlockHeight() {
277
265
  return __awaiter(this, void 0, void 0, function* () {
278
- const rpcClient = new neon_js_1.rpc.RPCClient(__classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").url);
266
+ const { rpc } = BSNeoLegacyNeonJsSingletonHelper_1.BSNeoLegacyNeonJsSingletonHelper.getInstance();
267
+ const rpcClient = new rpc.RPCClient(__classPrivateFieldGet(this, _DoraBDSNeoLegacy_service, "f").network.url);
279
268
  return yield rpcClient.getBlockCount();
280
269
  });
281
270
  }
282
- getRpcList() {
283
- return __awaiter(this, void 0, void 0, function* () {
284
- const list = [];
285
- const urls = BSNeoLegacyHelper_1.BSNeoLegacyHelper.getRpcList(__classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f"));
286
- const promises = urls.map(url => {
287
- // eslint-disable-next-line no-async-promise-executor
288
- return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
289
- const timeout = setTimeout(() => {
290
- resolve();
291
- }, 5000);
292
- try {
293
- const rpcClient = new neon_js_1.rpc.RPCClient(url);
294
- const timeStart = Date.now();
295
- const height = yield rpcClient.getBlockCount();
296
- const latency = Date.now() - timeStart;
297
- list.push({ url, latency, height });
298
- }
299
- finally {
300
- resolve();
301
- clearTimeout(timeout);
302
- }
303
- }));
304
- });
305
- yield Promise.allSettled(promises);
306
- return list;
307
- });
308
- }
309
271
  }
310
272
  exports.DoraBDSNeoLegacy = DoraBDSNeoLegacy;
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) {
312
- if (!BSNeoLegacyHelper_1.BSNeoLegacyHelper.isMainnet(__classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f")))
313
- throw new Error('Only Mainnet is supported');
314
- blockchain_service_1.BSFullTransactionsByAddressHelper.validateFullTransactionsByAddressParams(params);
315
- if (!neon_js_1.wallet.isAddress(params.address))
316
- throw new Error('Invalid address param');
317
- }, _DoraBDSNeoLegacy_validateGetFullTransactionsByAddressParams = function _DoraBDSNeoLegacy_validateGetFullTransactionsByAddressParams(_a) {
318
- var { pageSize } = _a, params = __rest(_a, ["pageSize"]);
319
- if (typeof pageSize === 'number' && (isNaN(pageSize) || pageSize < 1 || pageSize > 30))
320
- throw new Error('Page size should be between 1 and 30');
321
- __classPrivateFieldGet(this, _DoraBDSNeoLegacy_instances, "m", _DoraBDSNeoLegacy_validateFullTransactionsByAddressParams).call(this, params);
322
- };
273
+ _DoraBDSNeoLegacy_tokenCache = new WeakMap(), _DoraBDSNeoLegacy_service = new WeakMap();
274
+ DoraBDSNeoLegacy.SUPPORTED_NEP5_STANDARDS = ['nep5', 'nep-5'];
275
+ DoraBDSNeoLegacy.FULL_TRANSACTIONS_API_SUPPORTED_NETWORKS_IDS = ['mainnet'];
@@ -0,0 +1,7 @@
1
+ import { IClaimDataService } from '@cityofzion/blockchain-service';
2
+ import { IBSNeoLegacy } from '../../types';
3
+ export declare class DoraCDSNeoLegacy<N extends string> implements IClaimDataService {
4
+ #private;
5
+ constructor(service: IBSNeoLegacy<N>);
6
+ getUnclaimed(address: string): Promise<string>;
7
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12
+ if (kind === "m") throw new TypeError("Private method is not writable");
13
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
14
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
15
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
16
+ };
17
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
18
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
19
+ 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");
20
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
21
+ };
22
+ var _DoraCDSNeoLegacy_service;
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.DoraCDSNeoLegacy = void 0;
25
+ const BSNeoLegacyNeonJsSingletonHelper_1 = require("../../helpers/BSNeoLegacyNeonJsSingletonHelper");
26
+ class DoraCDSNeoLegacy {
27
+ constructor(service) {
28
+ _DoraCDSNeoLegacy_service.set(this, void 0);
29
+ __classPrivateFieldSet(this, _DoraCDSNeoLegacy_service, service, "f");
30
+ }
31
+ getUnclaimed(address) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ var _a;
34
+ const { rpc } = BSNeoLegacyNeonJsSingletonHelper_1.BSNeoLegacyNeonJsSingletonHelper.getInstance();
35
+ const rpcClient = new rpc.RPCClient(__classPrivateFieldGet(this, _DoraCDSNeoLegacy_service, "f").network.url);
36
+ const response = yield rpcClient.getUnclaimed(address);
37
+ return ((_a = response === null || response === void 0 ? void 0 : response.unclaimed) !== null && _a !== void 0 ? _a : 0).toFixed(__classPrivateFieldGet(this, _DoraCDSNeoLegacy_service, "f").claimToken.decimals);
38
+ });
39
+ }
40
+ }
41
+ exports.DoraCDSNeoLegacy = DoraCDSNeoLegacy;
42
+ _DoraCDSNeoLegacy_service = new WeakMap();
@@ -1,8 +1,8 @@
1
- import { CryptoCompareEDS, ExchangeDataService, GetTokenPriceHistoryParams, GetTokenPricesParams, Network, TokenPricesHistoryResponse, TokenPricesResponse } from '@cityofzion/blockchain-service';
2
- import { BSNeoLegacyNetworkId } from '../../constants/BSNeoLegacyConstants';
3
- export declare class CryptoCompareEDSNeoLegacy extends CryptoCompareEDS implements ExchangeDataService {
1
+ import { CryptoCompareEDS, TGetTokenPriceHistoryParams, TGetTokenPricesParams, TTokenPricesHistoryResponse, TTokenPricesResponse } from '@cityofzion/blockchain-service';
2
+ import { IBSNeoLegacy } from '../../types';
3
+ export declare class CryptoCompareEDSNeoLegacy<N extends string> extends CryptoCompareEDS {
4
4
  #private;
5
- constructor(network: Network<BSNeoLegacyNetworkId>);
6
- getTokenPriceHistory(params: GetTokenPriceHistoryParams): Promise<TokenPricesHistoryResponse[]>;
7
- getTokenPrices(params: GetTokenPricesParams): Promise<TokenPricesResponse[]>;
5
+ constructor(service: IBSNeoLegacy<N>);
6
+ getTokenPriceHistory(params: TGetTokenPriceHistoryParams): Promise<TTokenPricesHistoryResponse[]>;
7
+ getTokenPrices(params: TGetTokenPricesParams): Promise<TTokenPricesResponse[]>;
8
8
  }