@cityofzion/bs-neo-legacy 0.4.1 → 0.7.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 (52) hide show
  1. package/.rush/temp/shrinkwrap-deps.json +2 -2
  2. package/bs-neo-legacy.build.error.log +2 -82
  3. package/bs-neo-legacy.build.log +3 -84
  4. package/dist/BSNeoLegacy.d.ts +23 -13
  5. package/dist/BSNeoLegacy.js +98 -69
  6. package/dist/constants.d.ts +5 -2
  7. package/docs/assets/search.js +1 -1
  8. package/docs/classes/BDSNeoLegacy.html +13 -13
  9. package/docs/classes/BSNeoLegacy.html +81 -37
  10. package/docs/interfaces/DoraNeoLegacyAsset.html +7 -7
  11. package/docs/interfaces/DoraNeoLegacyAssetResponse.html +9 -9
  12. package/docs/interfaces/DoraNeoLegacyBalance.html +5 -5
  13. package/docs/interfaces/DoraNeoLegacyConsensusNode.html +3 -3
  14. package/docs/interfaces/DoraNeoLegacyDetails.html +12 -12
  15. package/docs/interfaces/DoraNeoLegacyEntriesEntity.html +8 -8
  16. package/docs/interfaces/DoraNeoLegacyNameEntity.html +3 -3
  17. package/docs/interfaces/DoraNeoLegacyScriptsEntity.html +3 -3
  18. package/docs/interfaces/DoraNeoLegacyTransaction.html +14 -14
  19. package/docs/interfaces/DoraNeoLegacyTransactionsHistory.html +6 -6
  20. package/docs/interfaces/DoraNeoLegacyUnclaimed.html +4 -4
  21. package/docs/interfaces/DoraNeoLegacyVinEntity.html +3 -3
  22. package/docs/interfaces/DoraNeoLegacyVoutEntity.html +5 -5
  23. package/docs/variables/DORA_NEO_LEGACY_ASSET.html +1 -1
  24. package/docs/variables/DORA_NEO_LEGACY_BALANCE.html +1 -1
  25. package/docs/variables/DORA_NEO_LEGACY_CONTRACT.html +1 -1
  26. package/docs/variables/DORA_NEO_LEGACY_HISTORY_TRANSACTIONS.html +1 -1
  27. package/docs/variables/DORA_NEO_LEGACY_NODES.html +1 -1
  28. package/docs/variables/DORA_NEO_LEGACY_TRANSACTION.html +1 -1
  29. package/docs/variables/DORA_NEO_LEGACY_UNCLAIMED.html +1 -1
  30. package/docs/variables/explorerNeoLegacyOption.html +1 -1
  31. package/jest.config.ts +13 -0
  32. package/jest.setup.ts +1 -0
  33. package/package.json +10 -6
  34. package/src/BSNeoLegacy.ts +184 -152
  35. package/src/CryptoCompareEDSNeoLegacy.ts +40 -0
  36. package/src/DoraBDSNeoLegacy.ts +171 -0
  37. package/src/__tests__/BDSNeoLegacy.spec.ts +120 -0
  38. package/src/__tests__/BSNeoLegacy.spec.ts +127 -0
  39. package/src/__tests__/CryptoCompareExchange.spec.ts +46 -0
  40. package/src/assets/tokens/common.json +18 -0
  41. package/src/assets/tokens/mainnet.json +620 -0
  42. package/src/constants.ts +20 -17
  43. package/src/index.ts +3 -2
  44. package/tsconfig.build.json +4 -0
  45. package/tsconfig.json +3 -7
  46. package/src/BDSNeoLegacy.ts +0 -163
  47. package/src/asset/blockchain_icon_neo_legacy.png +0 -0
  48. package/src/asset/blockchain_icon_neo_legacy_white.png +0 -0
  49. package/src/asset/tokens.json +0 -481
  50. package/src/explorer/dora/DoraResponsesNeoLegacy.ts +0 -107
  51. package/src/explorer/dora/DoraRoutesNeoLegacy.ts +0 -7
  52. package/src/explorer/index.ts +0 -8
@@ -20,7 +20,7 @@
20
20
  <ul class="tsd-hierarchy">
21
21
  <li><span class="target">DoraNeoLegacyVinEntity</span></li></ul></section><aside class="tsd-sources">
22
22
  <ul>
23
- <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/3eb2742/packages/bs-neo-legacy/src/explorer/dora/DoraResponsesNeoLegacy.ts#L60">explorer/dora/DoraResponsesNeoLegacy.ts:60</a></li></ul></aside>
23
+ <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/38910fc/packages/bs-neo-legacy/src/explorer/dora/DoraResponsesNeoLegacy.ts#L60">explorer/dora/DoraResponsesNeoLegacy.ts:60</a></li></ul></aside>
24
24
  <section class="tsd-panel-group tsd-index-group">
25
25
  <section class="tsd-panel tsd-index-panel">
