@cityofzion/bs-neo-legacy 1.10.10 → 1.11.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.
@@ -51,7 +51,7 @@ class BSNeoLegacy {
51
51
  }
52
52
  testNetwork(network) {
53
53
  return __awaiter(this, void 0, void 0, function* () {
54
- const blockchainDataServiceClone = new DoraBDSNeoLegacy_1.DoraBDSNeoLegacy(network, this.feeToken, this.claimToken, this.tokens);
54
+ const blockchainDataServiceClone = new DoraBDSNeoLegacy_1.DoraBDSNeoLegacy(network, this.feeToken, this.claimToken, this.tokens, this.explorerService);
55
55
  yield blockchainDataServiceClone.getBlockHeight();
56
56
  });
57
57
  }
@@ -60,9 +60,9 @@ class BSNeoLegacy {
60
60
  throw new Error('Custom network is not supported');
61
61
  __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_setTokens).call(this, network);
62
62
  this.network = network;
63
- this.blockchainDataService = new DoraBDSNeoLegacy_1.DoraBDSNeoLegacy(network, this.feeToken, this.claimToken, this.tokens);
64
- this.exchangeDataService = new CryptoCompareEDSNeoLegacy_1.CryptoCompareEDSNeoLegacy(network);
65
63
  this.explorerService = new NeoTubeESNeoLegacy_1.NeoTubeESNeoLegacy(network);
64
+ this.blockchainDataService = new DoraBDSNeoLegacy_1.DoraBDSNeoLegacy(network, this.feeToken, this.claimToken, this.tokens, this.explorerService);
65
+ this.exchangeDataService = new CryptoCompareEDSNeoLegacy_1.CryptoCompareEDSNeoLegacy(network);
66
66
  }
67
67
  validateAddress(address) {
68
68
  return neon_js_1.wallet.isAddress(address);
@@ -1,11 +1,12 @@
1
- import { BalanceResponse, BlockchainDataService, ContractResponse, TransactionsByAddressParams, TransactionsByAddressResponse, TransactionResponse, BDSClaimable, Token, Network, RpcResponse } from '@cityofzion/blockchain-service';
1
+ import { BalanceResponse, BDSClaimable, BlockchainDataService, ContractResponse, ExplorerService, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, Network, RpcResponse, Token, 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[]);
6
+ constructor(network: Network<BSNeoLegacyNetworkId>, feeToken: Token, claimToken: Token, tokens: Token[], explorerService: ExplorerService);
7
7
  getTransaction(hash: string): Promise<TransactionResponse>;
8
8
  getTransactionsByAddress({ address, nextPageParams, }: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
9
+ getFullTransactionsByAddress(params: FullTransactionsByAddressParams): Promise<FullTransactionsByAddressResponse>;
9
10
  getContract(contractHash: string): Promise<ContractResponse>;
10
11
  getTokenInfo(tokenHash: string): Promise<Token>;
11
12
  getBalance(address: string): Promise<BalanceResponse[]>;
@@ -19,24 +19,40 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
19
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
20
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
21
21
  };
22
- var _DoraBDSNeoLegacy_network, _DoraBDSNeoLegacy_claimToken, _DoraBDSNeoLegacy_feeToken, _DoraBDSNeoLegacy_tokens, _DoraBDSNeoLegacy_tokenCache;
22
+ var __rest = (this && this.__rest) || function (s, e) {
23
+ var t = {};
24
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
25
+ t[p] = s[p];
26
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
27
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
28
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
29
+ t[p[i]] = s[p[i]];
30
+ }
31
+ return t;
32
+ };
33
+ var _DoraBDSNeoLegacy_instances, _DoraBDSNeoLegacy_supportedNep5Standards, _DoraBDSNeoLegacy_network, _DoraBDSNeoLegacy_claimToken, _DoraBDSNeoLegacy_feeToken, _DoraBDSNeoLegacy_tokens, _DoraBDSNeoLegacy_tokenCache, _DoraBDSNeoLegacy_explorerService, _DoraBDSNeoLegacy_validateFullTransactionsByAddressParams;
23
34
  Object.defineProperty(exports, "__esModule", { value: true });
24
35
  exports.DoraBDSNeoLegacy = void 0;
36
+ const blockchain_service_1 = require("@cityofzion/blockchain-service");
25
37
  const dora_ts_1 = require("@cityofzion/dora-ts");
26
38
  const neon_js_1 = require("@cityofzion/neon-js");
27
39
  const BSNeoLegacyHelper_1 = require("../../helpers/BSNeoLegacyHelper");
