@cityofzion/bs-neo-legacy 0.9.2 → 0.10.0

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,7 +1,7 @@
1
1
  import { Currency, ExchangeDataService, NetworkType, TokenPricesResponse } from '@cityofzion/blockchain-service';
2
2
  export declare class CryptoCompareEDSNeoLegacy implements ExchangeDataService {
3
+ #private;
3
4
  networkType: NetworkType;
4
- private axiosInstance;
5
5
  constructor(network: NetworkType);
6
6
  getTokenPrices(currency: Currency): Promise<TokenPricesResponse[]>;
7
7
  }
@@ -8,17 +8,30 @@ 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 __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
+ };
11
22
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
24
  };
25
+ var _CryptoCompareEDSNeoLegacy_axiosInstance;
14
26
  Object.defineProperty(exports, "__esModule", { value: true });
15
27
  exports.CryptoCompareEDSNeoLegacy = void 0;
16
28
  const axios_1 = __importDefault(require("axios"));
17
29
  const constants_1 = require("./constants");
18
30
  class CryptoCompareEDSNeoLegacy {
19
31
  constructor(network) {
32
+ _CryptoCompareEDSNeoLegacy_axiosInstance.set(this, void 0);
20
33
  this.networkType = network;
21
- this.axiosInstance = axios_1.default.create({ baseURL: 'https://min-api.cryptocompare.com' });
34
+ __classPrivateFieldSet(this, _CryptoCompareEDSNeoLegacy_axiosInstance, axios_1.default.create({ baseURL: 'https://min-api.cryptocompare.com' }), "f");
22
35
  }
23
36
  getTokenPrices(currency) {
24
37
  return __awaiter(this, void 0, void 0, function* () {
@@ -26,7 +39,7 @@ class CryptoCompareEDSNeoLegacy {
26
39
  throw new Error('Exchange is only available on mainnet');
27
40
  const tokens = constants_1.TOKENS[this.networkType];
28
41
  const tokenSymbols = tokens.map(token => token.symbol);
29
- const { data: prices } = yield this.axiosInstance.get('/data/pricemultifull', {
42
+ const { data: prices } = yield __classPrivateFieldGet(this, _CryptoCompareEDSNeoLegacy_axiosInstance, "f").get('/data/pricemultifull', {
30
43
  params: {
31
44
  fsyms: tokenSymbols.join(','),
32
45
  tsyms: currency,
@@ -49,3 +62,4 @@ class CryptoCompareEDSNeoLegacy {
49
62
  }
50
63
  }
51
64
  exports.CryptoCompareEDSNeoLegacy = CryptoCompareEDSNeoLegacy;
65
+ _CryptoCompareEDSNeoLegacy_axiosInstance = new WeakMap();
@@ -1,9 +1,6 @@
1
1
  import { BalanceResponse, BlockchainDataService, ContractResponse, TransactionsByAddressParams, TransactionsByAddressResponse, TransactionResponse, BDSClaimable, Token, Network } from '@cityofzion/blockchain-service';
2
2
  export declare class DoraBDSNeoLegacy implements BlockchainDataService, BDSClaimable {
3
- readonly network: Network;
4
- private readonly claimToken;
5
- private readonly feeToken;
6
- private readonly tokenCache;
3
+ #private;
7
4
  maxTimeToConfirmTransactionInMs: number;
8
5
  constructor(network: Network, feeToken: Token, claimToken: Token);
9
6
  getTransaction(hash: string): Promise<TransactionResponse>;
@@ -8,6 +8,18 @@ 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 __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 _DoraBDSNeoLegacy_network, _DoraBDSNeoLegacy_claimToken, _DoraBDSNeoLegacy_feeToken, _DoraBDSNeoLegacy_tokenCache;
11
23
  Object.defineProperty(exports, "__esModule", { value: true });
12
24
  exports.DoraBDSNeoLegacy = void 0;
13
25
  const dora_ts_1 = require("@cityofzion/dora-ts");
@@ -15,18 +27,21 @@ const constants_1 = require("./constants");
15
27
  const neon_js_1 = require("@cityofzion/neon-js");
16
28
  class DoraBDSNeoLegacy {
17
29
  constructor(network, feeToken, claimToken) {
18
- this.tokenCache = new Map();
30
+ _DoraBDSNeoLegacy_network.set(this, void 0);
31
+ _DoraBDSNeoLegacy_claimToken.set(this, void 0);
32
+ _DoraBDSNeoLegacy_feeToken.set(this, void 0);
33
+ _DoraBDSNeoLegacy_tokenCache.set(this, new Map());
19
34
  this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 2;
20
35
  if (network.type === 'custom')
21
36
  throw new Error('Custom network is not supported for NEO Legacy');
22
- this.network = network;
23
- this.claimToken = claimToken;
24
- this.feeToken = feeToken;
37
+ __classPrivateFieldSet(this, _DoraBDSNeoLegacy_network, network, "f");
38
+ __classPrivateFieldSet(this, _DoraBDSNeoLegacy_claimToken, claimToken, "f");
39
+ __classPrivateFieldSet(this, _DoraBDSNeoLegacy_feeToken, feeToken, "f");
25
40
  }
26
41
  getTransaction(hash) {
27
42
  var _a, _b, _c;
28
43
  return __awaiter(this, void 0, void 0, function* () {
29
- const data = yield dora_ts_1.api.NeoLegacyREST.transaction(hash, this.network.type);
44
+ const data = yield dora_ts_1.api.NeoLegacyREST.transaction(hash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").type);
30
45
  if (!data || 'error' in data)
31
46
  throw new Error(`Transaction ${hash} not found`);
32
47
  const vout = (_a = data.vout) !== null && _a !== void 0 ? _a : [];
@@ -46,7 +61,7 @@ class DoraBDSNeoLegacy {
46
61
  return {
47
62
  hash: data.txid,
48
63
  block: data.block,
49
- fee: (Number((_b = data.sys_fee) !== null && _b !== void 0 ? _b : 0) + Number((_c = data.net_fee) !== null && _c !== void 0 ? _c : 0)).toFixed(this.feeToken.decimals),
64
+ 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),
50
65
  time: Number(data.time),
51
66
  notifications: [],
52
67
  transfers,
@@ -55,7 +70,7 @@ class DoraBDSNeoLegacy {
55
70
  }
56
71
  getTransactionsByAddress({ address, page = 1, }) {
57
72
  return __awaiter(this, void 0, void 0, function* () {
58
- const data = yield dora_ts_1.api.NeoLegacyREST.getAddressAbstracts(address, page, this.network.type);
73
+ const data = yield dora_ts_1.api.NeoLegacyREST.getAddressAbstracts(address, page, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").type);
59
74
  const transactions = new Map();
60
75
  const promises = data.entries.map((entry) => __awaiter(this, void 0, void 0, function* () {
61
76
  var _a, _b;
@@ -93,7 +108,7 @@ class DoraBDSNeoLegacy {
93
108
  }
94
109
  getContract(contractHash) {
95
110
  return __awaiter(this, void 0, void 0, function* () {
96
- const response = yield dora_ts_1.api.NeoLegacyREST.contract(contractHash, this.network.type);
111
+ const response = yield dora_ts_1.api.NeoLegacyREST.contract(contractHash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").type);
97
112
  if (!response || 'error' in response)
98
113
  throw new Error(`Contract ${contractHash} not found`);
99
114
  return {
@@ -105,13 +120,13 @@ class DoraBDSNeoLegacy {
105
120
  }
106
121
  getTokenInfo(tokenHash) {
107
122
  return __awaiter(this, void 0, void 0, function* () {
108
- const localToken = constants_1.TOKENS[this.network.type].find(token => token.hash === tokenHash);
123
+ const localToken = constants_1.TOKENS[__classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").type].find(token => token.hash === tokenHash);
109
124
  if (localToken)
110
125
  return localToken;
111
- if (this.tokenCache.has(tokenHash)) {
112
- return this.tokenCache.get(tokenHash);
126
+ if (__classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokenCache, "f").has(tokenHash)) {
127
+ return __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokenCache, "f").get(tokenHash);
113
128
  }
114
- const data = yield dora_ts_1.api.NeoLegacyREST.asset(tokenHash, this.network.type);
129
+ const data = yield dora_ts_1.api.NeoLegacyREST.asset(tokenHash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").type);
115
130
  if (!data || 'error' in data)
116
131
  throw new Error(`Token ${tokenHash} not found`);
117
132
  const token = {
@@ -120,13 +135,13 @@ class DoraBDSNeoLegacy {
120
135
  hash: data.scripthash,
121
136
  name: data.name,
122
137
  };
123
- this.tokenCache.set(tokenHash, token);
138
+ __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokenCache, "f").set(tokenHash, token);
124
139
  return token;
125
140
  });
126
141
  }
127
142
  getBalance(address) {
128
143
  return __awaiter(this, void 0, void 0, function* () {
129
- const data = yield dora_ts_1.api.NeoLegacyREST.balance(address, this.network.type);
144
+ const data = yield dora_ts_1.api.NeoLegacyREST.balance(address, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").type);
130
145
  const promises = data.map((balance) => __awaiter(this, void 0, void 0, function* () {
131
146
  const hash = balance.asset.replace('0x', '');
132
147
  let token = {
@@ -152,15 +167,16 @@ class DoraBDSNeoLegacy {
152
167
  }
153
168
  getUnclaimed(address) {
154
169
  return __awaiter(this, void 0, void 0, function* () {
155
- const { unclaimed } = yield dora_ts_1.api.NeoLegacyREST.getUnclaimed(address, this.network.type);
156
- return (unclaimed / Math.pow(10, this.claimToken.decimals)).toFixed(this.claimToken.decimals);
170
+ const { unclaimed } = yield dora_ts_1.api.NeoLegacyREST.getUnclaimed(address, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").type);
171
+ return (unclaimed / Math.pow(10, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_claimToken, "f").decimals)).toFixed(__classPrivateFieldGet(this, _DoraBDSNeoLegacy_claimToken, "f").decimals);
157
172
  });
158
173
  }
159
174
  getBlockHeight() {
160
175
  return __awaiter(this, void 0, void 0, function* () {
161
- const rpcClient = new neon_js_1.rpc.RPCClient(this.network.url);
176
+ const rpcClient = new neon_js_1.rpc.RPCClient(__classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").url);
162
177
  return yield rpcClient.getBlockCount();
163
178
  });
164
179
  }
165
180
  }
166
181
  exports.DoraBDSNeoLegacy = DoraBDSNeoLegacy;
182
+ _DoraBDSNeoLegacy_network = new WeakMap(), _DoraBDSNeoLegacy_claimToken = new WeakMap(), _DoraBDSNeoLegacy_feeToken = new WeakMap(), _DoraBDSNeoLegacy_tokenCache = new WeakMap();
@@ -1,6 +1,6 @@
1
1
  import { BuildNftUrlParams, ExplorerService, NetworkType } from '@cityofzion/blockchain-service';
2
2
  export declare class DoraESNeoLegacy implements ExplorerService {
3
- private networkType;
3
+ #private;
4
4
  constructor(networkType: NetworkType);
5
5
  buildTransactionUrl(hash: string): string;
6
6
  buildNftUrl(_params: BuildNftUrlParams): string;
@@ -1,17 +1,31 @@
1
1
  "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ 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");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
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
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _DoraESNeoLegacy_networkType;
2
14
  Object.defineProperty(exports, "__esModule", { value: true });
3
15
  exports.DoraESNeoLegacy = void 0;
4
16
  class DoraESNeoLegacy {
5
17
  constructor(networkType) {
6
- this.networkType = networkType;
18
+ _DoraESNeoLegacy_networkType.set(this, void 0);
19
+ __classPrivateFieldSet(this, _DoraESNeoLegacy_networkType, networkType, "f");
7
20
  }
8
21
  buildTransactionUrl(hash) {
9
- if (this.networkType === 'custom')
22
+ if (__classPrivateFieldGet(this, _DoraESNeoLegacy_networkType, "f") === 'custom')
10
23
  throw new Error('DoraESNeoLegacy does not support custom network');
11
- return `https://dora.coz.io/transaction/neo2/${this.networkType}/${hash}`;
24
+ return `https://dora.coz.io/transaction/neo2/${__classPrivateFieldGet(this, _DoraESNeoLegacy_networkType, "f")}/${hash}`;
12
25
  }
13
26
  buildNftUrl(_params) {
14
27
  throw new Error('DoraESNeoLegacy does not support nft');
15
28
  }
16
29
  }
17
30
  exports.DoraESNeoLegacy = DoraESNeoLegacy;
31
+ _DoraESNeoLegacy_networkType = new WeakMap();
package/package.json CHANGED
@@ -1,16 +1,19 @@
1
1
  {
2
2
  "name": "@cityofzion/bs-neo-legacy",
3
- "version": "0.9.2",
3
+ "version": "0.10.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "Coz",
7
7
  "license": "MIT",
8
+ "files": [
9
+ "/dist"
10
+ ],
8
11
  "dependencies": {
9
12
  "@cityofzion/dora-ts": "0.0.11",
10
13
  "@cityofzion/neon-js": "4.8.3",
11
14
  "axios": "1.5.1",
12
- "@cityofzion/blockchain-service": "0.9.1",
13
- "@cityofzion/bs-asteroid-sdk": "0.7.3"
15
+ "@cityofzion/bs-asteroid-sdk": "0.8.0",
16
+ "@cityofzion/blockchain-service": "0.11.0"
14
17
  },
15
18
  "devDependencies": {
16
19
  "@types/jest": "29.5.3",
package/.eslintignore DELETED
@@ -1,13 +0,0 @@
1
- .DS_Store
2
- node_modules
3
- /build
4
- /dist
5
- /package
6
- .env
7
- .env.*
8
- !.env.example
9
- *.md
10
- *.html
11
-
12
- # Ignore files for NPM lock file
13
- package-lock.json
package/.eslintrc.cjs DELETED
@@ -1,22 +0,0 @@
1
- module.exports = {
2
- extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
3
- parser: '@typescript-eslint/parser',
4
- plugins: ['@typescript-eslint'],
5
- parserOptions: {
6
- parser: '@typescript-eslint/parser',
7
- },
8
- root: true,
9
- rules: {
10
- '@typescript-eslint/ban-ts-comment': 'off',
11
- '@typescript-eslint/no-explicit-any': 'off',
12
- '@typescript-eslint/no-unused-vars': [
13
- 'error',
14
- {
15
- varsIgnorePattern: '^_',
16
- argsIgnorePattern: '^_',
17
- },
18
- ],
19
- '@typescript-eslint/no-var-requires': 'off',
20
- 'no-unused-vars': 'off',
21
- },
22
- }
@@ -1 +0,0 @@
1
- Invoking: tsc --project tsconfig.build.json
@@ -1,3 +0,0 @@
1
- {
2
- "nonCachedDurationMs": 2055.8490029999957
3
- }
@@ -1,27 +0,0 @@
1
- {
2
- "files": {
3
- "packages/bs-neo-legacy/.eslintignore": "3ee402c88b68258919e4f4b4eef4f25e5d078d90",
4
- "packages/bs-neo-legacy/.eslintrc.cjs": "5ec0bf6332ec01b3e02beb532bb47025c4c1bf7b",
5
- "packages/bs-neo-legacy/CHANGELOG.json": "dc93c6044bcc2d0bf5d48d3592dd3c3048bcc0bd",
6
- "packages/bs-neo-legacy/CHANGELOG.md": "d9613e061e51231e66f50775553b96d8906289fc",
7
- "packages/bs-neo-legacy/jest.config.ts": "d944475db93cbe41a9339187fd94b9962e411c43",
8
- "packages/bs-neo-legacy/jest.setup.ts": "9a1976a32050616d4d2ee95b1aa21041bc4daca3",
9
- "packages/bs-neo-legacy/package.json": "40aee403a44d1630bb3530a030f92d1a39f7a34e",
10
- "packages/bs-neo-legacy/src/BSNeoLegacy.ts": "b9f8fd4989d5a1a01025b93f02e6617ba350eb56",
11
- "packages/bs-neo-legacy/src/CryptoCompareEDSNeoLegacy.ts": "baafce35ec622b2b2d80afa020f084daf6d4d59a",
12
- "packages/bs-neo-legacy/src/DoraBDSNeoLegacy.ts": "aff1263b8b00edaf3e1e1cd50edfe488e9319a62",
13
- "packages/bs-neo-legacy/src/DoraESNeoLegacy.ts": "e12df08893ac0bb0f0daecf2b61a96d9c7532bf4",
14
- "packages/bs-neo-legacy/src/__tests__/BDSNeoLegacy.spec.ts": "84a18db5dfe14e2e5d87825eb5de6fced39ffe17",
15
- "packages/bs-neo-legacy/src/__tests__/BSNeoLegacy.spec.ts": "c2c59e878ae8eeb376a469168817981e820b5466",
16
- "packages/bs-neo-legacy/src/__tests__/CryptoCompareExchange.spec.ts": "0469dc99648308249eab837f1450537afd516948",
17
- "packages/bs-neo-legacy/src/__tests__/DoraESNeoLegacy.spec.ts": "4ea3298204b96536f3e143e29e1ba6f94ce90b31",
18
- "packages/bs-neo-legacy/src/assets/tokens/common.json": "4778d3c3d06d20d5e8d6d722ce1cfe24f584a376",
19
- "packages/bs-neo-legacy/src/assets/tokens/mainnet.json": "ffca87949db47750232217973e271f64999391ba",
20
- "packages/bs-neo-legacy/src/constants.ts": "82e36146cf6cf3c16bc7b7ec4fd3e4089c745bd5",
21
- "packages/bs-neo-legacy/src/index.ts": "247e7d072502350e685e11497aeedc89b7c921d5",
22
- "packages/bs-neo-legacy/tsconfig.build.json": "4dc23fb9c4c5e4d19a9bc3947a47c523f4bd967c",
23
- "packages/bs-neo-legacy/tsconfig.json": "77cf2b789e9c665b62792f9992cc81ae86296ef7",
24
- "packages/bs-neo-legacy/.rush/temp/shrinkwrap-deps.json": "d365998031e4be1670d84c7d4a5ac3985048f53d"
25
- },
26
- "arguments": "tsc --project tsconfig.build.json "
27
- }