@cityofzion/bs-neo-legacy 0.4.2 → 0.7.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.
Files changed (62) hide show
  1. package/.rush/temp/package-deps_build.json +21 -0
  2. package/.rush/temp/shrinkwrap-deps.json +2 -2
  3. package/bs-neo-legacy.build.log +1 -86
  4. package/dist/BSNeoLegacy.d.ts +20 -23
  5. package/dist/BSNeoLegacy.js +118 -135
  6. package/dist/CryptoCompareEDSNeoLegacy.d.ts +7 -0
  7. package/dist/CryptoCompareEDSNeoLegacy.js +41 -0
  8. package/dist/DoraBDSNeoLegacy.d.ts +15 -0
  9. package/dist/DoraBDSNeoLegacy.js +162 -0
  10. package/dist/assets/tokens/common.json +18 -0
  11. package/dist/assets/tokens/mainnet.json +620 -0
  12. package/dist/constants.d.ts +10 -4
  13. package/dist/constants.js +20 -17
  14. package/dist/index.d.ts +3 -2
  15. package/dist/index.js +3 -2
  16. package/docs/assets/search.js +1 -1
  17. package/docs/classes/BDSNeoLegacy.html +13 -13
  18. package/docs/classes/BSNeoLegacy.html +81 -37
  19. package/docs/interfaces/DoraNeoLegacyAsset.html +7 -7
  20. package/docs/interfaces/DoraNeoLegacyAssetResponse.html +9 -9
  21. package/docs/interfaces/DoraNeoLegacyBalance.html +5 -5
  22. package/docs/interfaces/DoraNeoLegacyConsensusNode.html +3 -3
  23. package/docs/interfaces/DoraNeoLegacyDetails.html +12 -12
  24. package/docs/interfaces/DoraNeoLegacyEntriesEntity.html +8 -8
  25. package/docs/interfaces/DoraNeoLegacyNameEntity.html +3 -3
  26. package/docs/interfaces/DoraNeoLegacyScriptsEntity.html +3 -3
  27. package/docs/interfaces/DoraNeoLegacyTransaction.html +14 -14
  28. package/docs/interfaces/DoraNeoLegacyTransactionsHistory.html +6 -6
  29. package/docs/interfaces/DoraNeoLegacyUnclaimed.html +4 -4
  30. package/docs/interfaces/DoraNeoLegacyVinEntity.html +3 -3
  31. package/docs/interfaces/DoraNeoLegacyVoutEntity.html +5 -5
  32. package/docs/variables/DORA_NEO_LEGACY_ASSET.html +1 -1
  33. package/docs/variables/DORA_NEO_LEGACY_BALANCE.html +1 -1
  34. package/docs/variables/DORA_NEO_LEGACY_CONTRACT.html +1 -1
  35. package/docs/variables/DORA_NEO_LEGACY_HISTORY_TRANSACTIONS.html +1 -1
  36. package/docs/variables/DORA_NEO_LEGACY_NODES.html +1 -1
  37. package/docs/variables/DORA_NEO_LEGACY_TRANSACTION.html +1 -1
  38. package/docs/variables/DORA_NEO_LEGACY_UNCLAIMED.html +1 -1
  39. package/docs/variables/explorerNeoLegacyOption.html +1 -1
  40. package/jest.config.ts +13 -0
  41. package/jest.setup.ts +1 -0
  42. package/package.json +10 -6
  43. package/src/BSNeoLegacy.ts +184 -152
  44. package/src/CryptoCompareEDSNeoLegacy.ts +40 -0
  45. package/src/DoraBDSNeoLegacy.ts +171 -0
  46. package/src/__tests__/BDSNeoLegacy.spec.ts +120 -0
  47. package/src/__tests__/BSNeoLegacy.spec.ts +127 -0
  48. package/src/__tests__/CryptoCompareExchange.spec.ts +46 -0
  49. package/src/assets/tokens/common.json +18 -0
  50. package/src/assets/tokens/mainnet.json +620 -0
  51. package/src/constants.ts +20 -17
  52. package/src/index.ts +3 -2
  53. package/tsconfig.build.json +4 -0
  54. package/tsconfig.json +3 -7
  55. package/bs-neo-legacy.build.error.log +0 -84
  56. package/src/BDSNeoLegacy.ts +0 -163
  57. package/src/asset/blockchain_icon_neo_legacy.png +0 -0
  58. package/src/asset/blockchain_icon_neo_legacy_white.png +0 -0
  59. package/src/asset/tokens.json +0 -481
  60. package/src/explorer/dora/DoraResponsesNeoLegacy.ts +0 -107
  61. package/src/explorer/dora/DoraRoutesNeoLegacy.ts +0 -7
  62. package/src/explorer/index.ts +0 -8
