@cityofzion/bs-neo3 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.
- package/.rush/temp/operation/build/all.log +1 -0
- package/.rush/temp/operation/build/state.json +1 -1
- package/.rush/temp/package-deps_build.json +9 -7
- package/.rush/temp/shrinkwrap-deps.json +354 -130
- package/CHANGELOG.json +22 -0
- package/CHANGELOG.md +11 -0
- package/bs-neo3.build.log +1 -2
- package/dist/BSNeo3.d.ts +29 -28
- package/dist/BSNeo3.js +187 -184
- package/dist/DoraBDSNeo3.d.ts +12 -12
- package/dist/DoraBDSNeo3.js +169 -169
- package/dist/DoraESNeo3.d.ts +7 -7
- package/dist/DoraESNeo3.js +19 -19
- package/dist/FlamingoEDSNeo3.d.ts +8 -8
- package/dist/FlamingoEDSNeo3.js +45 -44
- package/dist/GhostMarketNDSNeo3.d.ts +10 -10
- package/dist/GhostMarketNDSNeo3.js +75 -75
- package/dist/RpcBDSNeo3.d.ts +16 -16
- package/dist/RpcBDSNeo3.js +153 -153
- package/dist/assets/tokens/common.json +14 -14
- package/dist/assets/tokens/mainnet.json +116 -116
- package/dist/constants.d.ts +7 -7
- package/dist/constants.js +28 -28
- package/dist/index.d.ts +6 -6
- package/dist/index.js +22 -22
- package/jest.config.ts +13 -13
- package/jest.setup.ts +1 -1
- package/package.json +33 -32
- package/src/BSNeo3.ts +232 -228
- package/src/DoraBDSNeo3.ts +180 -180
- package/src/DoraESNeo3.ts +19 -19
- package/src/FlamingoEDSNeo3.ts +47 -45
- package/src/GhostMarketNDSNeo3.ts +117 -117
- package/src/RpcBDSNeo3.ts +157 -157
- package/src/__tests__/BDSNeo3.spec.ts +126 -126
- package/src/__tests__/BSNeo3.spec.ts +150 -142
- package/src/__tests__/DoraESNeo3.spec.ts +23 -23
- package/src/__tests__/FlamingoEDSNeo3.spec.ts +48 -45
- package/src/__tests__/GhostMarketNDSNeo3.spec.ts +43 -43
- package/src/__tests__/utils/sleep.ts +1 -1
- package/src/assets/tokens/common.json +13 -13
- package/src/assets/tokens/mainnet.json +115 -115
- package/src/constants.ts +29 -29
- package/src/index.ts +6 -6
- package/tsconfig.build.json +4 -4
- package/tsconfig.json +14 -14
- package/dist/BDSNeo3.d.ts +0 -15
- package/dist/BDSNeo3.js +0 -211
- package/dist/assets/tokens.json +0 -128
- package/dist/exceptions.d.ts +0 -3
- package/dist/exceptions.js +0 -8
- package/dist/explorer/dora/DoraNeo3Responses.d.ts +0 -174
- package/dist/explorer/dora/DoraNeo3Responses.js +0 -3
- package/dist/explorer/dora/DoraNeo3Routes.d.ts +0 -6
- package/dist/explorer/dora/DoraNeo3Routes.js +0 -9
- 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/BDSNeo3.html +0 -253
- package/docs/classes/BSNeo3.html +0 -442
- package/docs/index.html +0 -82
- package/docs/interfaces/DoraNeo3Abi.html +0 -78
- package/docs/interfaces/DoraNeo3Asset.html +0 -117
- package/docs/interfaces/DoraNeo3AssetState.html +0 -96
- package/docs/interfaces/DoraNeo3Balance.html +0 -89
- package/docs/interfaces/DoraNeo3ConsensusNode.html +0 -75
- package/docs/interfaces/DoraNeo3Contract.html +0 -110
- package/docs/interfaces/DoraNeo3Event.html +0 -75
- package/docs/interfaces/DoraNeo3Features.html +0 -84
- package/docs/interfaces/DoraNeo3HistoryState.html +0 -75
- package/docs/interfaces/DoraNeo3Invocation.html +0 -75
- package/docs/interfaces/DoraNeo3Item.html +0 -131
- package/docs/interfaces/DoraNeo3Manifest.html +0 -117
- package/docs/interfaces/DoraNeo3Metadata.html +0 -138
- package/docs/interfaces/DoraNeo3Method.html +0 -102
- package/docs/interfaces/DoraNeo3Nef.html +0 -103
- package/docs/interfaces/DoraNeo3Notification.html +0 -82
- package/docs/interfaces/DoraNeo3Parameter.html +0 -75
- package/docs/interfaces/DoraNeo3Permission.html +0 -75
- package/docs/interfaces/DoraNeo3Signer.html +0 -75
- package/docs/interfaces/DoraNeo3Token.html +0 -96
- package/docs/interfaces/DoraNeo3Transaction.html +0 -166
- package/docs/interfaces/DoraNeo3TransactionHistory.html +0 -75
- package/docs/interfaces/DoraNeo3Transfer.html +0 -117
- package/docs/interfaces/DoraNeo3Witness.html +0 -75
- package/docs/modules.html +0 -122
- package/docs/variables/DORA_ASSET.html +0 -81
- package/docs/variables/DORA_BALANCE.html +0 -81
- package/docs/variables/DORA_CONTRACT.html +0 -81
- package/docs/variables/DORA_NODES.html +0 -81
- package/docs/variables/DORA_TRANSACTION.html +0 -81
- package/docs/variables/DORA_TRANSACTIONS.html +0 -81
- package/docs/variables/explorerOptions.html +0 -86
- package/docs/variables/gasInfoNeo3.html +0 -90
- package/docs/variables/neoInfoNeo3.html +0 -90
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
import { BDSClaimable, BlockchainDataService } from '@cityofzion/blockchain-service'
|
|
2
|
-
import { DoraBDSNeo3 } from '../DoraBDSNeo3'
|
|
3
|
-
import { RPCBDSNeo3 } from '../RpcBDSNeo3'
|
|
4
|
-
import { DEFAULT_URL_BY_NETWORK_TYPE, TOKENS } from '../constants'
|
|
5
|
-
|
|
6
|
-
const gasToken = TOKENS.testnet.find(t => t.symbol === 'GAS')!
|
|
7
|
-
let doraBDSNeo3 = new DoraBDSNeo3({ type: 'testnet', url: DEFAULT_URL_BY_NETWORK_TYPE.testnet }, gasToken, gasToken)
|
|
8
|
-
let rpcBDSNeo3 = new RPCBDSNeo3({ type: 'testnet', url: DEFAULT_URL_BY_NETWORK_TYPE.testnet }, gasToken, gasToken)
|
|
9
|
-
|
|
10
|
-
describe('BDSNeo3', () => {
|
|
11
|
-
it.each([doraBDSNeo3, rpcBDSNeo3])(
|
|
12
|
-
'Should be able to get transaction - %s',
|
|
13
|
-
async (bdsNeo3: BlockchainDataService) => {
|
|
14
|
-
const hash = '0x70e7381c5dee6e81becd02844e4e0199f6b3df834213bc89418dc4da32cf3f21'
|
|
15
|
-
const transaction = await bdsNeo3.getTransaction(hash)
|
|
16
|
-
|
|
17
|
-
expect(transaction).toEqual(
|
|
18
|
-
expect.objectContaining({
|
|
19
|
-
block: expect.any(Number),
|
|
20
|
-
hash,
|
|
21
|
-
notifications: [],
|
|
22
|
-
transfers: [],
|
|
23
|
-
time: expect.any(Number),
|
|
24
|
-
fee: expect.any(String),
|
|
25
|
-
})
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
it.each([doraBDSNeo3, rpcBDSNeo3])(
|
|
31
|
-
'Should be able to get transactions of address - %s',
|
|
32
|
-
async (bdsNeo3: BlockchainDataService) => {
|
|
33
|
-
const address = 'NNmTVFrSPhe7zjgN6iq9cLgXJwLZziUKV6'
|
|
34
|
-
try {
|
|
35
|
-
const response = await bdsNeo3.getTransactionsByAddress({ address, page: 1 })
|
|
36
|
-
|
|
37
|
-
response.transactions.forEach(transaction => {
|
|
38
|
-
expect(transaction).toEqual(
|
|
39
|
-
expect.objectContaining({
|
|
40
|
-
block: expect.any(Number),
|
|
41
|
-
hash: expect.any(String),
|
|
42
|
-
notifications: expect.arrayContaining([
|
|
43
|
-
expect.objectContaining({
|
|
44
|
-
eventName: expect.any(String),
|
|
45
|
-
state: expect.arrayContaining([
|
|
46
|
-
{
|
|
47
|
-
type: expect.any(String),
|
|
48
|
-
value: expect.any(String),
|
|
49
|
-
},
|
|
50
|
-
]),
|
|
51
|
-
}),
|
|
52
|
-
]),
|
|
53
|
-
transfers: expect.arrayContaining([
|
|
54
|
-
expect.objectContaining({
|
|
55
|
-
amount: expect.any(String),
|
|
56
|
-
from: expect.any(String),
|
|
57
|
-
to: expect.any(String),
|
|
58
|
-
type: 'asset',
|
|
59
|
-
}),
|
|
60
|
-
]),
|
|
61
|
-
time: expect.any(Number),
|
|
62
|
-
fee: expect.any(String),
|
|
63
|
-
})
|
|
64
|
-
)
|
|
65
|
-
})
|
|
66
|
-
} catch {}
|
|
67
|
-
}
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
it.each([doraBDSNeo3, rpcBDSNeo3])('Should be able to get contract - %s', async (bdsNeo3: BlockchainDataService) => {
|
|
71
|
-
const hash = '0xd2a4cff31913016155e38e474a2c06d08be276cf'
|
|
72
|
-
const contract = await bdsNeo3.getContract(hash)
|
|
73
|
-
expect(contract).toEqual({
|
|
74
|
-
hash: hash,
|
|
75
|
-
name: 'GasToken',
|
|
76
|
-
methods: expect.arrayContaining([
|
|
77
|
-
expect.objectContaining({
|
|
78
|
-
name: expect.any(String),
|
|
79
|
-
parameters: expect.arrayContaining([
|
|
80
|
-
expect.objectContaining({ name: expect.any(String), type: expect.any(String) }),
|
|
81
|
-
]),
|
|
82
|
-
}),
|
|
83
|
-
]),
|
|
84
|
-
})
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
it.each([doraBDSNeo3, rpcBDSNeo3])(
|
|
88
|
-
'Should be able to get token info - %s',
|
|
89
|
-
async (bdsNeo3: BlockchainDataService) => {
|
|
90
|
-
const hash = '0xd2a4cff31913016155e38e474a2c06d08be276cf'
|
|
91
|
-
const token = await bdsNeo3.getTokenInfo(hash)
|
|
92
|
-
|
|
93
|
-
expect(token).toEqual({
|
|
94
|
-
decimals: 8,
|
|
95
|
-
hash: hash,
|
|
96
|
-
name: 'GasToken',
|
|
97
|
-
symbol: 'GAS',
|
|
98
|
-
})
|
|
99
|
-
}
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
it.each([doraBDSNeo3, rpcBDSNeo3])('Should be able to get balance - %s', async (bdsNeo3: BlockchainDataService) => {
|
|
103
|
-
const address = 'NNmTVFrSPhe7zjgN6iq9cLgXJwLZziUKV6'
|
|
104
|
-
const balance = await bdsNeo3.getBalance(address)
|
|
105
|
-
balance.forEach(balance => {
|
|
106
|
-
expect(balance).toEqual({
|
|
107
|
-
amount: expect.any(String),
|
|
108
|
-
token: {
|
|
109
|
-
hash: expect.any(String),
|
|
110
|
-
name: expect.any(String),
|
|
111
|
-
symbol: expect.any(String),
|
|
112
|
-
decimals: expect.any(Number),
|
|
113
|
-
},
|
|
114
|
-
})
|
|
115
|
-
})
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
it.each([doraBDSNeo3, rpcBDSNeo3])(
|
|
119
|
-
'Should be able to get unclaimed - %s',
|
|
120
|
-
async (bdsNeo3: BlockchainDataService & BDSClaimable) => {
|
|
121
|
-
const address = 'NNmTVFrSPhe7zjgN6iq9cLgXJwLZziUKV6'
|
|
122
|
-
const unclaimed = await bdsNeo3.getUnclaimed(address)
|
|
123
|
-
expect(unclaimed).toEqual(expect.any(String))
|
|
124
|
-
}
|
|
125
|
-
)
|
|
126
|
-
})
|
|
1
|
+
import { BDSClaimable, BlockchainDataService } from '@cityofzion/blockchain-service'
|
|
2
|
+
import { DoraBDSNeo3 } from '../DoraBDSNeo3'
|
|
3
|
+
import { RPCBDSNeo3 } from '../RpcBDSNeo3'
|
|
4
|
+
import { DEFAULT_URL_BY_NETWORK_TYPE, TOKENS } from '../constants'
|
|
5
|
+
|
|
6
|
+
const gasToken = TOKENS.testnet.find(t => t.symbol === 'GAS')!
|
|
7
|
+
let doraBDSNeo3 = new DoraBDSNeo3({ type: 'testnet', url: DEFAULT_URL_BY_NETWORK_TYPE.testnet }, gasToken, gasToken)
|
|
8
|
+
let rpcBDSNeo3 = new RPCBDSNeo3({ type: 'testnet', url: DEFAULT_URL_BY_NETWORK_TYPE.testnet }, gasToken, gasToken)
|
|
9
|
+
|
|
10
|
+
describe('BDSNeo3', () => {
|
|
11
|
+
it.each([doraBDSNeo3, rpcBDSNeo3])(
|
|
12
|
+
'Should be able to get transaction - %s',
|
|
13
|
+
async (bdsNeo3: BlockchainDataService) => {
|
|
14
|
+
const hash = '0x70e7381c5dee6e81becd02844e4e0199f6b3df834213bc89418dc4da32cf3f21'
|
|
15
|
+
const transaction = await bdsNeo3.getTransaction(hash)
|
|
16
|
+
|
|
17
|
+
expect(transaction).toEqual(
|
|
18
|
+
expect.objectContaining({
|
|
19
|
+
block: expect.any(Number),
|
|
20
|
+
hash,
|
|
21
|
+
notifications: [],
|
|
22
|
+
transfers: [],
|
|
23
|
+
time: expect.any(Number),
|
|
24
|
+
fee: expect.any(String),
|
|
25
|
+
})
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
it.each([doraBDSNeo3, rpcBDSNeo3])(
|
|
31
|
+
'Should be able to get transactions of address - %s',
|
|
32
|
+
async (bdsNeo3: BlockchainDataService) => {
|
|
33
|
+
const address = 'NNmTVFrSPhe7zjgN6iq9cLgXJwLZziUKV6'
|
|
34
|
+
try {
|
|
35
|
+
const response = await bdsNeo3.getTransactionsByAddress({ address, page: 1 })
|
|
36
|
+
|
|
37
|
+
response.transactions.forEach(transaction => {
|
|
38
|
+
expect(transaction).toEqual(
|
|
39
|
+
expect.objectContaining({
|
|
40
|
+
block: expect.any(Number),
|
|
41
|
+
hash: expect.any(String),
|
|
42
|
+
notifications: expect.arrayContaining([
|
|
43
|
+
expect.objectContaining({
|
|
44
|
+
eventName: expect.any(String),
|
|
45
|
+
state: expect.arrayContaining([
|
|
46
|
+
{
|
|
47
|
+
type: expect.any(String),
|
|
48
|
+
value: expect.any(String),
|
|
49
|
+
},
|
|
50
|
+
]),
|
|
51
|
+
}),
|
|
52
|
+
]),
|
|
53
|
+
transfers: expect.arrayContaining([
|
|
54
|
+
expect.objectContaining({
|
|
55
|
+
amount: expect.any(String),
|
|
56
|
+
from: expect.any(String),
|
|
57
|
+
to: expect.any(String),
|
|
58
|
+
type: 'asset',
|
|
59
|
+
}),
|
|
60
|
+
]),
|
|
61
|
+
time: expect.any(Number),
|
|
62
|
+
fee: expect.any(String),
|
|
63
|
+
})
|
|
64
|
+
)
|
|
65
|
+
})
|
|
66
|
+
} catch {}
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
it.each([doraBDSNeo3, rpcBDSNeo3])('Should be able to get contract - %s', async (bdsNeo3: BlockchainDataService) => {
|
|
71
|
+
const hash = '0xd2a4cff31913016155e38e474a2c06d08be276cf'
|
|
72
|
+
const contract = await bdsNeo3.getContract(hash)
|
|
73
|
+
expect(contract).toEqual({
|
|
74
|
+
hash: hash,
|
|
75
|
+
name: 'GasToken',
|
|
76
|
+
methods: expect.arrayContaining([
|
|
77
|
+
expect.objectContaining({
|
|
78
|
+
name: expect.any(String),
|
|
79
|
+
parameters: expect.arrayContaining([
|
|
80
|
+
expect.objectContaining({ name: expect.any(String), type: expect.any(String) }),
|
|
81
|
+
]),
|
|
82
|
+
}),
|
|
83
|
+
]),
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
it.each([doraBDSNeo3, rpcBDSNeo3])(
|
|
88
|
+
'Should be able to get token info - %s',
|
|
89
|
+
async (bdsNeo3: BlockchainDataService) => {
|
|
90
|
+
const hash = '0xd2a4cff31913016155e38e474a2c06d08be276cf'
|
|
91
|
+
const token = await bdsNeo3.getTokenInfo(hash)
|
|
92
|
+
|
|
93
|
+
expect(token).toEqual({
|
|
94
|
+
decimals: 8,
|
|
95
|
+
hash: hash,
|
|
96
|
+
name: 'GasToken',
|
|
97
|
+
symbol: 'GAS',
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
it.each([doraBDSNeo3, rpcBDSNeo3])('Should be able to get balance - %s', async (bdsNeo3: BlockchainDataService) => {
|
|
103
|
+
const address = 'NNmTVFrSPhe7zjgN6iq9cLgXJwLZziUKV6'
|
|
104
|
+
const balance = await bdsNeo3.getBalance(address)
|
|
105
|
+
balance.forEach(balance => {
|
|
106
|
+
expect(balance).toEqual({
|
|
107
|
+
amount: expect.any(String),
|
|
108
|
+
token: {
|
|
109
|
+
hash: expect.any(String),
|
|
110
|
+
name: expect.any(String),
|
|
111
|
+
symbol: expect.any(String),
|
|
112
|
+
decimals: expect.any(Number),
|
|
113
|
+
},
|
|
114
|
+
})
|
|
115
|
+
})
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
it.each([doraBDSNeo3, rpcBDSNeo3])(
|
|
119
|
+
'Should be able to get unclaimed - %s',
|
|
120
|
+
async (bdsNeo3: BlockchainDataService & BDSClaimable) => {
|
|
121
|
+
const address = 'NNmTVFrSPhe7zjgN6iq9cLgXJwLZziUKV6'
|
|
122
|
+
const unclaimed = await bdsNeo3.getUnclaimed(address)
|
|
123
|
+
expect(unclaimed).toEqual(expect.any(String))
|
|
124
|
+
}
|
|
125
|
+
)
|
|
126
|
+
})
|
|
@@ -1,142 +1,150 @@
|
|
|
1
|
-
import { wallet } from '@cityofzion/neon-js'
|
|
2
|
-
import { sleep } from './utils/sleep'
|
|
3
|
-
import { BSNeo3 } from '../BSNeo3'
|
|
4
|
-
import { generateMnemonic } from '@cityofzion/bs-asteroid-sdk'
|
|
5
|
-
|
|
6
|
-
let bsNeo3: BSNeo3
|
|
7
|
-
|
|
8
|
-
describe('BSNeo3', () => {
|
|
9
|
-
beforeAll(() => {
|
|
10
|
-
bsNeo3 = new BSNeo3('neo3', { type: 'testnet', url: 'https://testnet1.neo.coz.io:443' })
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it('Should be able to validate an address', () => {
|
|
14
|
-
const validAddress = 'NPRMF5bmYuW23DeDJqsDJenhXkAPSJyuYe'
|
|
15
|
-
const invalidAddress = 'invalid address'
|
|
16
|
-
|
|
17
|
-
expect(bsNeo3.validateAddress(validAddress)).toBeTruthy()
|
|
18
|
-
expect(bsNeo3.validateAddress(invalidAddress)).toBeFalsy()
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
it('Should be able to validate an encrypted key', () => {
|
|
22
|
-
const validEncryptedKey = '6PYVPVe1fQznphjbUxXP9KZJqPMVnVwCx5s5pr5axRJ8uHkMtZg97eT5kL'
|
|
23
|
-
const invalidEncryptedKey = 'invalid encrypted key'
|
|
24
|
-
|
|
25
|
-
expect(bsNeo3.validateEncrypted(validEncryptedKey)).toBeTruthy()
|
|
26
|
-
expect(bsNeo3.validateEncrypted(invalidEncryptedKey)).toBeFalsy()
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('Should be able to validate a wif', () => {
|
|
30
|
-
const validWif = 'L44B5gGEpqEDRS9vVPz7QT35jcBG2r3CZwSwQ4fCewXAhAhqGVpP'
|
|
31
|
-
const invalidWif = 'invalid wif'
|
|
32
|
-
|
|
33
|
-
expect(bsNeo3.validateKey(validWif)).toBeTruthy()
|
|
34
|
-
expect(bsNeo3.validateKey(invalidWif)).toBeFalsy()
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('Should be able to validate an domain', () => {
|
|
38
|
-
const validDomain = 'test.neo'
|
|
39
|
-
const invalidDomain = 'invalid domain'
|
|
40
|
-
|
|
41
|
-
expect(bsNeo3.validateNameServiceDomainFormat(validDomain)).toBeTruthy()
|
|
42
|
-
expect(bsNeo3.validateNameServiceDomainFormat(invalidDomain)).toBeFalsy()
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('Should be able to generate a mnemonic', () => {
|
|
46
|
-
expect(() => {
|
|
47
|
-
const mnemonic = generateMnemonic()
|
|
48
|
-
expect(mnemonic).toHaveLength(12)
|
|
49
|
-
}).not.toThrowError()
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
it('Should be able to gererate a account from mnemonic', () => {
|
|
53
|
-
const mnemonic = generateMnemonic()
|
|
54
|
-
const account = bsNeo3.generateAccountFromMnemonic(mnemonic, 0)
|
|
55
|
-
|
|
56
|
-
expect(bsNeo3.validateAddress(account.address)).toBeTruthy()
|
|
57
|
-
expect(bsNeo3.validateKey(account.key)).toBeTruthy()
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it('Should be able to generate a account from wif', () => {
|
|
61
|
-
const mnemonic = generateMnemonic()
|
|
62
|
-
const account = bsNeo3.generateAccountFromMnemonic(mnemonic, 0)
|
|
63
|
-
|
|
64
|
-
const accountFromWif = bsNeo3.generateAccountFromKey(account.key)
|
|
65
|
-
expect(account).toEqual(expect.objectContaining(accountFromWif))
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
it('Should be able to decrypt a encrypted key', async () => {
|
|
69
|
-
const mnemonic = generateMnemonic()
|
|
70
|
-
const account = bsNeo3.generateAccountFromMnemonic(mnemonic, 0)
|
|
71
|
-
const password = 'TestPassword'
|
|
72
|
-
const encryptedKey = await
|
|
73
|
-
const decryptedAccount = await bsNeo3.decrypt(encryptedKey, password)
|
|
74
|
-
expect(account).toEqual(expect.objectContaining(decryptedAccount))
|
|
75
|
-
}, 20000)
|
|
76
|
-
|
|
77
|
-
it
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
1
|
+
import { wallet } from '@cityofzion/neon-js'
|
|
2
|
+
import { sleep } from './utils/sleep'
|
|
3
|
+
import { BSNeo3 } from '../BSNeo3'
|
|
4
|
+
import { generateMnemonic } from '@cityofzion/bs-asteroid-sdk'
|
|
5
|
+
|
|
6
|
+
let bsNeo3: BSNeo3
|
|
7
|
+
|
|
8
|
+
describe('BSNeo3', () => {
|
|
9
|
+
beforeAll(() => {
|
|
10
|
+
bsNeo3 = new BSNeo3('neo3', { type: 'testnet', url: 'https://testnet1.neo.coz.io:443' })
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
it('Should be able to validate an address', () => {
|
|
14
|
+
const validAddress = 'NPRMF5bmYuW23DeDJqsDJenhXkAPSJyuYe'
|
|
15
|
+
const invalidAddress = 'invalid address'
|
|
16
|
+
|
|
17
|
+
expect(bsNeo3.validateAddress(validAddress)).toBeTruthy()
|
|
18
|
+
expect(bsNeo3.validateAddress(invalidAddress)).toBeFalsy()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('Should be able to validate an encrypted key', () => {
|
|
22
|
+
const validEncryptedKey = '6PYVPVe1fQznphjbUxXP9KZJqPMVnVwCx5s5pr5axRJ8uHkMtZg97eT5kL'
|
|
23
|
+
const invalidEncryptedKey = 'invalid encrypted key'
|
|
24
|
+
|
|
25
|
+
expect(bsNeo3.validateEncrypted(validEncryptedKey)).toBeTruthy()
|
|
26
|
+
expect(bsNeo3.validateEncrypted(invalidEncryptedKey)).toBeFalsy()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('Should be able to validate a wif', () => {
|
|
30
|
+
const validWif = 'L44B5gGEpqEDRS9vVPz7QT35jcBG2r3CZwSwQ4fCewXAhAhqGVpP'
|
|
31
|
+
const invalidWif = 'invalid wif'
|
|
32
|
+
|
|
33
|
+
expect(bsNeo3.validateKey(validWif)).toBeTruthy()
|
|
34
|
+
expect(bsNeo3.validateKey(invalidWif)).toBeFalsy()
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('Should be able to validate an domain', () => {
|
|
38
|
+
const validDomain = 'test.neo'
|
|
39
|
+
const invalidDomain = 'invalid domain'
|
|
40
|
+
|
|
41
|
+
expect(bsNeo3.validateNameServiceDomainFormat(validDomain)).toBeTruthy()
|
|
42
|
+
expect(bsNeo3.validateNameServiceDomainFormat(invalidDomain)).toBeFalsy()
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('Should be able to generate a mnemonic', () => {
|
|
46
|
+
expect(() => {
|
|
47
|
+
const mnemonic = generateMnemonic()
|
|
48
|
+
expect(mnemonic).toHaveLength(12)
|
|
49
|
+
}).not.toThrowError()
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('Should be able to gererate a account from mnemonic', () => {
|
|
53
|
+
const mnemonic = generateMnemonic()
|
|
54
|
+
const account = bsNeo3.generateAccountFromMnemonic(mnemonic, 0)
|
|
55
|
+
|
|
56
|
+
expect(bsNeo3.validateAddress(account.address)).toBeTruthy()
|
|
57
|
+
expect(bsNeo3.validateKey(account.key)).toBeTruthy()
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('Should be able to generate a account from wif', () => {
|
|
61
|
+
const mnemonic = generateMnemonic()
|
|
62
|
+
const account = bsNeo3.generateAccountFromMnemonic(mnemonic, 0)
|
|
63
|
+
|
|
64
|
+
const accountFromWif = bsNeo3.generateAccountFromKey(account.key)
|
|
65
|
+
expect(account).toEqual(expect.objectContaining(accountFromWif))
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('Should be able to decrypt a encrypted key', async () => {
|
|
69
|
+
const mnemonic = generateMnemonic()
|
|
70
|
+
const account = bsNeo3.generateAccountFromMnemonic(mnemonic, 0)
|
|
71
|
+
const password = 'TestPassword'
|
|
72
|
+
const encryptedKey = await bsNeo3.encrypt(account.key, password)
|
|
73
|
+
const decryptedAccount = await bsNeo3.decrypt(encryptedKey, password)
|
|
74
|
+
expect(account).toEqual(expect.objectContaining(decryptedAccount))
|
|
75
|
+
}, 20000)
|
|
76
|
+
|
|
77
|
+
it('Should be able to encrypt a key', async () => {
|
|
78
|
+
const mnemonic = generateMnemonic()
|
|
79
|
+
const account = bsNeo3.generateAccountFromMnemonic(mnemonic, 0)
|
|
80
|
+
const password = 'TestPassword'
|
|
81
|
+
const encryptedKey = await bsNeo3.encrypt(account.key, password)
|
|
82
|
+
expect(encryptedKey).toEqual(expect.any(String))
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
it.skip('Should be able to calculate transfer fee', async () => {
|
|
86
|
+
const account = bsNeo3.generateAccountFromKey(process.env.TESTNET_PRIVATE_KEY as string)
|
|
87
|
+
|
|
88
|
+
const fee = await bsNeo3.calculateTransferFee({
|
|
89
|
+
senderAccount: account,
|
|
90
|
+
intent: {
|
|
91
|
+
amount: '0.00000001',
|
|
92
|
+
receiverAddress: 'NPRMF5bmYuW23DeDJqsDJenhXkAPSJyuYe',
|
|
93
|
+
tokenHash: bsNeo3.feeToken.hash,
|
|
94
|
+
tokenDecimals: bsNeo3.feeToken.decimals,
|
|
95
|
+
},
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
expect(fee).toEqual({
|
|
99
|
+
total: expect.any(Number),
|
|
100
|
+
networkFee: expect.any(Number),
|
|
101
|
+
systemFee: expect.any(Number),
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
it.skip('Should be able to transfer', async () => {
|
|
106
|
+
const account = bsNeo3.generateAccountFromKey(process.env.TESTNET_PRIVATE_KEY as string)
|
|
107
|
+
const balance = await bsNeo3.blockchainDataService.getBalance(account.address)
|
|
108
|
+
const gasBalance = balance.find(b => b.token.symbol === bsNeo3.feeToken.symbol)
|
|
109
|
+
expect(Number(gasBalance?.amount)).toBeGreaterThan(0.00000001)
|
|
110
|
+
|
|
111
|
+
const transactionHash = await bsNeo3.transfer({
|
|
112
|
+
senderAccount: account,
|
|
113
|
+
intent: {
|
|
114
|
+
amount: '0.00000001',
|
|
115
|
+
receiverAddress: 'NPRMF5bmYuW23DeDJqsDJenhXkAPSJyuYe',
|
|
116
|
+
tokenHash: bsNeo3.feeToken.hash,
|
|
117
|
+
tokenDecimals: bsNeo3.feeToken.decimals,
|
|
118
|
+
},
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
expect(transactionHash).toEqual(expect.any(String))
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
it.skip('Should be able to claim', async () => {
|
|
125
|
+
const account = bsNeo3.generateAccountFromKey(process.env.TESTNET_PRIVATE_KEY as string)
|
|
126
|
+
|
|
127
|
+
const maxTries = 10
|
|
128
|
+
let tries = 0
|
|
129
|
+
|
|
130
|
+
while (tries < maxTries) {
|
|
131
|
+
try {
|
|
132
|
+
const unclaimed = await bsNeo3.blockchainDataService.getUnclaimed(account.address)
|
|
133
|
+
if (Number(unclaimed) <= 0) continue
|
|
134
|
+
|
|
135
|
+
const transactionHash = await bsNeo3.claim(account)
|
|
136
|
+
expect(transactionHash).toEqual(expect.any(String))
|
|
137
|
+
break
|
|
138
|
+
} catch (error) {
|
|
139
|
+
await sleep(4000)
|
|
140
|
+
} finally {
|
|
141
|
+
tries++
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}, 60000)
|
|
145
|
+
|
|
146
|
+
it('Should be able to resolve a name service domain', async () => {
|
|
147
|
+
const owner = await bsNeo3.resolveNameServiceDomain('neo.neo')
|
|
148
|
+
expect(owner).toEqual('Nj39M97Rk2e23JiULBBMQmvpcnKaRHqxFf')
|
|
149
|
+
})
|
|
150
|
+
})
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { DoraESNeo3 } from '../DoraESNeo3'
|
|
2
|
-
|
|
3
|
-
let doraESNeo3: DoraESNeo3
|
|
4
|
-
|
|
5
|
-
describe('DoraESNeo3', () => {
|
|
6
|
-
beforeAll(() => {
|
|
7
|
-
doraESNeo3 = new DoraESNeo3('mainnet')
|
|
8
|
-
})
|
|
9
|
-
it('Should return a transaction url', async () => {
|
|
10
|
-
const hash = '0x775d824a54d4e9bebf3c522a7d8dede550348323d833ce68fbcf0ab953d579e8'
|
|
11
|
-
const url = doraESNeo3.buildTransactionUrl(hash)
|
|
12
|
-
|
|
13
|
-
expect(url).toEqual(`https://dora.coz.io/transaction/neo3/mainnet/${hash}`)
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
it('Should return a nft url', async () => {
|
|
17
|
-
const contractHash = '0x577a51f7d39162c9de1db12a6b319c848e4c54e5'
|
|
18
|
-
const tokenId = 'rAI='
|
|
19
|
-
const url = doraESNeo3.buildNftUrl({ contractHash, tokenId })
|
|
20
|
-
|
|
21
|
-
expect(url).toEqual(`https://dora.coz.io/nft/neo3/mainnet/${contractHash}/${tokenId}`)
|
|
22
|
-
})
|
|
23
|
-
})
|
|
1
|
+
import { DoraESNeo3 } from '../DoraESNeo3'
|
|
2
|
+
|
|
3
|
+
let doraESNeo3: DoraESNeo3
|
|
4
|
+
|
|
5
|
+
describe('DoraESNeo3', () => {
|
|
6
|
+
beforeAll(() => {
|
|
7
|
+
doraESNeo3 = new DoraESNeo3('mainnet')
|
|
8
|
+
})
|
|
9
|
+
it('Should return a transaction url', async () => {
|
|
10
|
+
const hash = '0x775d824a54d4e9bebf3c522a7d8dede550348323d833ce68fbcf0ab953d579e8'
|
|
11
|
+
const url = doraESNeo3.buildTransactionUrl(hash)
|
|
12
|
+
|
|
13
|
+
expect(url).toEqual(`https://dora.coz.io/transaction/neo3/mainnet/${hash}`)
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('Should return a nft url', async () => {
|
|
17
|
+
const contractHash = '0x577a51f7d39162c9de1db12a6b319c848e4c54e5'
|
|
18
|
+
const tokenId = 'rAI='
|
|
19
|
+
const url = doraESNeo3.buildNftUrl({ contractHash, tokenId })
|
|
20
|
+
|
|
21
|
+
expect(url).toEqual(`https://dora.coz.io/nft/neo3/mainnet/${contractHash}/${tokenId}`)
|
|
22
|
+
})
|
|
23
|
+
})
|