@cityofzion/bs-neo-legacy 0.7.2 → 0.8.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.
Files changed (77) hide show
  1. package/.rush/temp/operation/build/all.log +1 -0
  2. package/.rush/temp/operation/build/state.json +3 -0
  3. package/.rush/temp/package-deps_build.json +10 -6
  4. package/.rush/temp/shrinkwrap-deps.json +350 -101
  5. package/CHANGELOG.json +22 -0
  6. package/CHANGELOG.md +11 -0
  7. package/bs-neo-legacy.build.log +1 -2
  8. package/dist/BSNeoLegacy.d.ts +24 -23
  9. package/dist/BSNeoLegacy.js +173 -171
  10. package/dist/CryptoCompareEDSNeoLegacy.d.ts +7 -7
  11. package/dist/CryptoCompareEDSNeoLegacy.js +51 -41
  12. package/dist/DoraBDSNeoLegacy.d.ts +16 -15
  13. package/dist/DoraBDSNeoLegacy.js +163 -162
  14. package/dist/DoraESNeoLegacy.d.ts +7 -0
  15. package/dist/DoraESNeoLegacy.js +17 -0
  16. package/dist/assets/tokens/common.json +18 -18
  17. package/dist/assets/tokens/mainnet.json +620 -620
  18. package/dist/constants.d.ts +13 -13
  19. package/dist/constants.js +23 -23
  20. package/dist/index.d.ts +4 -4
  21. package/dist/index.js +20 -20
  22. package/jest.config.ts +13 -13
  23. package/jest.setup.ts +1 -1
  24. package/package.json +26 -25
  25. package/src/BSNeoLegacy.ts +198 -191
  26. package/src/CryptoCompareEDSNeoLegacy.ts +50 -40
  27. package/src/DoraBDSNeoLegacy.ts +173 -171
  28. package/src/DoraESNeoLegacy.ts +18 -0
  29. package/src/__tests__/BDSNeoLegacy.spec.ts +120 -120
  30. package/src/__tests__/BSNeoLegacy.spec.ts +127 -127
  31. package/src/__tests__/CryptoCompareExchange.spec.ts +48 -46
  32. package/src/__tests__/DoraESNeoLegacy.spec.ts +15 -0
  33. package/src/assets/tokens/common.json +17 -17
  34. package/src/assets/tokens/mainnet.json +619 -619
  35. package/src/constants.ts +23 -23
  36. package/src/index.ts +4 -4
  37. package/tsconfig.build.json +4 -4
  38. package/tsconfig.json +14 -14
  39. package/dist/BDSNeoLegacy.d.ts +0 -15
  40. package/dist/BDSNeoLegacy.js +0 -199
  41. package/dist/asset/tokens.json +0 -480
  42. package/dist/explorer/dora/DoraResponsesNeoLegacy.d.ts +0 -95
  43. package/dist/explorer/dora/DoraResponsesNeoLegacy.js +0 -2
  44. package/dist/explorer/dora/DoraRoutesNeoLegacy.d.ts +0 -7
  45. package/dist/explorer/dora/DoraRoutesNeoLegacy.js +0 -10
  46. package/dist/explorer/index.d.ts +0 -6
  47. package/dist/explorer/index.js +0 -23
  48. package/docs/.nojekyll +0 -1
  49. package/docs/assets/highlight.css +0 -22
  50. package/docs/assets/main.js +0 -58
  51. package/docs/assets/search.js +0 -1
  52. package/docs/assets/style.css +0 -1280
  53. package/docs/classes/BDSNeoLegacy.html +0 -243
  54. package/docs/classes/BSNeoLegacy.html +0 -423
  55. package/docs/index.html +0 -70
  56. package/docs/interfaces/DoraNeoLegacyAsset.html +0 -103
  57. package/docs/interfaces/DoraNeoLegacyAssetResponse.html +0 -117
  58. package/docs/interfaces/DoraNeoLegacyBalance.html +0 -89
  59. package/docs/interfaces/DoraNeoLegacyConsensusNode.html +0 -75
  60. package/docs/interfaces/DoraNeoLegacyDetails.html +0 -138
  61. package/docs/interfaces/DoraNeoLegacyEntriesEntity.html +0 -110
  62. package/docs/interfaces/DoraNeoLegacyNameEntity.html +0 -75
  63. package/docs/interfaces/DoraNeoLegacyScriptsEntity.html +0 -75
  64. package/docs/interfaces/DoraNeoLegacyTransaction.html +0 -152
  65. package/docs/interfaces/DoraNeoLegacyTransactionsHistory.html +0 -96
  66. package/docs/interfaces/DoraNeoLegacyUnclaimed.html +0 -82
  67. package/docs/interfaces/DoraNeoLegacyVinEntity.html +0 -75
  68. package/docs/interfaces/DoraNeoLegacyVoutEntity.html +0 -89
  69. package/docs/modules.html +0 -98
  70. package/docs/variables/DORA_NEO_LEGACY_ASSET.html +0 -69
  71. package/docs/variables/DORA_NEO_LEGACY_BALANCE.html +0 -69
  72. package/docs/variables/DORA_NEO_LEGACY_CONTRACT.html +0 -69
  73. package/docs/variables/DORA_NEO_LEGACY_HISTORY_TRANSACTIONS.html +0 -69
  74. package/docs/variables/DORA_NEO_LEGACY_NODES.html +0 -69
  75. package/docs/variables/DORA_NEO_LEGACY_TRANSACTION.html +0 -69
  76. package/docs/variables/DORA_NEO_LEGACY_UNCLAIMED.html +0 -69
  77. package/docs/variables/explorerNeoLegacyOption.html +0 -74
