@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
package/src/constants.ts CHANGED
@@ -1,23 +1,23 @@
1
- import { NetworkType, Token } from '@cityofzion/blockchain-service'
2
- import commom from './assets/tokens/common.json'
3
- import mainnet from './assets/tokens/mainnet.json'
4
-
5
- export const TOKENS: Record<NetworkType, Token[]> = {
6
- mainnet: [...commom, ...mainnet],
7
- testnet: commom,
8
- custom: commom,
9
- }
10
-
11
- export const LEGACY_NETWORK_BY_NETWORK_TYPE: Record<Exclude<NetworkType, 'custom'>, string> = {
12
- mainnet: 'MainNet',
13
- testnet: 'TestNet',
14
- }
15
-
16
- export const NATIVE_ASSETS = commom
17
-
18
- export const DEFAULT_URL_BY_NETWORK_TYPE: Record<Exclude<NetworkType, 'custom'>, string> = {
19
- mainnet: 'http://seed9.ngd.network:10332',
20
- testnet: 'http://seed5.ngd.network:20332',
21
- }
22
-
23
- export const DERIVATION_PATH = "m/44'/888'/0'/0/?"
1
+ import { NetworkType, Token } from '@cityofzion/blockchain-service'
2
+ import commom from './assets/tokens/common.json'
3
+ import mainnet from './assets/tokens/mainnet.json'
4
+
5
+ export const TOKENS: Record<NetworkType, Token[]> = {
6
+ mainnet: [...commom, ...mainnet],
7
+ testnet: commom,
8
+ custom: commom,
9
+ }
10
+
11
+ export const LEGACY_NETWORK_BY_NETWORK_TYPE: Record<Exclude<NetworkType, 'custom'>, string> = {
12
+ mainnet: 'MainNet',
13
+ testnet: 'TestNet',
14
+ }
15
+
16
+ export const NATIVE_ASSETS = commom
17
+
18
+ export const DEFAULT_URL_BY_NETWORK_TYPE: Record<Exclude<NetworkType, 'custom'>, string> = {
19
+ mainnet: 'http://seed9.ngd.network:10332',
20
+ testnet: 'http://seed5.ngd.network:20332',
21
+ }
22
+
23
+ export const DERIVATION_PATH = "m/44'/888'/0'/0/?"
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './BSNeoLegacy'
2
- export * from './DoraBDSNeoLegacy'
3
- export * from './constants'
4
- export * from './CryptoCompareEDSNeoLegacy'
1
+ export * from './BSNeoLegacy'
2
+ export * from './DoraBDSNeoLegacy'
3
+ export * from './constants'
4
+ export * from './CryptoCompareEDSNeoLegacy'
@@ -1,4 +1,4 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "exclude": ["src/__tests__"]
4
- }
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "exclude": ["src/__tests__"]
4
+ }
package/tsconfig.json CHANGED
@@ -1,14 +1,14 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "lib": ["ESNext"],
5
- "outDir": "./dist"
6
- },
7
- "include": ["src"],
8
- "exclude": ["node_modules"],
9
- "typedocOptions": {
10
- "entryPoints": ["./src/index.ts"],
11
- "out": "docs",
12
- "exclude": "**/node_modules/**"
13
- }
14
- }
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "lib": ["ESNext"],
5
+ "outDir": "./dist"
6
+ },
7
+ "include": ["src"],
8
+ "exclude": ["node_modules"],
9
+ "typedocOptions": {
10
+ "entryPoints": ["./src/index.ts"],
11
+ "out": "docs",
12
+ "exclude": "**/node_modules/**"
13
+ }
14
+ }
@@ -1,15 +0,0 @@
1
- import { BalanceResponse, BlockchainNetwork, BlockchainDataService, ConsensusNodeResponse, ContractResponse, TokenInfoResponse, TransactionHistoryResponse, TransactionResponse, BDSClaimable, UnclaimedResponse } from '@cityofzion/blockchain-service';
2
- export declare class BDSNeoLegacy implements BlockchainDataService, BDSClaimable {
3
- explorer: string;
4
- network: BlockchainNetwork;
5
- private request;
6
- setNetwork(network: BlockchainNetwork): void;
7
- getTransaction(txid: string): Promise<TransactionResponse>;
8
- getHistoryTransactions(address: string, page?: number): Promise<TransactionHistoryResponse>;
9
- getContract(contractHash: string): Promise<ContractResponse>;
10
- getTokenInfo(tokenHash: string): Promise<TokenInfoResponse>;
11
- getBalance(address: string): Promise<BalanceResponse[]>;
12
- getAllNodes(): Promise<ConsensusNodeResponse[]>;
13
- getHigherNode(): Promise<ConsensusNodeResponse>;
14
- getUnclaimed(address: string): Promise<UnclaimedResponse>;
15
- }
@@ -1,199 +0,0 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.BDSNeoLegacy = void 0;
16
- const axios_1 = __importDefault(require("axios"));
17
- const DoraRoutesNeoLegacy_1 = require("./explorer/dora/DoraRoutesNeoLegacy");
18
- const dora_ts_1 = require("@cityofzion/dora-ts");
19
- class BDSNeoLegacy {
20
- constructor() {
21
- this.explorer = 'https://dora.coz.io/';
22
- this.network = 'mainnet';
23
- this.request = axios_1.default.create({ baseURL: `https://dora.coz.io/api/v1/neo2/${this.network}` });
24
- }
25
- setNetwork(network) {
26
- this.network = network;
27
- }
28
- getTransaction(txid) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- try {
31
- const { data } = yield this.request.get(`/${DoraRoutesNeoLegacy_1.DORA_NEO_LEGACY_TRANSACTION}/${txid}`);
32
- const result = {
33
- block: data.block,
34
- netfee: data.net_fee,
35
- sysfee: data.sys_fee,
36
- time: data.time,
37
- txid: data.txid,
38
- totfee: (Number(data.sys_fee) + Number(data.net_fee)).toString(),
39
- notifications: [],
40
- transfers: data.vout.map((transfer) => {
41
- var _a;
42
- return {
43
- amount: transfer.value,
44
- from: (_a = data.vout[data.vout.length - 1]) === null || _a === void 0 ? void 0 : _a.address,
45
- hash: transfer.asset,
46
- to: transfer.address
47
- };
48
- })
49
- };
50
- return result;
51
- }
52
- catch (error) {
53
- throw error;
54
- }
55
- });
56
- }
57
- getHistoryTransactions(address, page = 1) {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- try {
60
- const data = yield dora_ts_1.api.NeoLegacyREST.getAddressAbstracts(address, page, this.network);
61
- const entriesGroupByTxid = {};
62
- const transactionsGroupByTxid = [];
63
- data.entries.forEach((entry) => {
64
- entriesGroupByTxid[entry.txid] = data.entries.filter(it => it.txid === entry.txid);
65
- const haveTransaction = transactionsGroupByTxid.find(it => it.txid === entry.txid);
66
- if (!haveTransaction) {
67
- transactionsGroupByTxid.push({
68
- block: entry.block_height,
69
- netfee: '0',
70
- sysfee: '0',
71
- totfee: '0',
72
- txid: entry.txid,
73
- notifications: [],
74
- time: entry.time.toString(),
75
- transfers: entriesGroupByTxid[entry.txid].map((entryGrouped) => {
76
- return {
77
- amount: entryGrouped.amount.toString(),
78
- from: entryGrouped.address_from,
79
- to: entryGrouped.address_to,
80
- hash: entryGrouped.asset
81
- };
82
- })
83
- });
84
- }
85
- else {
86
- haveTransaction.transfers = entriesGroupByTxid[entry.txid].map((entryGrouped) => {
87
- return {
88
- amount: entryGrouped.amount.toString(),
89
- from: entryGrouped.address_from,
90
- to: entryGrouped.address_to,
91
- hash: entryGrouped.asset
92
- };
93
- });
94
- transactionsGroupByTxid[transactionsGroupByTxid.indexOf(haveTransaction)] = haveTransaction;
95
- }
96
- });
97
- const result = {
98
- totalCount: data.total_entries,
99
- transactions: transactionsGroupByTxid
100
- };
101
- return result;
102
- }
103
- catch (error) {
104
- throw error;
105
- }
106
- });
107
- }
108
- getContract(contractHash) {
109
- return __awaiter(this, void 0, void 0, function* () {
110
- try {
111
- const response = yield dora_ts_1.api.NeoLegacyREST.contract(contractHash, this.network);
112
- const result = {
113
- hash: response.hash,
114
- name: response.name,
115
- methods: []
116
- };
117
- return result;
118
- }
119
- catch (error) {
120
- throw error;
121
- }
122
- });
123
- }
124
- getTokenInfo(tokenHash) {
125
- return __awaiter(this, void 0, void 0, function* () {
126
- try {
127
- const data = yield dora_ts_1.api.NeoLegacyREST.asset(tokenHash);
128
- const result = {
129
- decimals: data.decimals,
130
- symbol: data.symbol
131
- };
132
- return result;
133
- }
134
- catch (error) {
135
- throw error;
136
- }
137
- });
138
- }
139
- getBalance(address) {
140
- return __awaiter(this, void 0, void 0, function* () {
141
- try {
142
- const data = yield dora_ts_1.api.NeoLegacyREST.balance(address, this.network);
143
- const result = data.map(balance => {
144
- return {
145
- hash: balance.asset,
146
- amount: Number(balance.balance),
147
- name: balance.asset_name,
148
- symbol: balance.symbol
149
- };
150
- });
151
- return result;
152
- }
153
- catch (error) {
154
- throw error;
155
- }
156
- });
157
- }
158
- getAllNodes() {
159
- return __awaiter(this, void 0, void 0, function* () {
160
- try {
161
- const data = yield dora_ts_1.api.NeoLegacyREST.getAllNodes();
162
- const result = data;
163
- return result;
164
- }
165
- catch (error) {
166
- throw error;
167
- }
168
- });
169
- }
170
- getHigherNode() {
171
- return __awaiter(this, void 0, void 0, function* () {
172
- const nodes = yield this.getAllNodes();
173
- const node = nodes.reduce((bestNode, node) => {
174
- if (bestNode.height >= node.height) {
175
- return bestNode;
176
- }
177
- return node;
178
- });
179
- return node;
180
- });
181
- }
182
- //Implementation of BDSClaimable
183
- getUnclaimed(address) {
184
- return __awaiter(this, void 0, void 0, function* () {
185
- try {
186
- const data = yield dora_ts_1.api.NeoLegacyREST.getUnclaimed(address);
187
- const result = {
188
- address,
189
- unclaimed: data.unclaimed,
190
- };
191
- return result;
192
- }
193
- catch (error) {
194
- throw error;
195
- }
196
- });
197
- }
198
- }
199
- exports.BDSNeoLegacy = BDSNeoLegacy;