26
26
  <details class="tsd-index-content tsd-index-accordion" open><summary class="tsd-accordion-summary tsd-index-summary">
@@ -37,12 +37,12 @@
37
37
  <h3 class="tsd-anchor-link"><span>txid</span><a href="#txid" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none" id="icon-anchor-a"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5" id="icon-anchor-b"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5" id="icon-anchor-c"></path></svg></a></h3>
38
38
  <div class="tsd-signature">txid<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources">
39
39
  <ul>
40
- <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/3eb2742/packages/bs-neo-legacy/src/explorer/dora/DoraResponsesNeoLegacy.ts#L61">explorer/dora/DoraResponsesNeoLegacy.ts:61</a></li></ul></aside></section>
40
+ <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/38910fc/packages/bs-neo-legacy/src/explorer/dora/DoraResponsesNeoLegacy.ts#L61">explorer/dora/DoraResponsesNeoLegacy.ts:61</a></li></ul></aside></section>
41
41
  <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="vout" class="tsd-anchor"></a>
42
42
  <h3 class="tsd-anchor-link"><span>vout</span><a href="#vout" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
43
43
  <div class="tsd-signature">vout<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources">
44
44
  <ul>
45
- <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/3eb2742/packages/bs-neo-legacy/src/explorer/dora/DoraResponsesNeoLegacy.ts#L62">explorer/dora/DoraResponsesNeoLegacy.ts:62</a></li></ul></aside></section></section></div>
45
+ <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/38910fc/packages/bs-neo-legacy/src/explorer/dora/DoraResponsesNeoLegacy.ts#L62">explorer/dora/DoraResponsesNeoLegacy.ts:62</a></li></ul></aside></section></section></div>
46
46
  <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
47
47
  <div class="tsd-navigation settings">
48
48
  <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
@@ -20,7 +20,7 @@
20
20
  <ul class="tsd-hierarchy">
21
21
  <li><span class="target">DoraNeoLegacyVoutEntity</span></li></ul></section><aside class="tsd-sources">
22
22
  <ul>
23
- <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/3eb2742/packages/bs-neo-legacy/src/explorer/dora/DoraResponsesNeoLegacy.ts#L64">explorer/dora/DoraResponsesNeoLegacy.ts:64</a></li></ul></aside>
23
+ <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/38910fc/packages/bs-neo-legacy/src/explorer/dora/DoraResponsesNeoLegacy.ts#L64">explorer/dora/DoraResponsesNeoLegacy.ts:64</a></li></ul></aside>
24
24
  <section class="tsd-panel-group tsd-index-group">
25
25
  <section class="tsd-panel tsd-index-panel">
26
26
  <details class="tsd-index-content tsd-index-accordion" open><summary class="tsd-accordion-summary tsd-index-summary">
@@ -39,22 +39,22 @@
39
39
  <h3 class="tsd-anchor-link"><span>address</span><a href="#address" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none" id="icon-anchor-a"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5" id="icon-anchor-b"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5" id="icon-anchor-c"></path></svg></a></h3>
40
40
  <div class="tsd-signature">address<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources">
41
41
  <ul>
42
- <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/3eb2742/packages/bs-neo-legacy/src/explorer/dora/DoraResponsesNeoLegacy.ts#L68">explorer/dora/DoraResponsesNeoLegacy.ts:68</a></li></ul></aside></section>
42
+ <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/38910fc/packages/bs-neo-legacy/src/explorer/dora/DoraResponsesNeoLegacy.ts#L68">explorer/dora/DoraResponsesNeoLegacy.ts:68</a></li></ul></aside></section>
43
43
  <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="asset" class="tsd-anchor"></a>
44
44
  <h3 class="tsd-anchor-link"><span>asset</span><a href="#asset" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
45
45
  <div class="tsd-signature">asset<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources">
46
46
  <ul>
47
- <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/3eb2742/packages/bs-neo-legacy/src/explorer/dora/DoraResponsesNeoLegacy.ts#L66">explorer/dora/DoraResponsesNeoLegacy.ts:66</a></li></ul></aside></section>
47
+ <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/38910fc/packages/bs-neo-legacy/src/explorer/dora/DoraResponsesNeoLegacy.ts#L66">explorer/dora/DoraResponsesNeoLegacy.ts:66</a></li></ul></aside></section>
48
48
  <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="n" class="tsd-anchor"></a>
49
49
  <h3 class="tsd-anchor-link"><span>n</span><a href="#n" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
50
50
  <div class="tsd-signature">n<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources">
51
51
  <ul>
52
- <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/3eb2742/packages/bs-neo-legacy/src/explorer/dora/DoraResponsesNeoLegacy.ts#L65">explorer/dora/DoraResponsesNeoLegacy.ts:65</a></li></ul></aside></section>
52
+ <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/38910fc/packages/bs-neo-legacy/src/explorer/dora/DoraResponsesNeoLegacy.ts#L65">explorer/dora/DoraResponsesNeoLegacy.ts:65</a></li></ul></aside></section>
53
53
  <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="value" class="tsd-anchor"></a>