@@ -1,84 +0,0 @@
1
- C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:140:0 - warning BlockchainDataService is referenced by BDSNeoLegacy but not included in the documentation.
2
-
3
- 140 export interface BlockchainDataService {
4
-
5
- C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:137:0 - warning BDSClaimable is referenced by BDSNeoLegacy but not included in the documentation.
6
-
7
- 137 export interface BDSClaimable {
8
-
9
- C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:60:0 - warning BlockchainService is referenced by BSNeoLegacy but not included in the documentation.
10
-
11
- 60 export interface BlockchainService<BSCustomName extends string = string> {
12
-
13
- C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:30:0 - warning Claimable is referenced by BSNeoLegacy but not included in the documentation.
14
-
15
- 30 export interface Claimable {
16
-
17
- C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:126:0 - warning BlockchainNetwork is referenced by BDSNeoLegacy.network but not included in the documentation.
18
-
19
- 126 export type BlockchainNetwork = "mainnet" | "testnet" | "privatenet";
20
-
21
- C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:156:0 - warning Exchange is referenced by BSNeoLegacy.exchange but not included in the documentation.
22
-
23
- 156 export interface Exchange {
24
-
25
- C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:11:0 - warning TokenInfo is referenced by BSNeoLegacy.feeToken but not included in the documentation.
26
-
27
- 11 export type TokenInfo = {
28
-
29
- C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:46:0 - warning Token is referenced by BSNeoLegacy.tokens but not included in the documentation.
30
-
31
- 46 export type Token = {
32
-
33
- C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:118:0 - warning ConsensusNodeResponse is referenced by BDSNeoLegacy.getAllNodes.getAllNodes but not included in the documentation.
34
-
35
- 118 export type ConsensusNodeResponse = {
36
-
37
- C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:127:0 - warning BalanceResponse is referenced by BDSNeoLegacy.getBalance.getBalance but not included in the documentation.
38
-
39
- 127 export type BalanceResponse = {
40
-
41
- C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:113:0 - warning ContractResponse is referenced by BDSNeoLegacy.getContract.getContract but not included in the documentation.
42
-
43
- 113 export type ContractResponse = {
44
-
45
- C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:105:0 - warning TransactionHistoryResponse is referenced by BDSNeoLegacy.getHistoryTransactions.getHistoryTransactions but not included in the documentation.
46
-
47
- 105 export type TransactionHistoryResponse = {
48
-
49
- C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:122:0 - warning TokenInfoResponse is referenced by BDSNeoLegacy.getTokenInfo.getTokenInfo but not included in the documentation.
50
-
51
- 122 export type TokenInfoResponse = {
52
-
53
- C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:84:0 - warning TransactionResponse is referenced by BDSNeoLegacy.getTransaction.getTransaction but not included in the documentation.
54
-
55
- 84 export type TransactionResponse = {
56
-
57
- C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:133:0 - warning UnclaimedResponse is referenced by BDSNeoLegacy.getUnclaimed.getUnclaimed but not included in the documentation.
58
-
59
- 133 export type UnclaimedResponse = {
60
-
61
- C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:56:0 - warning CalculateTransferFeeResponse is referenced by BSNeoLegacy.calculateTransferFee.calculateTransferFee but not included in the documentation.
62
-
63
- 56 export type CalculateTransferFeeResponse = {
64
-
65
- C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:25:0 - warning ClaimResponse is referenced by BSNeoLegacy.claim.claim but not included in the documentation.
66
-
67
- 25 export type ClaimResponse = {
68
-
69
- C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:52:0 - warning Account is referenced by BSNeoLegacy.decryptKey.decryptKey but not included in the documentation.
70
-
71
- 52 export type Account = {
72
-
73
- ./src/BSNeoLegacy.ts:149:8 - warning TransactionIntentResponse is referenced by BSNeoLegacy.setTypeIntents.setTypeIntents but not included in the documentation.
74
-
75
- 149 type TransactionIntentResponse = IntentTransactionParam & { type: 'native' | 'nep5' }
76
-
77
- C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:6:0 - warning IntentTransactionParam is referenced by BSNeoLegacy.buildNativeTransaction.buildNativeTransaction.transactionIntents but not included in the documentation.
78
-
79
- 6 export type IntentTransactionParam = {
80
-
81
- C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:1:0 - warning SendTransactionParam is referenced by BSNeoLegacy.sendTransaction.sendTransaction.param but not included in the documentation.
82
-
83
- 1 export type SendTransactionParam = {
84
-
@@ -1,163 +0,0 @@
1
- import { BalanceResponse, BlockchainNetwork, BlockchainDataService, ConsensusNodeResponse, ContractResponse, TokenInfoResponse, TransactionHistoryResponse, TransactionResponse, TransactionTransfer, BDSClaimable, UnclaimedResponse } from '@cityofzion/blockchain-service'
2
- import axios from 'axios'
3
- import { DoraNeoLegacyEntriesEntity, DoraNeoLegacyTransaction } from './explorer/dora/DoraResponsesNeoLegacy';
4
- import { DORA_NEO_LEGACY_TRANSACTION } from './explorer/dora/DoraRoutesNeoLegacy';
5
- import { api } from '@cityofzion/dora-ts'
6
- export class BDSNeoLegacy implements BlockchainDataService, BDSClaimable {
7
- explorer: string = 'https://dora.coz.io/'
8
- network: BlockchainNetwork = 'mainnet'
9
- private request = axios.create({ baseURL: `https://dora.coz.io/api/v1/neo2/${this.network}` })
10
-
11
- setNetwork(network: BlockchainNetwork): void {
12
- this.network = network
13
- }
14
- async getTransaction(txid: string): Promise<TransactionResponse> {
15
- try {
16
- const { data } = await this.request.get<DoraNeoLegacyTransaction>(`/${DORA_NEO_LEGACY_TRANSACTION}/${txid}`)
17
- const result: TransactionResponse = {
18
- block: data.block,
19
- netfee: data.net_fee,
20
- sysfee: data.sys_fee,
21
- time: data.time,
22
- txid: data.txid,
23
- totfee: (Number(data.sys_fee) + Number(data.net_fee)).toString(),
24
- notifications: [], //neolegacy doesn't have notifications
25
- transfers: data.vout.map<Omit<TransactionTransfer, "txid">>((transfer) => {
26
- return {
27
- amount: transfer.value,
28
- from: data.vout[data.vout.length - 1]?.address,
29
- hash: transfer.asset,
30
- to: transfer.address
31
- }
32
- })
33
- }
34
- return result
35
- } catch (error) {
36
- throw error;
37
- }
38
- }
39
-
40
- async getHistoryTransactions(address: string, page: number = 1): Promise<TransactionHistoryResponse> {
41
- try {
42
- const data = await api.NeoLegacyREST.getAddressAbstracts(address, page, this.network)
43
- const entriesGroupByTxid: { [txid: string]: DoraNeoLegacyEntriesEntity[] } = {}
44
- const transactionsGroupByTxid: TransactionResponse[] = []
45
-
46
- data.entries.forEach((entry) => {
47
- entriesGroupByTxid[entry.txid] = data.entries.filter(it => it.txid === entry.txid)
48
- const haveTransaction = transactionsGroupByTxid.find(it => it.txid === entry.txid)
49
- if (!haveTransaction) {
50
- transactionsGroupByTxid.push({
51
- block: entry.block_height,
52
- netfee: '0',
53
- sysfee: '0',
54
- totfee: '0',
55
- txid: entry.txid,
56
- notifications: [],
57
- time: entry.time.toString(),
58
- transfers: entriesGroupByTxid[entry.txid].map<Omit<TransactionTransfer, "txid">>((entryGrouped) => {
59
- return {
60
- amount: entryGrouped.amount.toString(),
61
- from: entryGrouped.address_from,
62
- to: entryGrouped.address_to,
63
- hash: entryGrouped.asset
64
- }
65
- })
66
- })
67
- } else {
68
- haveTransaction.transfers = entriesGroupByTxid[entry.txid].map<Omit<TransactionTransfer, "txid">>((entryGrouped) => {
69
- return {
70
- amount: entryGrouped.amount.toString(),
71
- from: entryGrouped.address_from,
72
- to: entryGrouped.address_to,
73
- hash: entryGrouped.asset
74
- }
75
- })
76
- transactionsGroupByTxid[transactionsGroupByTxid.indexOf(haveTransaction)] = haveTransaction
77
- }
78
- })
79
-
80
- const result: TransactionHistoryResponse = {
81
- totalCount: data.total_entries,
82
- transactions: transactionsGroupByTxid
83
- }
84
- return result
85
- } catch (error) {
86
- throw error;
87
- }
88
- }
89
- async getContract(contractHash: string): Promise<ContractResponse> {
90
- try {
91
- const response = await api.NeoLegacyREST.contract(contractHash, this.network)
92
- const result: ContractResponse = {
93
- hash: response.hash,
94
- name: response.name,
95
- methods: []
96
- }
97
- return result
98
- } catch (error) {
99
- throw error;
100
- }
101
- }
102
-
103
- async getTokenInfo(tokenHash: string): Promise<TokenInfoResponse> {
104
- try {
105
- const data = await api.NeoLegacyREST.asset(tokenHash)
106
- const result: TokenInfoResponse = {
107
- decimals: data.decimals,
108
- symbol: data.symbol
109
- }
110
- return result
111
- } catch (error) {
112
- throw error;
113
- }
114
- }
115
- async getBalance(address: string): Promise<BalanceResponse[]> {
116
- try {
117
- const data = await api.NeoLegacyREST.balance(address, this.network)
118
- const result: BalanceResponse[] = data.map<BalanceResponse>(balance => {
119
- return {
120
- hash: balance.asset,
121
- amount: Number(balance.balance),
122
- name: balance.asset_name,
123
- symbol: balance.symbol
124
- }
125
- })
126
- return result
127
- } catch (error) {
128
- throw error;
129
- }
130
- }
131
- async getAllNodes(): Promise<ConsensusNodeResponse[]> {
132
- try {
133
- const data = await api.NeoLegacyREST.getAllNodes()
134
- const result: ConsensusNodeResponse[] = data
135
- return result
136
- } catch (error) {
137
- throw error;
138
- }
139
- }
140
- async getHigherNode(): Promise<ConsensusNodeResponse> {
141
- const nodes = await this.getAllNodes()
142
- const node = nodes.reduce((bestNode, node) => {
143
- if (bestNode.height >= node.height) {
144
- return bestNode
145
- }
146
- return node
147
- })
148
- return node
149
- }
150
- //Implementation of BDSClaimable
151
- async getUnclaimed(address: string): Promise<UnclaimedResponse> {
152
- try {
153
- const data = await api.NeoLegacyREST.getUnclaimed(address)
154
- const result: UnclaimedResponse = {
155
- address,
156
- unclaimed: data.unclaimed,
157
- }
158
- return result;
159
- } catch (error) {
160
- throw error;
161
- }
162
- }
163
- }