@cityofzion/bs-neo3 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.
Files changed (99) hide show
  1. package/.rush/temp/operation/build/all.log +1 -0
  2. package/.rush/temp/operation/build/state.json +1 -1
  3. package/.rush/temp/package-deps_build.json +11 -7
  4. package/.rush/temp/shrinkwrap-deps.json +354 -130
  5. package/CHANGELOG.json +22 -0
  6. package/CHANGELOG.md +11 -0
  7. package/bs-neo3.build.log +1 -2
  8. package/dist/BSNeo3.d.ts +28 -27
  9. package/dist/BSNeo3.js +184 -182
  10. package/dist/DoraBDSNeo3.d.ts +12 -12
  11. package/dist/DoraBDSNeo3.js +169 -169
  12. package/dist/DoraESNeo3.d.ts +7 -0
  13. package/dist/DoraESNeo3.js +19 -0
  14. package/dist/FlamingoEDSNeo3.d.ts +8 -8
  15. package/dist/FlamingoEDSNeo3.js +45 -44
  16. package/dist/GhostMarketNDSNeo3.d.ts +10 -10
  17. package/dist/GhostMarketNDSNeo3.js +75 -75
  18. package/dist/RpcBDSNeo3.d.ts +16 -15
  19. package/dist/RpcBDSNeo3.js +153 -152
  20. package/dist/assets/tokens/common.json +14 -14
  21. package/dist/assets/tokens/mainnet.json +116 -116
  22. package/dist/constants.d.ts +7 -7
  23. package/dist/constants.js +28 -28
  24. package/dist/index.d.ts +6 -6
  25. package/dist/index.js +22 -22
  26. package/jest.config.ts +13 -13
  27. package/jest.setup.ts +1 -1
  28. package/package.json +33 -32
  29. package/src/BSNeo3.ts +228 -223
  30. package/src/DoraBDSNeo3.ts +180 -180
  31. package/src/DoraESNeo3.ts +19 -0
  32. package/src/FlamingoEDSNeo3.ts +47 -45
  33. package/src/GhostMarketNDSNeo3.ts +117 -117
  34. package/src/RpcBDSNeo3.ts +157 -155
  35. package/src/__tests__/BDSNeo3.spec.ts +126 -126
  36. package/src/__tests__/BSNeo3.spec.ts +142 -142
  37. package/src/__tests__/DoraESNeo3.spec.ts +23 -0
  38. package/src/__tests__/FlamingoEDSNeo3.spec.ts +48 -45
  39. package/src/__tests__/GhostMarketNDSNeo3.spec.ts +43 -43
  40. package/src/__tests__/utils/sleep.ts +1 -1
  41. package/src/assets/tokens/common.json +13 -13
  42. package/src/assets/tokens/mainnet.json +115 -115
  43. package/src/constants.ts +29 -29
  44. package/src/index.ts +6 -6
  45. package/tsconfig.build.json +4 -4
  46. package/tsconfig.json +14 -14
  47. package/dist/BDSNeo3.d.ts +0 -15
  48. package/dist/BDSNeo3.js +0 -211
  49. package/dist/assets/tokens.json +0 -128
  50. package/dist/exceptions.d.ts +0 -3
  51. package/dist/exceptions.js +0 -8
  52. package/dist/explorer/dora/DoraNeo3Responses.d.ts +0 -174
  53. package/dist/explorer/dora/DoraNeo3Responses.js +0 -3
  54. package/dist/explorer/dora/DoraNeo3Routes.d.ts +0 -6
  55. package/dist/explorer/dora/DoraNeo3Routes.js +0 -9
  56. package/dist/explorer/index.d.ts +0 -6
  57. package/dist/explorer/index.js +0 -23
  58. package/docs/.nojekyll +0 -1
  59. package/docs/assets/highlight.css +0 -22
  60. package/docs/assets/main.js +0 -58
  61. package/docs/assets/search.js +0 -1
  62. package/docs/assets/style.css +0 -1280
  63. package/docs/classes/BDSNeo3.html +0 -253
  64. package/docs/classes/BSNeo3.html +0 -442
  65. package/docs/index.html +0 -82
  66. package/docs/interfaces/DoraNeo3Abi.html +0 -78
  67. package/docs/interfaces/DoraNeo3Asset.html +0 -117
  68. package/docs/interfaces/DoraNeo3AssetState.html +0 -96
  69. package/docs/interfaces/DoraNeo3Balance.html +0 -89
  70. package/docs/interfaces/DoraNeo3ConsensusNode.html +0 -75
  71. package/docs/interfaces/DoraNeo3Contract.html +0 -110
  72. package/docs/interfaces/DoraNeo3Event.html +0 -75
  73. package/docs/interfaces/DoraNeo3Features.html +0 -84
  74. package/docs/interfaces/DoraNeo3HistoryState.html +0 -75
  75. package/docs/interfaces/DoraNeo3Invocation.html +0 -75
  76. package/docs/interfaces/DoraNeo3Item.html +0 -131
  77. package/docs/interfaces/DoraNeo3Manifest.html +0 -117
  78. package/docs/interfaces/DoraNeo3Metadata.html +0 -138
  79. package/docs/interfaces/DoraNeo3Method.html +0 -102
  80. package/docs/interfaces/DoraNeo3Nef.html +0 -103
  81. package/docs/interfaces/DoraNeo3Notification.html +0 -82
  82. package/docs/interfaces/DoraNeo3Parameter.html +0 -75
  83. package/docs/interfaces/DoraNeo3Permission.html +0 -75
  84. package/docs/interfaces/DoraNeo3Signer.html +0 -75
  85. package/docs/interfaces/DoraNeo3Token.html +0 -96
  86. package/docs/interfaces/DoraNeo3Transaction.html +0 -166
  87. package/docs/interfaces/DoraNeo3TransactionHistory.html +0 -75
  88. package/docs/interfaces/DoraNeo3Transfer.html +0 -117
  89. package/docs/interfaces/DoraNeo3Witness.html +0 -75
  90. package/docs/modules.html +0 -122
  91. package/docs/variables/DORA_ASSET.html +0 -81
  92. package/docs/variables/DORA_BALANCE.html +0 -81
  93. package/docs/variables/DORA_CONTRACT.html +0 -81
  94. package/docs/variables/DORA_NODES.html +0 -81
  95. package/docs/variables/DORA_TRANSACTION.html +0 -81
  96. package/docs/variables/DORA_TRANSACTIONS.html +0 -81
  97. package/docs/variables/explorerOptions.html +0 -86
  98. package/docs/variables/gasInfoNeo3.html +0 -90
  99. 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,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 wallet.encrypt(account.key, password)