54
54
  <h3 class="tsd-anchor-link"><span>value</span><a href="#value" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
55
55
  <div class="tsd-signature">value<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><aside class="tsd-sources">
56
56
  <ul>
57
- <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/3eb2742/packages/bs-neo-legacy/src/explorer/dora/DoraResponsesNeoLegacy.ts#L67">explorer/dora/DoraResponsesNeoLegacy.ts:67</a></li></ul></aside></section></section></div>
57
+ <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/38910fc/packages/bs-neo-legacy/src/explorer/dora/DoraResponsesNeoLegacy.ts#L67">explorer/dora/DoraResponsesNeoLegacy.ts:67</a></li></ul></aside></section></section></div>
58
58
  <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
59
59
  <div class="tsd-navigation settings">
60
60
  <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
@@ -17,7 +17,7 @@
17
17
  <h1>Variable DORA_NEO_LEGACY_ASSET<code class="tsd-tag ts-flagConst">Const</code> </h1></div>
18
18
  <div class="tsd-signature">DORA_<wbr/>NEO_<wbr/>LEGACY_<wbr/>ASSET<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;asset&quot;</span><span class="tsd-signature-symbol"> = &#39;asset&#39;</span></div><aside class="tsd-sources">
19
19
  <ul>
20
- <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/3eb2742/packages/bs-neo-legacy/src/explorer/dora/DoraRoutesNeoLegacy.ts#L6">explorer/dora/DoraRoutesNeoLegacy.ts:6</a></li></ul></aside></div>
20
+ <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/38910fc/packages/bs-neo-legacy/src/explorer/dora/DoraRoutesNeoLegacy.ts#L6">explorer/dora/DoraRoutesNeoLegacy.ts:6</a></li></ul></aside></div>
21
21
  <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
22
22
  <div class="tsd-navigation settings">
23
23
  <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
@@ -17,7 +17,7 @@
17
17
  <h1>Variable DORA_NEO_LEGACY_BALANCE<code class="tsd-tag ts-flagConst">Const</code> </h1></div>
18
18
  <div class="tsd-signature">DORA_<wbr/>NEO_<wbr/>LEGACY_<wbr/>BALANCE<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;balance&quot;</span><span class="tsd-signature-symbol"> = &#39;balance&#39;</span></div><aside class="tsd-sources">
19
19
  <ul>
20
- <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/3eb2742/packages/bs-neo-legacy/src/explorer/dora/DoraRoutesNeoLegacy.ts#L3">explorer/dora/DoraRoutesNeoLegacy.ts:3</a></li></ul></aside></div>
20
+ <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/38910fc/packages/bs-neo-legacy/src/explorer/dora/DoraRoutesNeoLegacy.ts#L3">explorer/dora/DoraRoutesNeoLegacy.ts:3</a></li></ul></aside></div>
21
21
  <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
22
22
  <div class="tsd-navigation settings">
23
23
  <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
@@ -17,7 +17,7 @@
17
17
  <h1>Variable DORA_NEO_LEGACY_CONTRACT<code class="tsd-tag ts-flagConst">Const</code> </h1></div>
18
18
  <div class="tsd-signature">DORA_<wbr/>NEO_<wbr/>LEGACY_<wbr/>CONTRACT<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;contract&quot;</span><span class="tsd-signature-symbol"> = &#39;contract&#39;</span></div><aside class="tsd-sources">
19
19
  <ul>
20
- <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/3eb2742/packages/bs-neo-legacy/src/explorer/dora/DoraRoutesNeoLegacy.ts#L4">explorer/dora/DoraRoutesNeoLegacy.ts:4</a></li></ul></aside></div>
20
+ <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/38910fc/packages/bs-neo-legacy/src/explorer/dora/DoraRoutesNeoLegacy.ts#L4">explorer/dora/DoraRoutesNeoLegacy.ts:4</a></li></ul></aside></div>
21
21
  <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
22
22
  <div class="tsd-navigation settings">
23
23
  <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
@@ -17,7 +17,7 @@
17
17
  <h1>Variable DORA_NEO_LEGACY_HISTORY_TRANSACTIONS<code class="tsd-tag ts-flagConst">Const</code> </h1></div>
18
18
  <div class="tsd-signature">DORA_<wbr/>NEO_<wbr/>LEGACY_<wbr/>HISTORY_<wbr/>TRANSACTIONS<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;get_address_abstracts&quot;</span><span class="tsd-signature-symbol"> = &#39;get_address_abstracts&#39;</span></div><aside class="tsd-sources">
19
19
  <ul>
20
- <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/3eb2742/packages/bs-neo-legacy/src/explorer/dora/DoraRoutesNeoLegacy.ts#L2">explorer/dora/DoraRoutesNeoLegacy.ts:2</a></li></ul></aside></div>
20
+ <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/38910fc/packages/bs-neo-legacy/src/explorer/dora/DoraRoutesNeoLegacy.ts#L2">explorer/dora/DoraRoutesNeoLegacy.ts:2</a></li></ul></aside></div>
21
21
  <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