28
40
  class DoraBDSNeoLegacy {
29
- constructor(network, feeToken, claimToken, tokens) {
41
+ constructor(network, feeToken, claimToken, tokens, explorerService) {
42
+ _DoraBDSNeoLegacy_instances.add(this);
43
+ _DoraBDSNeoLegacy_supportedNep5Standards.set(this, ['nep5', 'nep-5']);
30
44
  _DoraBDSNeoLegacy_network.set(this, void 0);
31
45
  _DoraBDSNeoLegacy_claimToken.set(this, void 0);
32
46
  _DoraBDSNeoLegacy_feeToken.set(this, void 0);
33
47
  _DoraBDSNeoLegacy_tokens.set(this, void 0);
34
48
  _DoraBDSNeoLegacy_tokenCache.set(this, new Map());
49
+ _DoraBDSNeoLegacy_explorerService.set(this, void 0);
35
50
  this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 2;
36
51
  __classPrivateFieldSet(this, _DoraBDSNeoLegacy_network, network, "f");
37
52
  __classPrivateFieldSet(this, _DoraBDSNeoLegacy_claimToken, claimToken, "f");
38
53
  __classPrivateFieldSet(this, _DoraBDSNeoLegacy_feeToken, feeToken, "f");
39
54
  __classPrivateFieldSet(this, _DoraBDSNeoLegacy_tokens, tokens, "f");
55
+ __classPrivateFieldSet(this, _DoraBDSNeoLegacy_explorerService, explorerService, "f");
40
56
  }
41
57
  getTransaction(hash) {
42
58
  var _a, _b, _c;
@@ -106,6 +122,66 @@ class DoraBDSNeoLegacy {
106
122
  };
107
123
  });
108
124
  }
125
+ getFullTransactionsByAddress(params) {
126
+ var _a;
127
+ return __awaiter(this, void 0, void 0, function* () {
128
+ __classPrivateFieldGet(this, _DoraBDSNeoLegacy_instances, "m", _DoraBDSNeoLegacy_validateFullTransactionsByAddressParams).call(this, params);
129
+ const data = [];
130
+ const _b = yield dora_ts_1.api.NeoLegacyREST.getFullTransactionsByAddress({
131
+ address: params.address,
132
+ timestampFrom: params.dateFrom,
133
+ timestampTo: params.dateTo,
134
+ network: 'mainnet',
135
+ cursor: params.nextCursor,
136
+ }), { nextCursor } = _b, response = __rest(_b, ["nextCursor"]);
137
+ const items = (_a = response.data) !== null && _a !== void 0 ? _a : [];
138
+ const addressTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_explorerService, "f").getAddressTemplateUrl();
139
+ const txTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_explorerService, "f").getTxTemplateUrl();
140
+ const contractTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_explorerService, "f").getContractTemplateUrl();
141
+ const itemPromises = items.map((item) => __awaiter(this, void 0, void 0, function* () {
142
+ const txId = item.transactionID;
143
+ const newItem = {
144
+ txId,
145
+ txIdUrl: txId ? txTemplateUrl === null || txTemplateUrl === void 0 ? void 0 : txTemplateUrl.replace('{txId}', txId) : undefined,
146
+ block: item.block,
147
+ date: item.date,
148
+ invocationCount: item.invocationCount,
149
+ notificationCount: item.notificationCount,
150
+ networkFeeAmount: (0, blockchain_service_1.formatNumber)(item.networkFeeAmount, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_feeToken, "f").decimals),
151
+ systemFeeAmount: (0, blockchain_service_1.formatNumber)(item.systemFeeAmount, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_feeToken, "f").decimals),
152
+ events: [],
153
+ };
154
+ const eventPromises = item.events.map((event) => __awaiter(this, void 0, void 0, function* () {
155
+ var _c, _d, _e, _f;
156
+ const { contractHash: hash, amount, from, to } = event;
157
+ const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(hash));
158
+ const standard = (_e = (_d = (_c = event.supportedStandards) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.toLowerCase()) !== null && _e !== void 0 ? _e : '';
159
+ const isNep5 = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_supportedNep5Standards, "f").includes(standard);
160
+ const toUrl = to ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', to) : undefined;
161
+ const fromUrl = from ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', from) : undefined;
162
+ const hashUrl = hash ? contractTemplateUrl === null || contractTemplateUrl === void 0 ? void 0 : contractTemplateUrl.replace('{hash}', hash) : undefined;
163
+ const assetEvent = {
164
+ eventType: 'token',
165
+ amount: (0, blockchain_service_1.formatNumber)(amount, (_f = token === null || token === void 0 ? void 0 : token.decimals) !== null && _f !== void 0 ? _f : event.tokenDecimals),
166
+ methodName: event.methodName,
167
+ from: from || 'Mint',
168
+ fromUrl,
169
+ to: to || 'Burn',
170
+ toUrl,
171
+ hash,
172
+ hashUrl,
173
+ token: token !== null && token !== void 0 ? token : undefined,
174
+ tokenType: isNep5 ? 'nep-5' : 'generic',
175
+ };
176
+ newItem.events.push(assetEvent);
177
+ }));
178
+ yield Promise.allSettled(eventPromises);
179
+ data.push(newItem);
180
+ }));
181
+ yield Promise.allSettled(itemPromises);
182
+ return { nextCursor, data };
183
+ });
184
+ }
109
185
  getContract(contractHash) {
110
186
  return __awaiter(this, void 0, void 0, function* () {
111
187
  const response = yield dora_ts_1.api.NeoLegacyREST.contract(contractHash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").id);
@@ -161,8 +237,7 @@ class DoraBDSNeoLegacy {
161
237
  token,
162
238
  };
163
239
  }));
164
- const result = yield Promise.all(promises);
165
- return result;
240
+ return yield Promise.all(promises);
166
241
  });