@@ -1,162 +1,163 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.DoraBDSNeoLegacy = void 0;
13
- const dora_ts_1 = require("@cityofzion/dora-ts");
14
- const constants_1 = require("./constants");
15
- const neon_js_1 = require("@cityofzion/neon-js");
16
- class DoraBDSNeoLegacy {
17
- constructor(network, feeToken, claimToken) {
18
- this.tokenCache = new Map();
19
- if (network.type === 'custom')
20
- throw new Error('Custom network is not supported for NEO Legacy');
21
- this.network = network;
22
- this.claimToken = claimToken;
23
- this.feeToken = feeToken;
24
- }
25
- getTransaction(hash) {
26
- var _a, _b, _c;
27
- return __awaiter(this, void 0, void 0, function* () {
28
- const data = yield dora_ts_1.api.NeoLegacyREST.transaction(hash, this.network.type);
29
- if (!data || 'error' in data)
30
- throw new Error(`Transaction ${hash} not found`);
31
- const vout = (_a = data.vout) !== null && _a !== void 0 ? _a : [];
32
- const promises = vout.map((transfer, _index, array) => __awaiter(this, void 0, void 0, function* () {
33
- var _d;
34
- const token = yield this.getTokenInfo(transfer.asset);
35
- return {
36
- amount: String(transfer.value),
37
- from: (_d = array[array.length - 1]) === null || _d === void 0 ? void 0 : _d.address,
38
- contractHash: transfer.asset,
39
- to: transfer.address,
40
- type: 'token',
41
- token,
42
- };
43
- }));
44
- const transfers = yield Promise.all(promises);
45
- return {
46
- hash: data.txid,
47
- block: data.block,
48
- 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),
49
- time: Number(data.time),
50
- notifications: [],
51
- transfers,
52
- };
53
- });
54
- }
55
- getTransactionsByAddress({ address, page = 1, }) {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- const data = yield dora_ts_1.api.NeoLegacyREST.getAddressAbstracts(address, page, this.network.type);
58
- const transactions = new Map();
59
- const promises = data.entries.map((entry) => __awaiter(this, void 0, void 0, function* () {
60
- var _a, _b;
61
- if (entry.address_from !== address && entry.address_to !== address)
62
- return;
63
- const token = yield this.getTokenInfo(entry.asset);
64
- const transfer = {
65
- amount: String(entry.amount),
66
- from: (_a = entry.address_from) !== null && _a !== void 0 ? _a : 'Mint',
67
- to: (_b = entry.address_to) !== null && _b !== void 0 ? _b : 'Burn',
68
- type: 'token',
69
- contractHash: entry.asset,
70
- token,
71
- };
72
- const existingTransaction = transactions.get(entry.txid);
73
- if (existingTransaction) {
74
- existingTransaction.transfers.push(transfer);
75
- return;
76
- }
77
- transactions.set(entry.txid, {
78
- block: entry.block_height,
79
- hash: entry.txid,
80
- time: entry.time,
81
- transfers: [transfer],
82
- notifications: [],
83
- });
84
- }));
85
- yield Promise.all(promises);
86
- return {
87
- totalCount: data.total_entries,
88
- limit: data.page_size,
89
- transactions: Array.from(transactions.values()),
90
- };
91
- });
92
- }
93
- getContract(contractHash) {
94
- return __awaiter(this, void 0, void 0, function* () {
95
- const response = yield dora_ts_1.api.NeoLegacyREST.contract(contractHash, this.network.type);
96
- if (!response || 'error' in response)
97
- throw new Error(`Contract ${contractHash} not found`);
98
- return {
99
- hash: response.hash,
100
- name: response.name,
101
- methods: [],
102
- };
103
- });
104
- }
105
- getTokenInfo(tokenHash) {
106
- return __awaiter(this, void 0, void 0, function* () {
107
- const localToken = constants_1.TOKENS[this.network.type].find(token => token.hash === tokenHash);
108
- if (localToken)
109
- return localToken;
110
- if (this.tokenCache.has(tokenHash)) {
111
- return this.tokenCache.get(tokenHash);
112
- }
113
- const data = yield dora_ts_1.api.NeoLegacyREST.asset(tokenHash, this.network.type);
114
- if (!data || 'error' in data)
115
- throw new Error(`Token ${tokenHash} not found`);
116
- const token = {
117
- decimals: data.decimals,
118
- symbol: data.symbol,
119
- hash: data.scripthash,
120
- name: data.name,
121
- };
122
- this.tokenCache.set(tokenHash, token);
123
- return token;
124
- });
125
- }
126
- getBalance(address) {
127
- return __awaiter(this, void 0, void 0, function* () {
128
- const data = yield dora_ts_1.api.NeoLegacyREST.balance(address, this.network.type);
129
- const promises = data.map((balance) => __awaiter(this, void 0, void 0, function* () {
130
- let token = {
131
- hash: balance.asset,
132
- name: balance.asset_name,
133
- symbol: balance.symbol,
134
- decimals: 8,
135
- };
136
- try {
137
- token = yield this.getTokenInfo(balance.asset);
138
- }
139
- catch (_a) { }
140
- return {
141
- amount: Number(balance.balance).toFixed(token.decimals),
142
- token,
143
- };
144
- }));
145
- const result = yield Promise.all(promises);
146
- return result;
147
- });
148
- }
149
- getUnclaimed(address) {
150
- return __awaiter(this, void 0, void 0, function* () {
151
- const { unclaimed } = yield dora_ts_1.api.NeoLegacyREST.getUnclaimed(address, this.network.type);
152
- return (unclaimed / Math.pow(10, this.claimToken.decimals)).toFixed(this.claimToken.decimals);
153
- });
154
- }
155
- getBlockHeight() {
156
- return __awaiter(this, void 0, void 0, function* () {
157
- const rpcClient = new neon_js_1.rpc.RPCClient(this.network.url);
158
- return yield rpcClient.getBlockCount();
159
- });
160
- }
161
- }
162
- exports.DoraBDSNeoLegacy = DoraBDSNeoLegacy;
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.DoraBDSNeoLegacy = void 0;
13
+ const dora_ts_1 = require("@cityofzion/dora-ts");
14
+ const constants_1 = require("./constants");
15
+ const neon_js_1 = require("@cityofzion/neon-js");
16
+ class DoraBDSNeoLegacy {
17
+ constructor(network, feeToken, claimToken) {
18
+ this.tokenCache = new Map();
19
+ this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 2;
20
+ if (network.type === 'custom')
21
+ throw new Error('Custom network is not supported for NEO Legacy');
22
+ this.network = network;
23
+ this.claimToken = claimToken;
24
+ this.feeToken = feeToken;
25
+ }
26
+ getTransaction(hash) {
27
+ var _a, _b, _c;
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const data = yield dora_ts_1.api.NeoLegacyREST.transaction(hash, this.network.type);
30
+ if (!data || 'error' in data)
31
+ throw new Error(`Transaction ${hash} not found`);
32
+ const vout = (_a = data.vout) !== null && _a !== void 0 ? _a : [];
33
+ const promises = vout.map((transfer, _index, array) => __awaiter(this, void 0, void 0, function* () {
34
+ var _d;
35
+ const token = yield this.getTokenInfo(transfer.asset);
36
+ return {
37
+ amount: String(transfer.value),
38
+ from: (_d = array[array.length - 1]) === null || _d === void 0 ? void 0 : _d.address,
39
+ contractHash: transfer.asset,
40
+ to: transfer.address,
41
+ type: 'token',
42
+ token,
43
+ };
44
+ }));
45
+ const transfers = yield Promise.all(promises);
46
+ return {
47
+ hash: data.txid,
48
+ 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),
50
+ time: Number(data.time),
51
+ notifications: [],
52
+ transfers,
53
+ };
54
+ });
55
+ }
56
+ getTransactionsByAddress({ address, page = 1, }) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ const data = yield dora_ts_1.api.NeoLegacyREST.getAddressAbstracts(address, page, this.network.type);
59
+ const transactions = new Map();
60
+ const promises = data.entries.map((entry) => __awaiter(this, void 0, void 0, function* () {
61
+ var _a, _b;
62
+ if (entry.address_from !== address && entry.address_to !== address)
63
+ return;
64
+ const token = yield this.getTokenInfo(entry.asset);
65
+ const transfer = {
66
+ amount: String(entry.amount),
67
+ from: (_a = entry.address_from) !== null && _a !== void 0 ? _a : 'Mint',
68
+ to: (_b = entry.address_to) !== null && _b !== void 0 ? _b : 'Burn',
69
+ type: 'token',
70
+ contractHash: entry.asset,
71
+ token,
72
+ };
73
+ const existingTransaction = transactions.get(entry.txid);
74
+ if (existingTransaction) {
75
+ existingTransaction.transfers.push(transfer);
76
+ return;
77
+ }
78
+ transactions.set(entry.txid, {
79
+ block: entry.block_height,
80
+ hash: entry.txid,
81
+ time: entry.time,
82
+ transfers: [transfer],
83
+ notifications: [],
84
+ });
85
+ }));
86
+ yield Promise.all(promises);
87
+ return {
88
+ totalCount: data.total_entries,
89
+ limit: data.page_size,
90
+ transactions: Array.from(transactions.values()),
91
+ };
92
+ });
93
+ }
94
+ getContract(contractHash) {
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ const response = yield dora_ts_1.api.NeoLegacyREST.contract(contractHash, this.network.type);
97
+ if (!response || 'error' in response)
98
+ throw new Error(`Contract ${contractHash} not found`);
99
+ return {
100
+ hash: response.hash,
101
+ name: response.name,
102
+ methods: [],
103
+ };
104
+ });
105
+ }
106
+ getTokenInfo(tokenHash) {
107
+ return __awaiter(this, void 0, void 0, function* () {
108
+ const localToken = constants_1.TOKENS[this.network.type].find(token => token.hash === tokenHash);
109
+ if (localToken)
110
+ return localToken;
111
+ if (this.tokenCache.has(tokenHash)) {
112
+ return this.tokenCache.get(tokenHash);
113
+ }
114
+ const data = yield dora_ts_1.api.NeoLegacyREST.asset(tokenHash, this.network.type);
115
+ if (!data || 'error' in data)
116
+ throw new Error(`Token ${tokenHash} not found`);
117
+ const token = {
118
+ decimals: data.decimals,
119
+ symbol: data.symbol,
120
+ hash: data.scripthash,
121
+ name: data.name,
122
+ };
123
+ this.tokenCache.set(tokenHash, token);
124
+ return token;
125
+ });
126
+ }
127
+ getBalance(address) {
128
+ return __awaiter(this, void 0, void 0, function* () {
129
+ const data = yield dora_ts_1.api.NeoLegacyREST.balance(address, this.network.type);
130
+ const promises = data.map((balance) => __awaiter(this, void 0, void 0, function* () {
131
+ let token = {
132
+ hash: balance.asset,
133
+ name: balance.asset_name,
134
+ symbol: balance.symbol,
135
+ decimals: 8,
136
+ };
137
+ try {
138
+ token = yield this.getTokenInfo(balance.asset);
139
+ }
140
+ catch (_a) { }
141
+ return {
142
+ amount: Number(balance.balance).toFixed(token.decimals),
143
+ token,
144
+ };
145
+ }));
146
+ const result = yield Promise.all(promises);
147
+ return result;
148
+ });
149
+ }
150
+ getUnclaimed(address) {
151
+ return __awaiter(this, void 0, void 0, function* () {
152
+ const { unclaimed } = yield dora_ts_1.api.NeoLegacyREST.getUnclaimed(address, this.network.type);
153
+ return (unclaimed / Math.pow(10, this.claimToken.decimals)).toFixed(this.claimToken.decimals);
154
+ });
155
+ }
156
+ getBlockHeight() {
157
+ return __awaiter(this, void 0, void 0, function* () {
158
+ const rpcClient = new neon_js_1.rpc.RPCClient(this.network.url);
159
+ return yield rpcClient.getBlockCount();
160
+ });
161
+ }
162
+ }
163
+ exports.DoraBDSNeoLegacy = DoraBDSNeoLegacy;
@@ -0,0 +1,7 @@
1
+ import { BuildNftUrlParams, ExplorerService, NetworkType } from '@cityofzion/blockchain-service';
2
+ export declare class DoraESNeoLegacy implements ExplorerService {
3
+ private networkType;
4
+ constructor(networkType: NetworkType);
5
+ buildTransactionUrl(hash: string): string;
6
+ buildNftUrl(_params: BuildNftUrlParams): string;
7
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DoraESNeoLegacy = void 0;
4
+ class DoraESNeoLegacy {
5
+ constructor(networkType) {
6
+ this.networkType = networkType;
7
+ }
8
+ buildTransactionUrl(hash) {
9
+ if (this.networkType === 'custom')
10
+ throw new Error('DoraESNeoLegacy does not support custom network');
11
+ return `https://dora.coz.io/transaction/neo2/${this.networkType}/${hash}`;
12
+ }
13
+ buildNftUrl(_params) {
14
+ throw new Error('DoraESNeoLegacy does not support nft');
15
+ }
16
+ }
17
+ exports.DoraESNeoLegacy = DoraESNeoLegacy;
@@ -1,18 +1,18 @@
1
- [
2
- {
3
- "symbol": "GAS",
4
- "type": "UtilityToken",
5
- "name": "GAS",
6
- "hash": "602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7",
7
- "decimals": 8,
8
- "blockchain": "neoLegacy"
9
- },
10
- {
11
- "symbol": "NEO",
12
- "type": "GoverningToken",
13
- "name": "NEO",
14
- "hash": "c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b",
15
- "decimals": 0,
16
- "blockchain": "neoLegacy"
17
- }
18
- ]
1
+ [
2
+ {
3
+ "symbol": "GAS",
4
+ "type": "UtilityToken",
5
+ "name": "GAS",
6
+ "hash": "602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7",
7
+ "decimals": 8,
8
+ "blockchain": "neoLegacy"
9
+ },
10
+ {
11
+ "symbol": "NEO",
12
+ "type": "GoverningToken",
13
+ "name": "NEO",
14
+ "hash": "c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b",
15
+ "decimals": 0,
16
+ "blockchain": "neoLegacy"
17
+ }
18
+ ]