22
22
  <div class="tsd-navigation settings">
23
23
  <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
@@ -17,7 +17,7 @@
17
17
  <h1>Variable DORA_NEO_LEGACY_NODES<code class="tsd-tag ts-flagConst">Const</code> </h1></div>
18
18
  <div class="tsd-signature">DORA_<wbr/>NEO_<wbr/>LEGACY_<wbr/>NODES<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;get_all_nodes&quot;</span><span class="tsd-signature-symbol"> = &#39;get_all_nodes&#39;</span></div><aside class="tsd-sources">
19
19
  <ul>
20
- <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/3eb2742/packages/bs-neo-legacy/src/explorer/dora/DoraRoutesNeoLegacy.ts#L1">explorer/dora/DoraRoutesNeoLegacy.ts:1</a></li></ul></aside></div>
20
+ <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/38910fc/packages/bs-neo-legacy/src/explorer/dora/DoraRoutesNeoLegacy.ts#L1">explorer/dora/DoraRoutesNeoLegacy.ts:1</a></li></ul></aside></div>
21
21
  <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
22
22
  <div class="tsd-navigation settings">
23
23
  <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
@@ -17,7 +17,7 @@
17
17
  <h1>Variable DORA_NEO_LEGACY_TRANSACTION<code class="tsd-tag ts-flagConst">Const</code> </h1></div>
18
18
  <div class="tsd-signature">DORA_<wbr/>NEO_<wbr/>LEGACY_<wbr/>TRANSACTION<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;transaction&quot;</span><span class="tsd-signature-symbol"> = &#39;transaction&#39;</span></div><aside class="tsd-sources">
19
19
  <ul>
20
- <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/3eb2742/packages/bs-neo-legacy/src/explorer/dora/DoraRoutesNeoLegacy.ts#L5">explorer/dora/DoraRoutesNeoLegacy.ts:5</a></li></ul></aside></div>
20
+ <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/38910fc/packages/bs-neo-legacy/src/explorer/dora/DoraRoutesNeoLegacy.ts#L5">explorer/dora/DoraRoutesNeoLegacy.ts:5</a></li></ul></aside></div>
21
21
  <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
22
22
  <div class="tsd-navigation settings">
23
23
  <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
@@ -17,7 +17,7 @@
17
17
  <h1>Variable DORA_NEO_LEGACY_UNCLAIMED<code class="tsd-tag ts-flagConst">Const</code> </h1></div>
18
18
  <div class="tsd-signature">DORA_<wbr/>NEO_<wbr/>LEGACY_<wbr/>UNCLAIMED<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;get_unclaimed&quot;</span><span class="tsd-signature-symbol"> = &#39;get_unclaimed&#39;</span></div><aside class="tsd-sources">
19
19
  <ul>
20
- <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/3eb2742/packages/bs-neo-legacy/src/explorer/dora/DoraRoutesNeoLegacy.ts#L7">explorer/dora/DoraRoutesNeoLegacy.ts:7</a></li></ul></aside></div>
20
+ <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/38910fc/packages/bs-neo-legacy/src/explorer/dora/DoraRoutesNeoLegacy.ts#L7">explorer/dora/DoraRoutesNeoLegacy.ts:7</a></li></ul></aside></div>
21
21
  <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
22
22
  <div class="tsd-navigation settings">
23
23
  <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
@@ -22,7 +22,7 @@
22
22
  <li class="tsd-parameter">
23
23
  <h5>dora<span class="tsd-signature-symbol">: </span><a href="../classes/BDSNeoLegacy.html" class="tsd-signature-type" data-tsd-kind="Class">BDSNeoLegacy</a></h5></li></ul></div><aside class="tsd-sources">
24
24
  <ul>
25
- <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/3eb2742/packages/bs-neo-legacy/src/explorer/index.ts#L6">explorer/index.ts:6</a></li></ul></aside></div>
25
+ <li>Defined in <a href="https://github.com/CityOfZion/blockchain-services/blob/38910fc/packages/bs-neo-legacy/src/explorer/index.ts#L6">explorer/index.ts:6</a></li></ul></aside></div>
26
26
  <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
27
27
  <div class="tsd-navigation settings">
28
28
  <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
