@cityofzion/bs-neo-legacy 0.7.3 → 0.9.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 +8 -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 +25 -24
  9. package/dist/BSNeoLegacy.js +176 -173
  10. package/dist/CryptoCompareEDSNeoLegacy.d.ts +7 -7
  11. package/dist/CryptoCompareEDSNeoLegacy.js +51 -41
  12. package/dist/DoraBDSNeoLegacy.d.ts +16 -16
  13. package/dist/DoraBDSNeoLegacy.js +163 -163
  14. package/dist/DoraESNeoLegacy.d.ts +7 -7
  15. package/dist/DoraESNeoLegacy.js +17 -17
  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 +202 -198
  26. package/src/CryptoCompareEDSNeoLegacy.ts +50 -40
  27. package/src/DoraBDSNeoLegacy.ts +173 -173
  28. package/src/DoraESNeoLegacy.ts +18 -18
  29. package/src/__tests__/BDSNeoLegacy.spec.ts +120 -120
  30. package/src/__tests__/BSNeoLegacy.spec.ts +135 -127
  31. package/src/__tests__/CryptoCompareExchange.spec.ts +48 -46
  32. package/src/__tests__/DoraESNeoLegacy.spec.ts +15 -15
  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,120 +1,120 @@
1
- import { BDSClaimable, BlockchainDataService } from '@cityofzion/blockchain-service'
2
- import { DoraBDSNeoLegacy } from '../DoraBDSNeoLegacy'
3
- import { DEFAULT_URL_BY_NETWORK_TYPE, TOKENS } from '../constants'
4
-
5
- const gasToken = TOKENS.testnet.find(t => t.symbol === 'GAS')!
6
- let doraBDSNeoLegacy = new DoraBDSNeoLegacy(
7
- { type: 'testnet', url: DEFAULT_URL_BY_NETWORK_TYPE.testnet },
8
- gasToken,
9
- gasToken
10
- )
11
-
12
- describe('BDSNeoLegacy', () => {
13
- it.each([doraBDSNeoLegacy])('Should be able to get transaction - %s', async (bdsNeoLegacy: BlockchainDataService) => {
14
- const hash = '0x6632e79b1e5182355bcc1f3ca0e91d11a426c893734cd266e7bf3d3f74618add'
15
- const transaction = await bdsNeoLegacy.getTransaction(hash)
16
- expect(transaction).toEqual(
17
- expect.objectContaining({
18
- block: expect.any(Number),
19
- hash,
20
- notifications: [],
21
- transfers: expect.arrayContaining([
22
- expect.objectContaining({
23
- amount: expect.any(String),
24
- from: expect.any(String),
25
- to: expect.any(String),
26
- type: 'token',
27
- }),
28
- ]),
29
- time: expect.any(Number),
30
- fee: expect.any(String),
31
- })
32
- )
33
- })
34
-
35
- it.each([doraBDSNeoLegacy])(
36
- 'Should be able to get history transactions - %s',
37
- async (bdsNeoLegacy: BlockchainDataService) => {
38
- const address = 'AeGgZTTWPzyVtNiQRcpngkV75Xip1hznmi'
39
- try {
40
- const response = await bdsNeoLegacy.getTransactionsByAddress({ address, page: 1 })
41
- response.transactions.forEach(transaction => {
42
- expect(transaction).toEqual(
43
- expect.objectContaining({
44
- block: expect.any(Number),
45
- hash: expect.any(String),
46
- notifications: expect.arrayContaining([
47
- expect.objectContaining({
48
- eventName: expect.any(String),
49
- state: expect.arrayContaining([
50
- {
51
- type: expect.any(String),
52
- value: expect.any(String),
53
- },
54
- ]),
55
- }),
56
- ]),
57
- transfers: expect.arrayContaining([
58
- expect.objectContaining({
59
- amount: expect.any(Number),
60
- from: expect.any(String),
61
- to: expect.any(String),
62
- type: 'asset',
63
- }),
64
- ]),
65
- time: expect.any(Number),
66
- fee: expect.any(String),
67
- })
68
- )
69
- })
70
- } catch {}
71
- }
72
- )
73
-
74
- it.each([doraBDSNeoLegacy])('Should be able to get contract - %s', async (bdsNeoLegacy: BlockchainDataService) => {
75
- const hash = '0x998a0da7ec5f21c9a99ef5349f81af8af89f9644'
76
- const contract = await bdsNeoLegacy.getContract(hash)
77
- expect(contract).toEqual({
78
- hash: hash,
79
- name: 'Phantasma Stake',
80
- methods: [],
81
- })
82
- })
83
-
84
- it.each([doraBDSNeoLegacy])('Should be able to get token info - %s', async (bdsNeoLegacy: BlockchainDataService) => {
85
- const hash = '0x602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7'
86
- const token = await bdsNeoLegacy.getTokenInfo(hash)
87
- expect(token).toEqual({
88
- decimals: 8,
89
- hash: hash,
90
- name: 'GAS',
91
- symbol: 'GAS',
92
- })
93
- })
94
-
95
- it.each([doraBDSNeoLegacy])('Should be able to get balance - %s', async (bdsNeoLegacy: BlockchainDataService) => {
96
- const address = 'AeGgZTTWPzyVtNiQRcpngkV75Xip1hznmi'
97
- const balance = await bdsNeoLegacy.getBalance(address)
98
-
99
- balance.forEach(balance => {
100
- expect(balance).toEqual({
101
- amount: expect.any(String),
102
- token: {
103
- hash: expect.any(String),
104
- name: expect.any(String),
105
- symbol: expect.any(String),
106
- decimals: expect.any(Number),
107
- },
108
- })
109
- })
110
- })
111
-
112
- it.each([doraBDSNeoLegacy])(
113
- 'Should be able to get unclaimed - %s',
114
- async (doraBDSNeoLegacy: BlockchainDataService & BDSClaimable) => {
115
- const address = 'AeGgZTTWPzyVtNiQRcpngkV75Xip1hznmi'
116
- const unclaimed = await doraBDSNeoLegacy.getUnclaimed(address)
117
- expect(unclaimed).toEqual(expect.any(String))
118
- }
119
- )
120
- })
1
+ import { BDSClaimable, BlockchainDataService } from '@cityofzion/blockchain-service'
2
+ import { DoraBDSNeoLegacy } from '../DoraBDSNeoLegacy'
3
+ import { DEFAULT_URL_BY_NETWORK_TYPE, TOKENS } from '../constants'
4
+
5
+ const gasToken = TOKENS.testnet.find(t => t.symbol === 'GAS')!
6
+ let doraBDSNeoLegacy = new DoraBDSNeoLegacy(
7
+ { type: 'testnet', url: DEFAULT_URL_BY_NETWORK_TYPE.testnet },
8
+ gasToken,
9
+ gasToken
10
+ )
11
+
12
+ describe('BDSNeoLegacy', () => {
13
+ it.each([doraBDSNeoLegacy])('Should be able to get transaction - %s', async (bdsNeoLegacy: BlockchainDataService) => {
14
+ const hash = '0x6632e79b1e5182355bcc1f3ca0e91d11a426c893734cd266e7bf3d3f74618add'
15
+ const transaction = await bdsNeoLegacy.getTransaction(hash)
16
+ expect(transaction).toEqual(
17
+ expect.objectContaining({
18
+ block: expect.any(Number),
19
+ hash,
20
+ notifications: [],
21
+ transfers: expect.arrayContaining([
22
+ expect.objectContaining({
23
+ amount: expect.any(String),
24
+ from: expect.any(String),
25
+ to: expect.any(String),
26
+ type: 'token',
27
+ }),
28
+ ]),
29
+ time: expect.any(Number),
30
+ fee: expect.any(String),
31
+ })
32
+ )
33
+ })
34
+
35
+ it.each([doraBDSNeoLegacy])(
36
+ 'Should be able to get history transactions - %s',
37
+ async (bdsNeoLegacy: BlockchainDataService) => {
38
+ const address = 'AeGgZTTWPzyVtNiQRcpngkV75Xip1hznmi'
39
+ try {
40
+ const response = await bdsNeoLegacy.getTransactionsByAddress({ address, page: 1 })
41
+ response.transactions.forEach(transaction => {
42
+ expect(transaction).toEqual(
43
+ expect.objectContaining({
44
+ block: expect.any(Number),
45
+ hash: expect.any(String),
46
+ notifications: expect.arrayContaining([
47
+ expect.objectContaining({
48
+ eventName: expect.any(String),
49
+ state: expect.arrayContaining([
50
+ {
51
+ type: expect.any(String),
52
+ value: expect.any(String),
53
+ },
54
+ ]),
55
+ }),
56
+ ]),
57
+ transfers: expect.arrayContaining([
58
+ expect.objectContaining({
59
+ amount: expect.any(Number),
60
+ from: expect.any(String),
61
+ to: expect.any(String),
62
+ type: 'asset',
63
+ }),
64
+ ]),
65
+ time: expect.any(Number),
66
+ fee: expect.any(String),
67
+ })
68
+ )
69
+ })
70
+ } catch {}
71
+ }
72
+ )
73
+
74
+ it.each([doraBDSNeoLegacy])('Should be able to get contract - %s', async (bdsNeoLegacy: BlockchainDataService) => {
75
+ const hash = '0x998a0da7ec5f21c9a99ef5349f81af8af89f9644'
76
+ const contract = await bdsNeoLegacy.getContract(hash)
77
+ expect(contract).toEqual({
78
+ hash: hash,
79
+ name: 'Phantasma Stake',
80
+ methods: [],
81
+ })
82
+ })
83
+
84
+ it.each([doraBDSNeoLegacy])('Should be able to get token info - %s', async (bdsNeoLegacy: BlockchainDataService) => {
85
+ const hash = '0x602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7'
86
+ const token = await bdsNeoLegacy.getTokenInfo(hash)
87
+ expect(token).toEqual({
88
+ decimals: 8,
89
+ hash: hash,
90
+ name: 'GAS',
91
+ symbol: 'GAS',
92
+ })
93
+ })
94
+
95
+ it.each([doraBDSNeoLegacy])('Should be able to get balance - %s', async (bdsNeoLegacy: BlockchainDataService) => {
96
+ const address = 'AeGgZTTWPzyVtNiQRcpngkV75Xip1hznmi'
97
+ const balance = await bdsNeoLegacy.getBalance(address)
98
+
99
+ balance.forEach(balance => {
100
+ expect(balance).toEqual({
101
+ amount: expect.any(String),
102
+ token: {
103
+ hash: expect.any(String),
104
+ name: expect.any(String),
105
+ symbol: expect.any(String),
106
+ decimals: expect.any(Number),
107
+ },
108
+ })
109
+ })
110
+ })
111
+
112
+ it.each([doraBDSNeoLegacy])(
113
+ 'Should be able to get unclaimed - %s',
114
+ async (doraBDSNeoLegacy: BlockchainDataService & BDSClaimable) => {
115
+ const address = 'AeGgZTTWPzyVtNiQRcpngkV75Xip1hznmi'
116
+ const unclaimed = await doraBDSNeoLegacy.getUnclaimed(address)
117
+ expect(unclaimed).toEqual(expect.any(String))
118
+ }
119
+ )
120
+ })
@@ -1,127 +1,135 @@
1
- import { BSNeoLegacy } from '../BSNeoLegacy'
2
- import { wallet } from '@cityofzion/neon-js'
3
- import { generateMnemonic } from '@cityofzion/bs-asteroid-sdk'
4
-
5
- let bsNeoLegacy: BSNeoLegacy
6
-
7
- describe('BSNeoLegacy', () => {
8
- beforeEach(() => {
9
- bsNeoLegacy = new BSNeoLegacy('neoLegacy', { type: 'testnet', url: 'http://seed5.ngd.network:20332' })
10
- })
11
-
12
- it('Should be able to validate an address', () => {
13
- const validAddress = 'AJDZ8QP7ydjFicpcXCkG7wczeWEAKxpF69'
14
- const invalidAddress = 'invalid address'
15
-
16
- expect(bsNeoLegacy.validateAddress(validAddress)).toBeTruthy()
17
- expect(bsNeoLegacy.validateAddress(invalidAddress)).toBeFalsy()
18
- })
19
-
20
- it('Should be able to validate an encrypted key', () => {
21
- const validEncryptedKey = '6PYSsRjFn1v5uu79h5vXGZEYvvRkioHmd1Fd5bUyVp9Gt2wJcLKWHgD6Hy'
22
- const invalidEncryptedKey = 'invalid encrypted key'
23
-
24
- expect(bsNeoLegacy.validateEncrypted(validEncryptedKey)).toBeTruthy()
25
- expect(bsNeoLegacy.validateEncrypted(invalidEncryptedKey)).toBeFalsy()
26
- })
27
-
28
- it('Should be able to validate a wif', () => {
29
- const validWif = 'L4ZnhLegkFV9FTys1wBJDHUykn5hLnr15cPqvfuy4E1kzWTE6iRM'
30
- const invalidWif = 'invalid wif'
31
-
32
- expect(bsNeoLegacy.validateKey(validWif)).toBeTruthy()
33
- expect(bsNeoLegacy.validateKey(invalidWif)).toBeFalsy()
34
- })
35
-
36
- it('Should be able to gererate a account from mnemonic', () => {
37
- const mnemonic = generateMnemonic()
38
- const account = bsNeoLegacy.generateAccountFromMnemonic(mnemonic, 0)
39
-
40
- expect(bsNeoLegacy.validateAddress(account.address)).toBeTruthy()
41
- expect(bsNeoLegacy.validateKey(account.key)).toBeTruthy()
42
- })
43
-
44
- it('Should be able to generate a account from wif', () => {
45
- const mnemonic = generateMnemonic()
46
- const account = bsNeoLegacy.generateAccountFromMnemonic(mnemonic, 0)
47
-
48
- const accountFromWif = bsNeoLegacy.generateAccountFromKey(account.key)
49
- expect(account).toEqual(expect.objectContaining(accountFromWif))
50
- })
51
-
52
- it('Should be able to decrypt a encrypted key', async () => {
53
- const mnemonic = generateMnemonic()
54
- const account = bsNeoLegacy.generateAccountFromMnemonic(mnemonic, 0)
55
- const password = 'TestPassword'
56
- const encryptedKey = await wallet.encrypt(account.key, password)
57
- const decryptedAccount = await bsNeoLegacy.decrypt(encryptedKey, password)
58
- expect(account).toEqual(expect.objectContaining(decryptedAccount))
59
- }, 10000)
60
-
61
- it.skip('Should be able to transfer a native asset', async () => {
62
- const account = bsNeoLegacy.generateAccountFromKey(process.env.TESTNET_PRIVATE_KEY as string)
63
- const balance = await bsNeoLegacy.blockchainDataService.getBalance(account.address)
64
- const gasBalance = balance.find(b => b.token.symbol === 'GAS')!
65
- expect(Number(gasBalance?.amount)).toBeGreaterThan(0.00000001)
66
-
67
- const transactionHash = await bsNeoLegacy.transfer({
68
- senderAccount: account,
69
- intent: {
70
- amount: '0.00000001',
71
- receiverAddress: 'AQEQdmCcitFbE6oJU5Epa7dNxhTkCmTZST',
72
- tokenHash: gasBalance.token.hash,
73
- tokenDecimals: gasBalance.token.decimals,
74
- },
75
- })
76
-
77
- expect(transactionHash).toEqual(expect.any(String))
78
- })
79
-
80
- it.skip('Should be able to transfer a nep5 asset', async () => {
81
- bsNeoLegacy.setNetwork({ type: 'mainnet', url: 'http://seed9.ngd.network:10332' })
82
- const account = bsNeoLegacy.generateAccountFromKey(process.env.TESTNET_PRIVATE_KEY as string)
83
- const balance = await bsNeoLegacy.blockchainDataService.getBalance(account.address)
84
- const LXBalance = balance.find(item => item.token.symbol === 'LX')!
85
- expect(Number(LXBalance?.amount)).toBeGreaterThan(0.00000001)
86
-
87
- const transactionHash = await bsNeoLegacy.transfer({
88
- senderAccount: account,
89
- intent: {
90
- amount: '0.00000001',
91
- receiverAddress: 'AQEQdmCcitFbE6oJU5Epa7dNxhTkCmTZST',
92
- tokenHash: LXBalance.token.hash,
93
- tokenDecimals: LXBalance.token.decimals,
94
- },
95
- })
96
-
97
- expect(transactionHash).toEqual(expect.any(String))
98
- })
99
-
100
- it.skip('Should be able to transfer a asset with tip', async () => {
101
- bsNeoLegacy.setNetwork({ type: 'mainnet', url: 'http://seed9.ngd.network:10332' })
102
- const account = bsNeoLegacy.generateAccountFromKey(process.env.TESTNET_PRIVATE_KEY as string)
103
- const balance = await bsNeoLegacy.blockchainDataService.getBalance(account.address)
104
- const LXBalance = balance.find(item => item.token.symbol === 'LX')!
105
- expect(Number(LXBalance?.amount)).toBeGreaterThan(0.00000001)
106
- const gasBalance = balance.find(item => item.token.symbol === bsNeoLegacy.feeToken.symbol)!
107
- expect(Number(gasBalance?.amount)).toBeGreaterThan(0.00000001)
108
-
109
- const transactionHash = await bsNeoLegacy.transfer({
110
- senderAccount: account,
111
- intent: {
112
- amount: '0.00000001',
113
- receiverAddress: 'AQEQdmCcitFbE6oJU5Epa7dNxhTkCmTZST',
114
- tokenHash: LXBalance.token.hash,
115
- tokenDecimals: LXBalance.token.decimals,
116
- },
117
- tipIntent: {
118
- amount: '0.00000001',
119
- receiverAddress: 'AQEQdmCcitFbE6oJU5Epa7dNxhTkCmTZST',
120
- tokenHash: gasBalance.token.hash,
121
- tokenDecimals: gasBalance.token.decimals,
122
- },
123
- })
124
-
125
- expect(transactionHash).toEqual(expect.any(String))
126
- })
127
- })
1
+ import { BSNeoLegacy } from '../BSNeoLegacy'
2
+ import { wallet } from '@cityofzion/neon-js'
3
+ import { generateMnemonic } from '@cityofzion/bs-asteroid-sdk'
4
+
5
+ let bsNeoLegacy: BSNeoLegacy
6
+
7
+ describe('BSNeoLegacy', () => {
8
+ beforeEach(() => {
9
+ bsNeoLegacy = new BSNeoLegacy('neoLegacy', { type: 'testnet', url: 'http://seed5.ngd.network:20332' })
10
+ })
11
+
12
+ it('Should be able to validate an address', () => {
13
+ const validAddress = 'AJDZ8QP7ydjFicpcXCkG7wczeWEAKxpF69'
14
+ const invalidAddress = 'invalid address'
15
+
16
+ expect(bsNeoLegacy.validateAddress(validAddress)).toBeTruthy()
17
+ expect(bsNeoLegacy.validateAddress(invalidAddress)).toBeFalsy()
18
+ })
19
+
20
+ it('Should be able to validate an encrypted key', () => {
21
+ const validEncryptedKey = '6PYSsRjFn1v5uu79h5vXGZEYvvRkioHmd1Fd5bUyVp9Gt2wJcLKWHgD6Hy'
22
+ const invalidEncryptedKey = 'invalid encrypted key'
23
+
24
+ expect(bsNeoLegacy.validateEncrypted(validEncryptedKey)).toBeTruthy()
25
+ expect(bsNeoLegacy.validateEncrypted(invalidEncryptedKey)).toBeFalsy()
26
+ })
27
+
28
+ it('Should be able to validate a wif', () => {
29
+ const validWif = 'L4ZnhLegkFV9FTys1wBJDHUykn5hLnr15cPqvfuy4E1kzWTE6iRM'
30
+ const invalidWif = 'invalid wif'
31
+
32
+ expect(bsNeoLegacy.validateKey(validWif)).toBeTruthy()
33
+ expect(bsNeoLegacy.validateKey(invalidWif)).toBeFalsy()
34
+ })
35
+
36
+ it('Should be able to gererate a account from mnemonic', () => {
37
+ const mnemonic = generateMnemonic()
38
+ const account = bsNeoLegacy.generateAccountFromMnemonic(mnemonic, 0)
39
+
40
+ expect(bsNeoLegacy.validateAddress(account.address)).toBeTruthy()
41
+ expect(bsNeoLegacy.validateKey(account.key)).toBeTruthy()
42
+ })
43
+
44
+ it('Should be able to generate a account from wif', () => {
45
+ const mnemonic = generateMnemonic()
46
+ const account = bsNeoLegacy.generateAccountFromMnemonic(mnemonic, 0)
47
+
48
+ const accountFromWif = bsNeoLegacy.generateAccountFromKey(account.key)
49
+ expect(account).toEqual(expect.objectContaining(accountFromWif))
50
+ })
51
+
52
+ it('Should be able to decrypt a encrypted key', async () => {
53
+ const mnemonic = generateMnemonic()
54
+ const account = bsNeoLegacy.generateAccountFromMnemonic(mnemonic, 0)
55
+ const password = 'TestPassword'
56
+ const encryptedKey = await bsNeoLegacy.encrypt(account.key, password)
57
+ const decryptedAccount = await bsNeoLegacy.decrypt(encryptedKey, password)
58
+ expect(account).toEqual(expect.objectContaining(decryptedAccount))
59
+ }, 10000)
60
+
61
+ it('Should be able to encrypt a key', async () => {
62
+ const mnemonic = generateMnemonic()
63
+ const account = bsNeoLegacy.generateAccountFromMnemonic(mnemonic, 0)
64
+ const password = 'TestPassword'
65
+ const encryptedKey = await bsNeoLegacy.encrypt(account.key, password)
66
+ expect(encryptedKey).toEqual(expect.any(String))
67
+ })
68
+
69
+ it.skip('Should be able to transfer a native asset', async () => {
70
+ const account = bsNeoLegacy.generateAccountFromKey(process.env.TESTNET_PRIVATE_KEY as string)
71
+ const balance = await bsNeoLegacy.blockchainDataService.getBalance(account.address)
72
+ const gasBalance = balance.find(b => b.token.symbol === 'GAS')!
73
+ expect(Number(gasBalance?.amount)).toBeGreaterThan(0.00000001)
74
+
75
+ const transactionHash = await bsNeoLegacy.transfer({
76
+ senderAccount: account,
77
+ intent: {
78
+ amount: '0.00000001',
79
+ receiverAddress: 'AQEQdmCcitFbE6oJU5Epa7dNxhTkCmTZST',
80
+ tokenHash: gasBalance.token.hash,
81
+ tokenDecimals: gasBalance.token.decimals,
82
+ },
83
+ })
84
+
85
+ expect(transactionHash).toEqual(expect.any(String))
86
+ })
87
+
88
+ it.skip('Should be able to transfer a nep5 asset', async () => {
89
+ bsNeoLegacy.setNetwork({ type: 'mainnet', url: 'http://seed9.ngd.network:10332' })
90
+ const account = bsNeoLegacy.generateAccountFromKey(process.env.TESTNET_PRIVATE_KEY as string)
91
+ const balance = await bsNeoLegacy.blockchainDataService.getBalance(account.address)
92
+ const LXBalance = balance.find(item => item.token.symbol === 'LX')!
93
+ expect(Number(LXBalance?.amount)).toBeGreaterThan(0.00000001)
94
+
95
+ const transactionHash = await bsNeoLegacy.transfer({
96
+ senderAccount: account,
97
+ intent: {
98
+ amount: '0.00000001',
99
+ receiverAddress: 'AQEQdmCcitFbE6oJU5Epa7dNxhTkCmTZST',
100
+ tokenHash: LXBalance.token.hash,
101
+ tokenDecimals: LXBalance.token.decimals,
102
+ },
103
+ })
104
+
105
+ expect(transactionHash).toEqual(expect.any(String))
106
+ })
107
+
108
+ it.skip('Should be able to transfer a asset with tip', async () => {
109
+ bsNeoLegacy.setNetwork({ type: 'mainnet', url: 'http://seed9.ngd.network:10332' })
110
+ const account = bsNeoLegacy.generateAccountFromKey(process.env.TESTNET_PRIVATE_KEY as string)
111
+ const balance = await bsNeoLegacy.blockchainDataService.getBalance(account.address)
112
+ const LXBalance = balance.find(item => item.token.symbol === 'LX')!
113
+ expect(Number(LXBalance?.amount)).toBeGreaterThan(0.00000001)
114
+ const gasBalance = balance.find(item => item.token.symbol === bsNeoLegacy.feeToken.symbol)!
115
+ expect(Number(gasBalance?.amount)).toBeGreaterThan(0.00000001)
116
+
117
+ const transactionHash = await bsNeoLegacy.transfer({
118
+ senderAccount: account,
119
+ intent: {
120
+ amount: '0.00000001',
121
+ receiverAddress: 'AQEQdmCcitFbE6oJU5Epa7dNxhTkCmTZST',
122
+ tokenHash: LXBalance.token.hash,
123
+ tokenDecimals: LXBalance.token.decimals,
124
+ },
125
+ tipIntent: {
126
+ amount: '0.00000001',
127
+ receiverAddress: 'AQEQdmCcitFbE6oJU5Epa7dNxhTkCmTZST',
128
+ tokenHash: gasBalance.token.hash,
129
+ tokenDecimals: gasBalance.token.decimals,
130
+ },
131
+ })
132
+
133
+ expect(transactionHash).toEqual(expect.any(String))
134
+ })
135
+ })
@@ -1,46 +1,48 @@
1
- import { CryptoCompareEDSNeoLegacy } from '../CryptoCompareEDSNeoLegacy'
2
-
3
- let cryptoCompareEDSNeoLegacy: CryptoCompareEDSNeoLegacy
4
-
5
- describe('FlamingoEDSNeo3', () => {
6
- beforeAll(() => {
7
- cryptoCompareEDSNeoLegacy = new CryptoCompareEDSNeoLegacy('mainnet')
8
- })
9
-
10
- it('Should return a list with prices of tokens using USD', async () => {
11
- const tokenPriceList = await cryptoCompareEDSNeoLegacy.getTokenPrices('USD')
12
-
13
- tokenPriceList.forEach(tokenPrice => {
14
- expect(tokenPrice).toEqual({
15
- price: expect.any(Number),
16
- symbol: expect.any(String),
17
- })
18
- })
19
- })
20
-
21
- it('Should return a list with prices of tokens using BRL', async () => {
22
- const tokenPriceListInUSD = await cryptoCompareEDSNeoLegacy.getTokenPrices('USD')
23
- const tokenPriceList = await cryptoCompareEDSNeoLegacy.getTokenPrices('BRL')
24
-
25
- tokenPriceList.forEach((tokenPrice, index) => {
26
- expect(tokenPrice.price).toBeGreaterThan(tokenPriceListInUSD[index].price)
27
- expect(tokenPrice).toEqual({
28
- price: expect.any(Number),
29
- symbol: expect.any(String),
30
- })
31
- })
32
- })
33
-
34
- it('Should return a list with prices of tokens using EUR', async () => {
35
- const tokenPriceListInUSD = await cryptoCompareEDSNeoLegacy.getTokenPrices('USD')
36
- const tokenPriceList = await cryptoCompareEDSNeoLegacy.getTokenPrices('EUR')
37
-
38
- tokenPriceList.forEach((tokenPrice, index) => {
39
- expect(tokenPrice.price).toBeLessThan(tokenPriceListInUSD[index].price)
40
- expect(tokenPrice).toEqual({
41
- price: expect.any(Number),
42
- symbol: expect.any(String),
43
- })
44
- })
45
- })
46
- })
1
+ import { CryptoCompareEDSNeoLegacy } from '../CryptoCompareEDSNeoLegacy'
2
+
3
+ let cryptoCompareEDSNeoLegacy: CryptoCompareEDSNeoLegacy
4
+
5
+ describe('FlamingoEDSNeo3', () => {
6
+ beforeAll(() => {
7
+ cryptoCompareEDSNeoLegacy = new CryptoCompareEDSNeoLegacy('mainnet')
8
+ })
9
+
10
+ it('Should return a list with prices of tokens using USD', async () => {
11
+ const tokenPriceList = await cryptoCompareEDSNeoLegacy.getTokenPrices('USD')
12
+ tokenPriceList.forEach(tokenPrice => {
13
+ expect(tokenPrice).toEqual({
14
+ price: expect.any(Number),
15
+ symbol: expect.any(String),
16
+ hash: expect.any(String),
17
+ })
18
+ })
19
+ })
20
+
21
+ it('Should return a list with prices of tokens using BRL', async () => {
22
+ const tokenPriceListInUSD = await cryptoCompareEDSNeoLegacy.getTokenPrices('USD')
23
+ const tokenPriceList = await cryptoCompareEDSNeoLegacy.getTokenPrices('BRL')
24
+
25
+ tokenPriceList.forEach((tokenPrice, index) => {
26
+ expect(tokenPrice.price).toBeGreaterThan(tokenPriceListInUSD[index].price)
27
+ expect(tokenPrice).toEqual({
28
+ price: expect.any(Number),
29
+ symbol: expect.any(String),
30
+ hash: expect.any(String),
31
+ })
32
+ })
33
+ })
34
+
35
+ it('Should return a list with prices of tokens using EUR', async () => {
36
+ const tokenPriceListInUSD = await cryptoCompareEDSNeoLegacy.getTokenPrices('USD')
37
+ const tokenPriceList = await cryptoCompareEDSNeoLegacy.getTokenPrices('EUR')
38
+
39
+ tokenPriceList.forEach((tokenPrice, index) => {
40
+ expect(tokenPrice.price).toBeLessThan(tokenPriceListInUSD[index].price)
41
+ expect(tokenPrice).toEqual({
42
+ price: expect.any(Number),
43
+ symbol: expect.any(String),
44
+ hash: expect.any(String),
45
+ })
46
+ })
47
+ })
48
+ })
@@ -1,15 +1,15 @@
1
- import { DoraESNeoLegacy } from '../DoraESNeoLegacy'
2
-
3
- let doraESNeoLegacy: DoraESNeoLegacy
4
-
5
- describe('doraESNeoLegacy', () => {
6
- beforeAll(() => {
7
- doraESNeoLegacy = new DoraESNeoLegacy('mainnet')
8
- })
9
- it('Should return a transaction url', async () => {
10
- const hash = '0x0cd2d834d910dcb74c19bbbb1c986a94e292e1160f0d9f138b97ac950a5ac700'
11
- const url = doraESNeoLegacy.buildTransactionUrl(hash)
12
-
13
- expect(url).toEqual(`https://dora.coz.io/transaction/neo2/mainnet/${hash}`)
14
- })
15
- })
1
+ import { DoraESNeoLegacy } from '../DoraESNeoLegacy'
2
+
3
+ let doraESNeoLegacy: DoraESNeoLegacy
4
+
5
+ describe('doraESNeoLegacy', () => {
6
+ beforeAll(() => {
7
+ doraESNeoLegacy = new DoraESNeoLegacy('mainnet')
8
+ })
9
+ it('Should return a transaction url', async () => {
10
+ const hash = '0x0cd2d834d910dcb74c19bbbb1c986a94e292e1160f0d9f138b97ac950a5ac700'
11
+ const url = doraESNeoLegacy.buildTransactionUrl(hash)
12
+
13
+ expect(url).toEqual(`https://dora.coz.io/transaction/neo2/mainnet/${hash}`)
14
+ })
15
+ })