73
- const decryptedAccount = await bsNeo3.decrypt(encryptedKey, password)
74
- expect(account).toEqual(expect.objectContaining(decryptedAccount))
75
- }, 20000)
76
-
77
- it.skip('Should be able to calculate transfer fee', async () => {
78
- const account = bsNeo3.generateAccountFromKey(process.env.TESTNET_PRIVATE_KEY as string)
79
-
80
- const fee = await bsNeo3.calculateTransferFee({
81
- senderAccount: account,
82
- intent: {
83
- amount: '0.00000001',
84
- receiverAddress: 'NPRMF5bmYuW23DeDJqsDJenhXkAPSJyuYe',
85
- tokenHash: bsNeo3.feeToken.hash,
86
- tokenDecimals: bsNeo3.feeToken.decimals,
87
- },
88
- })
89
-
90
- expect(fee).toEqual({
91
- total: expect.any(Number),
92
- networkFee: expect.any(Number),
93
- systemFee: expect.any(Number),
94
- })
95
- })
96
-
97
- it.skip('Should be able to transfer', async () => {
98
- const account = bsNeo3.generateAccountFromKey(process.env.TESTNET_PRIVATE_KEY as string)
99
- const balance = await bsNeo3.blockchainDataService.getBalance(account.address)
100
- const gasBalance = balance.find(b => b.token.symbol === bsNeo3.feeToken.symbol)
101
- expect(Number(gasBalance?.amount)).toBeGreaterThan(0.00000001)
102
-
103
- const transactionHash = await bsNeo3.transfer({
104
- senderAccount: account,
105
- intent: {
106
- amount: '0.00000001',
107
- receiverAddress: 'NPRMF5bmYuW23DeDJqsDJenhXkAPSJyuYe',
108
- tokenHash: bsNeo3.feeToken.hash,
109
- tokenDecimals: bsNeo3.feeToken.decimals,
110
- },
111
- })
112
-
113
- expect(transactionHash).toEqual(expect.any(String))
114
- })
115
-
116
- it.skip('Should be able to claim', async () => {
117
- const account = bsNeo3.generateAccountFromKey(process.env.TESTNET_PRIVATE_KEY as string)
118
-
119
- const maxTries = 10
120
- let tries = 0
121
-
122
- while (tries < maxTries) {
123
- try {
124
- const unclaimed = await bsNeo3.blockchainDataService.getUnclaimed(account.address)
125
- if (Number(unclaimed) <= 0) continue
126
-
127
- const transactionHash = await bsNeo3.claim(account)
128
- expect(transactionHash).toEqual(expect.any(String))
129
- break
130
- } catch (error) {
131
- await sleep(4000)
132
- } finally {
133
- tries++
134
- }
135
- }
136
- }, 60000)
137
-
138
- it('Should be able to resolve a name service domain', async () => {
139
- const owner = await bsNeo3.resolveNameServiceDomain('neo.neo')
140
- expect(owner).toEqual('Nj39M97Rk2e23JiULBBMQmvpcnKaRHqxFf')
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 wallet.encrypt(account.key, password)
73
+ const decryptedAccount = await bsNeo3.decrypt(encryptedKey, password)
74
+ expect(account).toEqual(expect.objectContaining(decryptedAccount))
75
+ }, 20000)
76
+
77
+ it.skip('Should be able to calculate transfer fee', async () => {
78
+ const account = bsNeo3.generateAccountFromKey(process.env.TESTNET_PRIVATE_KEY as string)
79
+
80
+ const fee = await bsNeo3.calculateTransferFee({
81
+ senderAccount: account,
82
+ intent: {
83
+ amount: '0.00000001',
84
+ receiverAddress: 'NPRMF5bmYuW23DeDJqsDJenhXkAPSJyuYe',
85
+ tokenHash: bsNeo3.feeToken.hash,
86
+ tokenDecimals: bsNeo3.feeToken.decimals,
87
+ },
88
+ })
89
+
90
+ expect(fee).toEqual({
91
+ total: expect.any(Number),
92
+ networkFee: expect.any(Number),
93
+ systemFee: expect.any(Number),
94
+ })
95
+ })
96
+
97
+ it.skip('Should be able to transfer', async () => {
98
+ const account = bsNeo3.generateAccountFromKey(process.env.TESTNET_PRIVATE_KEY as string)
99
+ const balance = await bsNeo3.blockchainDataService.getBalance(account.address)
100
+ const gasBalance = balance.find(b => b.token.symbol === bsNeo3.feeToken.symbol)
101
+ expect(Number(gasBalance?.amount)).toBeGreaterThan(0.00000001)
102
+
103
+ const transactionHash = await bsNeo3.transfer({
104
+ senderAccount: account,
105
+ intent: {
106
+ amount: '0.00000001',
107
+ receiverAddress: 'NPRMF5bmYuW23DeDJqsDJenhXkAPSJyuYe',
108
+ tokenHash: bsNeo3.feeToken.hash,
109
+ tokenDecimals: bsNeo3.feeToken.decimals,
110
+ },
111
+ })
112
+
113
+ expect(transactionHash).toEqual(expect.any(String))
114
+ })
115
+
116
+ it.skip('Should be able to claim', async () => {
117
+ const account = bsNeo3.generateAccountFromKey(process.env.TESTNET_PRIVATE_KEY as string)
118
+
119
+ const maxTries = 10
120
+ let tries = 0
121
+
122
+ while (tries < maxTries) {
123
+ try {
124
+ const unclaimed = await bsNeo3.blockchainDataService.getUnclaimed(account.address)
125
+ if (Number(unclaimed) <= 0) continue
126
+
127
+ const transactionHash = await bsNeo3.claim(account)
128
+ expect(transactionHash).toEqual(expect.any(String))
129
+ break
130
+ } catch (error) {
131
+ await sleep(4000)
132
+ } finally {
133
+ tries++
134
+ }
135
+ }
136
+ }, 60000)
137
+
138
+ it('Should be able to resolve a name service domain', async () => {
139
+ const owner = await bsNeo3.resolveNameServiceDomain('neo.neo')
140
+ expect(owner).toEqual('Nj39M97Rk2e23JiULBBMQmvpcnKaRHqxFf')
141
+ })
142
+ })
@@ -0,0 +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,45 +1,48 @@
1
- import { FlamingoEDSNeo3 } from '../FlamingoEDSNeo3'
2
-
3
- let flamingoEDSNeo3: FlamingoEDSNeo3
4
-
5
- describe('FlamingoEDSNeo3', () => {
6
- beforeAll(() => {
7
- flamingoEDSNeo3 = new FlamingoEDSNeo3('mainnet')
8
- })
9
- it('Should return a list with prices of tokens using USD', async () => {
10
- const tokenPriceList = await flamingoEDSNeo3.getTokenPrices('USD')
11
-
12
- tokenPriceList.forEach(tokenPrice => {
13
- expect(tokenPrice).toEqual({
14
- price: expect.any(Number),
15
- symbol: expect.any(String),
16
- })
17
- })
18
- })
19
-
20
- it('Should return a list with prices of tokens using BRL', async () => {
21
- const tokenPriceListInUSD = await flamingoEDSNeo3.getTokenPrices('USD')
22
- const tokenPriceList = await flamingoEDSNeo3.getTokenPrices('BRL')
23
-
24
- tokenPriceList.forEach((tokenPrice, index) => {
25
- expect(tokenPrice.price).toBeGreaterThan(tokenPriceListInUSD[index].price)
26
- expect(tokenPrice).toEqual({
27
- price: expect.any(Number),
28
- symbol: expect.any(String),
29
- })
30
- })
31
- })
32
-
33
- it('Should return a list with prices of tokens using EUR', async () => {
34
- const tokenPriceListInUSD = await flamingoEDSNeo3.getTokenPrices('USD')
35
- const tokenPriceList = await flamingoEDSNeo3.getTokenPrices('EUR')
36
-
37
- tokenPriceList.forEach((tokenPrice, index) => {
38
- expect(tokenPrice.price).toBeLessThan(tokenPriceListInUSD[index].price)
39
- expect(tokenPrice).toEqual({
40
- price: expect.any(Number),
41
- symbol: expect.any(String),
42
- })
43
- })
44
- })
45
- })
1
+ import { FlamingoEDSNeo3 } from '../FlamingoEDSNeo3'
2
+
3
+ let flamingoEDSNeo3: FlamingoEDSNeo3
4
+
5
+ describe('FlamingoEDSNeo3', () => {
6
+ beforeAll(() => {
7
+ flamingoEDSNeo3 = new FlamingoEDSNeo3('mainnet')
8
+ })
9
+ it('Should return a list with prices of tokens using USD', async () => {
10
+ const tokenPriceList = await flamingoEDSNeo3.getTokenPrices('USD')
11
+
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 flamingoEDSNeo3.getTokenPrices('USD')
23
+ const tokenPriceList = await flamingoEDSNeo3.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 flamingoEDSNeo3.getTokenPrices('USD')
37
+ const tokenPriceList = await flamingoEDSNeo3.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
+ })