package/jest.config.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { JestConfigWithTsJest } from 'ts-jest'
2
+ const config: JestConfigWithTsJest = {
3
+ preset: 'ts-jest',
4
+ testEnvironment: 'node',
5
+ clearMocks: true,
6
+ verbose: true,
7
+ bail: true,
8
+ testMatch: ['<rootDir>/**/*.spec.ts'],
9
+ setupFiles: ['<rootDir>/jest.setup.ts'],
10
+ detectOpenHandles: true,
11
+ }
12
+
13
+ export default config
package/jest.setup.ts ADDED
@@ -0,0 +1 @@
1
+ import 'dotenv/config'
package/package.json CHANGED
@@ -1,22 +1,26 @@
1
1
  {
2
2
  "name": "@cityofzion/bs-neo-legacy",
3
- "version": "0.4.1",
3
+ "version": "0.7.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "Coz",
7
7
  "license": "MIT",
8
8
  "scripts": {
9
- "build": "tsc && typedoc"
9
+ "build": "tsc --project tsconfig.build.json",
10
+ "test": "jest --config jest.config.ts"
10
11
  },
11
12
  "dependencies": {
12
- "@cityofzion/blockchain-service": "0.4.1",
13
+ "@cityofzion/blockchain-service": "0.7.0",
14
+ "@cityofzion/bs-asteroid-sdk": "0.7.0",
13
15
  "@cityofzion/dora-ts": "0.0.11",
14
- "@cityofzion/neon-js": "^4.8.3",
15
- "axios": "1.3.2"
16
+ "@cityofzion/neon-js": "4.8.3"
16
17
  },
17
18
  "devDependencies": {
18
19
  "ts-node": "10.9.1",
19
20
  "typescript": "4.9.5",
20
- "typedoc": "0.23.24"
21
+ "jest": "29.6.2",
22
+ "ts-jest": "29.1.1",
23
+ "@types/jest": "29.5.3",
24
+ "dotenv": "16.3.1"
21
25
  }
22
26
  }
@@ -1,159 +1,191 @@
1
- import { Account, keychain, BDSClaimable, BlockchainDataService, BlockchainService, CalculateTransferFeeResponse, ClaimResponse, Claimable, Exchange, IntentTransactionParam, SendTransactionParam, Token, TokenInfo } from '@cityofzion/blockchain-service'
1
+ import {
2
+ Account,
3
+ BDSClaimable,
4
+ BlockchainDataService,
5
+ BlockchainService,
6
+ BSClaimable,
7
+ ExchangeDataService,
8
+ Token,
9
+ Network,
10
+ PartialBy,
11
+ TransferParam,
12
+ AccountWithDerivationPath,
13
+ } from '@cityofzion/blockchain-service'
2
14
  import { api, sc, u, wallet } from '@cityofzion/neon-js'