167
242
  }
168
243
  getUnclaimed(address) {
@@ -206,4 +281,10 @@ class DoraBDSNeoLegacy {
206
281
  }
207
282
  }
208
283
  exports.DoraBDSNeoLegacy = DoraBDSNeoLegacy;
209
- _DoraBDSNeoLegacy_network = new WeakMap(), _DoraBDSNeoLegacy_claimToken = new WeakMap(), _DoraBDSNeoLegacy_feeToken = new WeakMap(), _DoraBDSNeoLegacy_tokens = new WeakMap(), _DoraBDSNeoLegacy_tokenCache = new WeakMap();
284
+ _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) {
285
+ if (!BSNeoLegacyHelper_1.BSNeoLegacyHelper.isMainnet(__classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f")))
286
+ throw new Error('Only Mainnet is supported');
287
+ blockchain_service_1.BSFullTransactionsByAddressHelper.validateFullTransactionsByAddressParams(params);
288
+ if (!neon_js_1.wallet.isAddress(params.address))
289
+ throw new Error('Invalid address param');
290
+ };
@@ -8,4 +8,6 @@ export declare class NeoTubeESNeoLegacy implements ExplorerService {
8
8
  buildNftUrl(_params: BuildNftUrlParams): string;
9
9
  getAddressTemplateUrl(): string | undefined;
10
10
  getTxTemplateUrl(): string | undefined;
11
+ getNftTemplateUrl(): undefined;
12
+ getContractTemplateUrl(): string | undefined;
11
13
  }
@@ -44,6 +44,14 @@ class NeoTubeESNeoLegacy {
44
44
  return undefined;
45
45
  return `${__classPrivateFieldGet(this, _NeoTubeESNeoLegacy_BASE_URL, "f")}/transaction/{txId}`;
46
46
  }
47
+ getNftTemplateUrl() {
48
+ return undefined;
49
+ }
50
+ getContractTemplateUrl() {
51
+ if (!BSNeoLegacyHelper_1.BSNeoLegacyHelper.isMainnet(__classPrivateFieldGet(this, _NeoTubeESNeoLegacy_network, "f")))
52
+ return undefined;
53
+ return `${__classPrivateFieldGet(this, _NeoTubeESNeoLegacy_BASE_URL, "f")}/asset/{hash}/page/1`;
54
+ }
47
55
  }
48
56
  exports.NeoTubeESNeoLegacy = NeoTubeESNeoLegacy;
49
57
  _NeoTubeESNeoLegacy_BASE_URL = new WeakMap(), _NeoTubeESNeoLegacy_network = new WeakMap();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityofzion/bs-neo-legacy",
3
- "version": "1.10.10",
3
+ "version": "1.11.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "Coz",
@@ -9,11 +9,13 @@
9
9
  "/dist"
10
10
  ],
11
11
  "dependencies": {
12
- "@cityofzion/dora-ts": "0.0.11",
12
+ "@cityofzion/dora-ts": "0.4.0",
13
13
  "@cityofzion/neon-js": "4.8.3",
14
14
  "@ledgerhq/hw-transport": "~6.30.5",
15
- "@cityofzion/blockchain-service": "1.17.0",
16
- "@cityofzion/bs-asteroid-sdk": "0.9.1"
15
+ "axios": "1.8.2",
16
+ "date-fns": "~4.1.0",
17
+ "@cityofzion/bs-asteroid-sdk": "0.9.1",
18
+ "@cityofzion/blockchain-service": "1.17.1"
17
19
  },
18
20
  "devDependencies": {
19
21
  "@types/jest": "29.5.3",