@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.
- package/.rush/temp/operation/build/all.log +1 -0
- package/.rush/temp/operation/build/state.json +3 -0
- package/.rush/temp/package-deps_build.json +10 -6
- package/.rush/temp/shrinkwrap-deps.json +350 -101
- package/CHANGELOG.json +22 -0
- package/CHANGELOG.md +11 -0
- package/bs-neo-legacy.build.log +1 -2
- package/dist/BSNeoLegacy.d.ts +24 -23
- package/dist/BSNeoLegacy.js +173 -171
- package/dist/CryptoCompareEDSNeoLegacy.d.ts +7 -7
- package/dist/CryptoCompareEDSNeoLegacy.js +51 -41
- package/dist/DoraBDSNeoLegacy.d.ts +16 -15
- package/dist/DoraBDSNeoLegacy.js +163 -162
- package/dist/DoraESNeoLegacy.d.ts +7 -0
- package/dist/DoraESNeoLegacy.js +17 -0
- package/dist/assets/tokens/common.json +18 -18
- package/dist/assets/tokens/mainnet.json +620 -620
- package/dist/constants.d.ts +13 -13
- package/dist/constants.js +23 -23
- package/dist/index.d.ts +4 -4
- package/dist/index.js +20 -20
- package/jest.config.ts +13 -13
- package/jest.setup.ts +1 -1
- package/package.json +26 -25
- package/src/BSNeoLegacy.ts +198 -191
- package/src/CryptoCompareEDSNeoLegacy.ts +50 -40
- package/src/DoraBDSNeoLegacy.ts +173 -171
- package/src/DoraESNeoLegacy.ts +18 -0
- package/src/__tests__/BDSNeoLegacy.spec.ts +120 -120
- package/src/__tests__/BSNeoLegacy.spec.ts +127 -127
- package/src/__tests__/CryptoCompareExchange.spec.ts +48 -46
- package/src/__tests__/DoraESNeoLegacy.spec.ts +15 -0
- package/src/assets/tokens/common.json +17 -17
- package/src/assets/tokens/mainnet.json +619 -619
- package/src/constants.ts +23 -23
- package/src/index.ts +4 -4
- package/tsconfig.build.json +4 -4
- package/tsconfig.json +14 -14
- package/dist/BDSNeoLegacy.d.ts +0 -15
- package/dist/BDSNeoLegacy.js +0 -199
- package/dist/asset/tokens.json +0 -480
- package/dist/explorer/dora/DoraResponsesNeoLegacy.d.ts +0 -95
- package/dist/explorer/dora/DoraResponsesNeoLegacy.js +0 -2
- package/dist/explorer/dora/DoraRoutesNeoLegacy.d.ts +0 -7
- package/dist/explorer/dora/DoraRoutesNeoLegacy.js +0 -10
- package/dist/explorer/index.d.ts +0 -6
- package/dist/explorer/index.js +0 -23
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -22
- package/docs/assets/main.js +0 -58
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1280
- package/docs/classes/BDSNeoLegacy.html +0 -243
- package/docs/classes/BSNeoLegacy.html +0 -423
- package/docs/index.html +0 -70
- package/docs/interfaces/DoraNeoLegacyAsset.html +0 -103
- package/docs/interfaces/DoraNeoLegacyAssetResponse.html +0 -117
- package/docs/interfaces/DoraNeoLegacyBalance.html +0 -89
- package/docs/interfaces/DoraNeoLegacyConsensusNode.html +0 -75
- package/docs/interfaces/DoraNeoLegacyDetails.html +0 -138
- package/docs/interfaces/DoraNeoLegacyEntriesEntity.html +0 -110
- package/docs/interfaces/DoraNeoLegacyNameEntity.html +0 -75
- package/docs/interfaces/DoraNeoLegacyScriptsEntity.html +0 -75
- package/docs/interfaces/DoraNeoLegacyTransaction.html +0 -152
- package/docs/interfaces/DoraNeoLegacyTransactionsHistory.html +0 -96
- package/docs/interfaces/DoraNeoLegacyUnclaimed.html +0 -82
- package/docs/interfaces/DoraNeoLegacyVinEntity.html +0 -75
- package/docs/interfaces/DoraNeoLegacyVoutEntity.html +0 -89
- package/docs/modules.html +0 -98
- package/docs/variables/DORA_NEO_LEGACY_ASSET.html +0 -69
- package/docs/variables/DORA_NEO_LEGACY_BALANCE.html +0 -69
- package/docs/variables/DORA_NEO_LEGACY_CONTRACT.html +0 -69
- package/docs/variables/DORA_NEO_LEGACY_HISTORY_TRANSACTIONS.html +0 -69
- package/docs/variables/DORA_NEO_LEGACY_NODES.html +0 -69
- package/docs/variables/DORA_NEO_LEGACY_TRANSACTION.html +0 -69
- package/docs/variables/DORA_NEO_LEGACY_UNCLAIMED.html +0 -69
- 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,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 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 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,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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
expect(tokenPrice).
|
|
41
|
-
|
|
42
|
-
|
|
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
|
+
})
|
|
@@ -0,0 +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,18 +1,18 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"symbol": "GAS",
|
|
4
|
-
"type": "UtilityToken",
|
|
5
|
-
"name": "GAS",
|
|
6
|
-
"hash": "602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7",
|
|
7
|
-
"decimals": 8,
|
|
8
|
-
"blockchain": "neoLegacy"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"symbol": "NEO",
|
|
12
|
-
"type": "GoverningToken",
|
|
13
|
-
"name": "NEO",
|
|
14
|
-
"hash": "c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b",
|
|
15
|
-
"decimals": 0,
|
|
16
|
-
"blockchain": "neoLegacy"
|
|
17
|
-
}
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"symbol": "GAS",
|
|
4
|
+
"type": "UtilityToken",
|
|
5
|
+
"name": "GAS",
|
|
6
|
+
"hash": "602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7",
|
|
7
|
+
"decimals": 8,
|
|
8
|
+
"blockchain": "neoLegacy"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"symbol": "NEO",
|
|
12
|
+
"type": "GoverningToken",
|
|
13
|
+
"name": "NEO",
|
|
14
|
+
"hash": "c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b",
|
|
15
|
+
"decimals": 0,
|
|
16
|
+
"blockchain": "neoLegacy"
|
|
17
|
+
}
|
|
18
18
|
]
|