3
- import { explorerNeoLegacyOption } from './explorer'
4
- import { nativeAssetsNeoLegacy, unclaimedTokenNeoLegacy } from './constants'
5
- const [, neoToken] = nativeAssetsNeoLegacy
6
- import tokens from './asset/tokens.json'
7
-
8
- export class BSNeoLegacy<BSCustomName extends string = string> implements BlockchainService, Claimable {
9
- dataService: BlockchainDataService & BDSClaimable = explorerNeoLegacyOption.dora
10
- blockchainName: BSCustomName;
11
- feeToken: TokenInfo;
12
- exchange: Exchange;
13
- tokenClaim: TokenInfo = neoToken
14
- tokens: Token[] = tokens
15
-
16
- private nativeAssets: TokenInfo[] = nativeAssetsNeoLegacy
17
- private derivationPath: string = "m/44'/888'/0'/0/?"
18
-
19
- constructor(blockchainName: BSCustomName) {
20
- this.blockchainName = blockchainName
21
- }
22
- validateAddress(address: string): boolean {
23
- return wallet.isAddress(address)
24
- }
25
- validateEncryptedKey(encryptedKey: string): boolean {
26
- return wallet.isNEP2(encryptedKey)
27
- }
28
- validateWif(wif: string): boolean {
29
- return wallet.isWIF(wif)
30
- }
31
- generateMnemonic(): string[] {
32
- keychain.generateMnemonic(128)
33
- if (!keychain.mnemonic) throw new Error("Failed to generate mnemonic")
34
- return keychain.mnemonic.toString().split(' ')
35
- }
36
- generateAccount(mnemonic: string[], index: number): Account {
37
- keychain.importMnemonic(mnemonic.join(' '))
38
- const childKey = keychain.generateChildKey("neo", this.derivationPath.replace('?', index.toString()))
39
- const wif = childKey.getWIF()
40
- const { address } = new wallet.Account(wif)
41
- return { address, wif }
42
- }
43
- generateAccountFromWif(wif: string): Account {
44
- const { address } = new wallet.Account(wif)
45
- return { address, wif }
46
- }
47
- async decryptKey(encryptedKey: string, password: string): Promise<Account> {
48
- const wif = await wallet.decrypt(encryptedKey, password)
49
- const { address } = new wallet.Account(wif)
50
- const result: { wif: string; address: string; } = { address, wif }
51
- return result
52
- }
53
- calculateTransferFee(): Promise<CalculateTransferFeeResponse> {
54
- throw new Error(`Doesn't have fee to make a transaction on ${this.blockchainName}`);
55
- }
56
- async sendTransaction(param: SendTransactionParam): Promise<string> {
57
- const url = (await this.dataService.getHigherNode()).url
58
- const apiProvider = new api.neoscan.instance("MainNet")
59
- const account = new wallet.Account(param.senderAccount.wif)
60
- const intentsWithTye = this.setTypeIntents(param.transactionIntents)
61
- const isNativeTransaction = intentsWithTye.every(intent => intent.type === 'native')
62
- const priorityFee = param.priorityFee ?? 0
63
- const [gasAsset] = this.nativeAssets
64
- const gasBalance = (await this.dataService.getBalance(param.senderAccount.address)).find(balance => balance.hash === gasAsset.hash)
65
- if (gasBalance?.amount < priorityFee) throw new Error("Don't have funds to pay the transaction");
66
- const transactionOperations = {
67
- native: () => {
68
- return api.sendAsset({
69
- account,
70
- api: apiProvider,
71
- url,
72
- intents: this.buildNativeTransaction(param.transactionIntents),
73
- fees: priorityFee
74
- })
75
- },
76
- nep5: () => {
77
- const extraIntentsNep5 = intentsWithTye.filter(it => it.type === 'native').map(it => {
78
- const { type, ...rest } = it
79
- return rest
80
- })
81
- return api.doInvoke({
82
- intents: extraIntentsNep5.length > 0 ? this.buildNativeTransaction(extraIntentsNep5) : undefined,
83
- account,
84
- api: apiProvider,
85
- script: this.buildNep5Transaction(param.transactionIntents, param.senderAccount).str,
86
- url,
87
- fees: priorityFee
88
- })
89
- }
90
- }
91
- const result = isNativeTransaction ? await transactionOperations.native() : await transactionOperations.nep5()
92
- if (!result.tx) throw new Error("Failed to send transaction");
93
- return result.tx.hash
94
- }
95
- //Implementation Claim interface
96
- async claim(account: Account): Promise<ClaimResponse> {
97
- const neoAccount = new wallet.Account(account.wif)
98
- const balances = await this.dataService.getBalance(account.address)
99
- const neoBalance = balances.find(balance => balance.symbol === 'NEO')
100
- const apiProvider = new api.neoscan.instance("MainNet")
101
- const neoNativeAsset = this.nativeAssets.find(nativeAsset => nativeAsset.symbol === neoBalance?.symbol)
102
- if (!neoNativeAsset || !neoBalance) throw new Error("Neo it's necessary to do a claim");
103
- const hasClaim = await this.dataService.getUnclaimed(account.address)
104
- if (hasClaim.unclaimed <= 0) throw new Error(`Doesn't have gas to claim`);
105
- const url = (await this.dataService.getHigherNode()).url
106
- const claims = await api.neoCli.getClaims(url, account.address)
107
- const claimGasResponse = await api.claimGas({
108
- claims,
109
- api: apiProvider,
110
- account: neoAccount,
111
- url
112
- })
113
-
114
- const result: { txid: string; symbol: string; hash: string } = {
115
- txid: claimGasResponse.response.txid,
116
- hash: unclaimedTokenNeoLegacy.hash,
117
- symbol: unclaimedTokenNeoLegacy.symbol
118
- }
119
-
120
- return result
15
+ import {
16
+ DEFAULT_URL_BY_NETWORK_TYPE,
17
+ DERIVATION_PATH,
18
+ LEGACY_NETWORK_BY_NETWORK_TYPE,
19
+ NATIVE_ASSETS,
20
+ TOKENS,
21
+ } from './constants'
22
+ import { DoraBDSNeoLegacy } from './DoraBDSNeoLegacy'
23
+ import { CryptoCompareEDSNeoLegacy } from './CryptoCompareEDSNeoLegacy'
24
+ import { keychain } from '@cityofzion/bs-asteroid-sdk'
25
+
26
+ export class BSNeoLegacy<BSCustomName extends string = string> implements BlockchainService, BSClaimable {
27
+ readonly blockchainName: BSCustomName
28
+ readonly feeToken: Token
29
+ readonly claimToken: Token
30
+ readonly burnToken: Token
31
+ readonly derivationPath: string
32
+
33
+ blockchainDataService!: BlockchainDataService & BDSClaimable
34
+ exchangeDataService!: ExchangeDataService
35
+ tokens: Token[]
36
+ network!: Network
37
+ legacyNetwork: string
38
+
39
+ constructor(blockchainName: BSCustomName, network: PartialBy<Network, 'url'>) {
40
+ if (network.type === 'custom') throw new Error('Custom network is not supported for NEO Legacy')
41
+
42
+ this.blockchainName = blockchainName
43
+ this.legacyNetwork = LEGACY_NETWORK_BY_NETWORK_TYPE[network.type]
44
+ this.derivationPath = DERIVATION_PATH
45
+ this.tokens = TOKENS[network.type]
46
+ this.claimToken = this.tokens.find(token => token.symbol === 'GAS')!
47
+ this.burnToken = this.tokens.find(token => token.symbol === 'NEO')!
48
+ this.feeToken = this.tokens.find(token => token.symbol === 'GAS')!
49
+ this.setNetwork(network)
50
+ }
51
+
52
+ setNetwork(param: PartialBy<Network, 'url'>) {
53
+ if (param.type === 'custom') throw new Error('Custom network is not supported for NEO Legacy')
54
+
55
+ const network = {
56
+ type: param.type,
57
+ url: param.url ?? DEFAULT_URL_BY_NETWORK_TYPE[param.type],
121
58
  }
122
- private buildNativeTransaction(transactionIntents: IntentTransactionParam[]) {
123
- let intents: ReturnType<typeof api.makeIntent> = []
124
- transactionIntents.forEach(transaction => {
125
- const nativeAsset = this.nativeAssets.find(asset => asset.hash === transaction.tokenHash)
126
- if (nativeAsset) {
127
- intents = [...intents, ...api.makeIntent({ [nativeAsset.symbol]: transaction.amount }, transaction.receiverAddress)]
128
- }
129
- })
130
- return intents
59
+ this.network = network
60
+ this.blockchainDataService = new DoraBDSNeoLegacy(network, this.feeToken, this.claimToken)
61
+ this.exchangeDataService = new CryptoCompareEDSNeoLegacy(network.type)
62
+ }
63
+
64
+ validateAddress(address: string): boolean {
65
+ return wallet.isAddress(address)
66
+ }
67
+
68
+ validateEncrypted(key: string): boolean {
69
+ return wallet.isNEP2(key)
70
+ }
71
+
72
+ validateKey(key: string): boolean {
73
+ return wallet.isWIF(key) || wallet.isPrivateKey(key)
74
+ }
75
+
76
+ generateAccountFromMnemonic(mnemonic: string[] | string, index: number): AccountWithDerivationPath {
77
+ keychain.importMnemonic(Array.isArray(mnemonic) ? mnemonic.join(' ') : mnemonic)
78
+ const path = this.derivationPath.replace('?', index.toString())
79
+ const childKey = keychain.generateChildKey('neo', path)
80
+ const key = childKey.getWIF()
81
+ const { address } = new wallet.Account(key)
82
+ return { address, key, type: 'wif', derivationPath: path }
83
+ }
84
+
85
+ generateAccountFromKey(key: string): Account {
86
+ const type = wallet.isWIF(key) ? 'wif' : wallet.isPrivateKey(key) ? 'privateKey' : undefined
87
+ if (!type) throw new Error('Invalid key')
88
+
89
+ const { address } = new wallet.Account(key)
90
+ return { address, key, type }
91
+ }
92
+
93
+ async decrypt(encryptedKey: string, password: string): Promise<Account> {
94
+ let BsReactNativeDecrypt: any
95
+
96
+ try {
97
+ const { NativeModules } = require('react-native')
98
+ BsReactNativeDecrypt = NativeModules.BsReactNativeDecrypt
99
+ } catch {
100
+ const key = await wallet.decrypt(encryptedKey, password)
101
+ return this.generateAccountFromKey(key)
131
102
  }
132
- private buildNep5Transaction(transactionIntents: IntentTransactionParam[], senderAccount: Account) {
133
- const sb = new sc.ScriptBuilder()
134
- transactionIntents.forEach(transaction => {
135
- if (!this.isNativeTransaction(transaction)) {
136
- const senderHash = u.reverseHex(wallet.getScriptHashFromAddress(senderAccount.address))
137
- const receiveHash = u.reverseHex(wallet.getScriptHashFromAddress(transaction.receiverAddress))
138
- const adjustedAmount = new u.Fixed8(transaction.amount).toRawNumber()
139
- sb.emitAppCall(transaction.tokenHash.replace('0x', ''), "transfer", [
140
- senderHash,
141
- receiveHash,
142
- sc.ContractParam.integer(adjustedAmount.toString())
143
- ])
144
- }
145
- })
146
- return sb
103
+
104
+ if (!BsReactNativeDecrypt) {
105
+ throw new Error('@CityOfZion/bs-react-native-decrypt is not installed')
147
106
  }
148
- private setTypeIntents(transactionIntents: IntentTransactionParam[]) {
149
- type TransactionIntentResponse = IntentTransactionParam & { type: 'native' | 'nep5' }
150
107
 
151
- const intents: TransactionIntentResponse[] = transactionIntents.map<TransactionIntentResponse>(transaction => {
152
- return { ...transaction, type: this.isNativeTransaction(transaction) ? 'native' : 'nep5' }
153
- })
154
- return intents
108
+ const privateKey = await BsReactNativeDecrypt.decryptNeoLegacy(encryptedKey, password)
109
+ return this.generateAccountFromKey(privateKey)
110
+ }
111
+
112
+ async transfer({ intent: transferIntent, senderAccount, tipIntent, ...params }: TransferParam): Promise<string> {
113
+ const apiProvider = new api.neoCli.instance(this.network.url)
114
+ const account = new wallet.Account(senderAccount.key)
115
+ const priorityFee = Number(params.priorityFee ?? 0)
116
+
117
+ const nativeIntents: ReturnType<typeof api.makeIntent> = []
118
+ const nep5ScriptBuilder = new sc.ScriptBuilder()
119
+
120
+ const intents = [transferIntent, ...(tipIntent ? [tipIntent] : [])]
121
+
122
+ for (const intent of intents) {
123
+ const tokenHashFixed = intent.tokenHash.replace('0x', '')
124
+
125
+ const nativeAsset = NATIVE_ASSETS.find(asset => asset.hash === tokenHashFixed)
126
+ if (nativeAsset) {
127
+ nativeIntents.push(...api.makeIntent({ [nativeAsset.symbol]: Number(intent.amount) }, intent.receiverAddress))
128
+ continue
129
+ }
130
+
131
+ nep5ScriptBuilder.emitAppCall(tokenHashFixed, 'transfer', [
132
+ u.reverseHex(wallet.getScriptHashFromAddress(account.address)),
133
+ u.reverseHex(wallet.getScriptHashFromAddress(intent.receiverAddress)),
134
+ sc.ContractParam.integer(
135
+ new u.Fixed8(intent.amount)
136
+ .div(Math.pow(10, 8 - (intent.tokenDecimals ?? 8)))
137
+ .toRawNumber()
138
+ .toString()
139
+ ),
140
+ ])
155
141
  }
156
- private isNativeTransaction(transactionParam: IntentTransactionParam) {
157
- return this.nativeAssets.some(asset => asset.hash === transactionParam.tokenHash)
142
+
143
+ let response
144
+
145
+ if (nep5ScriptBuilder.isEmpty()) {
146
+ response = await api.sendAsset({
147
+ account,
148
+ api: apiProvider,
149
+ url: this.network.url,
150
+ intents: nativeIntents,
151
+ fees: priorityFee,
152
+ })
153
+ } else {
154
+ response = await api.doInvoke({
155
+ intents: nativeIntents.length > 0 ? nativeIntents : undefined,
156
+ account,
157
+ api: apiProvider,
158
+ script: nep5ScriptBuilder.str,
159
+ url: this.network.url,
160
+ fees: priorityFee,
161
+ })
158
162
  }
159
- }
163
+
164
+ if (!response.tx) throw new Error('Failed to send transaction')
165
+ return response.tx.hash
166
+ }
167
+
168
+ async claim(account: Account): Promise<string> {
169
+ const neoAccount = new wallet.Account(account.key)
170
+
171
+ const balances = await this.blockchainDataService.getBalance(account.address)
172
+ const neoBalance = balances.find(balance => balance.token.symbol === 'NEO')
173
+ if (!neoBalance) throw new Error('It is necessary to have NEO to claim')
174
+
175
+ const unclaimed = await this.blockchainDataService.getUnclaimed(account.address)
176
+ if (Number(unclaimed) <= 0) throw new Error(`Doesn't have gas to claim`)
177
+
178
+ const apiProvider = new api.neoCli.instance(this.legacyNetwork)
179
+ const claims = await apiProvider.getClaims(account.address)
180
+
181
+ const response = await api.claimGas({
182
+ claims,
183
+ api: apiProvider,
184
+ account: neoAccount,
185
+ url: this.network.url,
186
+ })
187
+
188
+ if (!response.tx) throw new Error('Failed to claim')
189
+ return response.tx.hash
190
+ }
191
+ }
@@ -0,0 +1,40 @@
1
+ import { Currency, ExchangeDataService, NetworkType, TokenPricesResponse } from '@cityofzion/blockchain-service'
2
+ import axios, { AxiosInstance } from 'axios'
3
+ import { TOKENS } from './constants'
4
+
5
+ type CryptoCompareDataResponse = {
6
+ RAW: {
7
+ [symbol: string]: {
8
+ [currency: string]: {
9
+ PRICE: number
10
+ }
11
+ }
12
+ }
13
+ }
14
+
15
+ export class CryptoCompareEDSNeoLegacy implements ExchangeDataService {
16
+ networkType: NetworkType
17
+ private axiosInstance: AxiosInstance
18
+
19
+ constructor(network: NetworkType) {
20
+ this.networkType = network
21
+ this.axiosInstance = axios.create({ baseURL: 'https://min-api.cryptocompare.com' })
22
+ }
23
+
24
+ async getTokenPrices(currency: Currency): Promise<TokenPricesResponse[]> {
25
+ if (this.networkType !== 'mainnet') throw new Error('Exchange is only available on mainnet')
26
+
27
+ const tokenSymbols = TOKENS[this.networkType].map(token => token.symbol)
28
+ const { data: prices } = await this.axiosInstance.get<CryptoCompareDataResponse>('/data/pricemultifull', {
29
+ params: {
30
+ fsyms: tokenSymbols.join(','),
31
+ tsyms: currency,
32
+ },
33
+ })
34
+
35
+ return Object.entries(prices.RAW).map(([symbol, price]) => ({
36
+ symbol,
37
+ price: price[currency].PRICE,
38
+ }))
39
+ }
40
+ }