@cityofzion/bs-ethereum 1.1.0 → 1.2.1
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/dist/BSEthereum.d.ts +2 -2
- package/dist/BSEthereum.js +12 -7
- package/dist/BitqueryBDSEthereum.d.ts +2 -3
- package/dist/BitqueryBDSEthereum.js +34 -50
- package/dist/BitqueryEDSEthereum.d.ts +2 -3
- package/dist/BitqueryEDSEthereum.js +27 -27
- package/dist/GhostMarketNDSEthereum.d.ts +1 -1
- package/dist/GhostMarketNDSEthereum.js +23 -11
- package/dist/LedgerServiceEthereum.d.ts +4 -2
- package/dist/LedgerServiceEthereum.js +13 -5
- package/dist/RpcBDSEthereum.d.ts +1 -1
- package/dist/RpcBDSEthereum.js +21 -7
- package/dist/constants.d.ts +2 -2
- package/dist/constants.js +3 -3
- package/package.json +6 -5
- package/.eslintignore +0 -13
- package/.eslintrc.cjs +0 -22
- package/.rush/temp/operation/build/all.log +0 -1
- package/.rush/temp/operation/build/state.json +0 -3
- package/.rush/temp/package-deps_build.json +0 -30
- package/.rush/temp/shrinkwrap-deps.json +0 -531
- package/CHANGELOG.json +0 -126
- package/CHANGELOG.md +0 -68
- package/bs-ethereum.build.log +0 -1
- package/dist/graphql.d.ts +0 -124
- package/dist/graphql.js +0 -160
- package/jest.config.ts +0 -13
- package/jest.setup.ts +0 -1
- package/src/BSEthereum.ts +0 -208
- package/src/BitqueryBDSEthereum.ts +0 -231
- package/src/BitqueryEDSEthereum.ts +0 -67
- package/src/GhostMarketNDSEthereum.ts +0 -125
- package/src/LedgerServiceEthereum.ts +0 -44
- package/src/RpcBDSEthereum.ts +0 -88
- package/src/__tests__/BSEthereum.spec.ts +0 -172
- package/src/__tests__/BitqueryBDSEthereum.spec.ts +0 -106
- package/src/__tests__/BitqueryEDSEthereum.spec.ts +0 -55
- package/src/__tests__/GhostMarketNDSEthereum.spec.ts +0 -49
- package/src/__tests__/RpcBDSEthereum.spec.ts +0 -62
- package/src/assets/tokens/common.json +0 -8
- package/src/constants.ts +0 -36
- package/src/graphql.ts +0 -288
- package/src/index.ts +0 -6
- package/tsconfig.build.json +0 -4
- package/tsconfig.json +0 -15
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { ethers } from 'ethers'
|
|
2
|
-
import { BSEthereum } from '../BSEthereum'
|
|
3
|
-
import { Account } from '@cityofzion/blockchain-service'
|
|
4
|
-
import TransportNodeHid from '@ledgerhq/hw-transport-node-hid'
|
|
5
|
-
|
|
6
|
-
let bsEthereum: BSEthereum
|
|
7
|
-
let wallet: ethers.Wallet
|
|
8
|
-
let account: Account
|
|
9
|
-
|
|
10
|
-
describe('BSEthereum', () => {
|
|
11
|
-
beforeAll(() => {
|
|
12
|
-
bsEthereum = new BSEthereum('neo3', { type: 'testnet' }, process.env.BITQUERY_API_KEY as string)
|
|
13
|
-
wallet = ethers.Wallet.createRandom()
|
|
14
|
-
account = {
|
|
15
|
-
key: wallet.privateKey,
|
|
16
|
-
type: 'privateKey',
|
|
17
|
-
address: wallet.address,
|
|
18
|
-
}
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
it('Should be able to validate an address', () => {
|
|
22
|
-
const validAddress = '0xD81a8F3c3f8b006Ef1ae4a2Fd28699AD7E3e21C5'
|
|
23
|
-
const invalidAddress = 'invalid address'
|
|
24
|
-
|
|
25
|
-
expect(bsEthereum.validateAddress(validAddress)).toBeTruthy()
|
|
26
|
-
expect(bsEthereum.validateAddress(invalidAddress)).toBeFalsy()
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('Should be able to validate an encrypted key', async () => {
|
|
30
|
-
const validEncryptedJson = await wallet.encrypt('password')
|
|
31
|
-
const invalidEncryptedJson = '{ invalid: json }'
|
|
32
|
-
|
|
33
|
-
expect(bsEthereum.validateEncrypted(validEncryptedJson)).toBeTruthy()
|
|
34
|
-
expect(bsEthereum.validateEncrypted(invalidEncryptedJson)).toBeFalsy()
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('Should be able to validate a private key', () => {
|
|
38
|
-
const validKey = wallet.privateKey
|
|
39
|
-
const invalidKey = 'invalid key'
|
|
40
|
-
|
|
41
|
-
expect(bsEthereum.validateKey(validKey)).toBeTruthy()
|
|
42
|
-
expect(bsEthereum.validateKey(invalidKey)).toBeFalsy()
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('Should be able to validate an domain', () => {
|
|
46
|
-
const validDomain = 'alice.eth'
|
|
47
|
-
const invalidDomain = 'invalid domain'
|
|
48
|
-
|
|
49
|
-
expect(bsEthereum.validateNameServiceDomainFormat(validDomain)).toBeTruthy()
|
|
50
|
-
expect(bsEthereum.validateNameServiceDomainFormat(invalidDomain)).toBeFalsy()
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
it('Should be able to generate a account from mnemonic', () => {
|
|
54
|
-
const account = bsEthereum.generateAccountFromMnemonic(wallet.mnemonic.phrase, 0)
|
|
55
|
-
|
|
56
|
-
expect(bsEthereum.validateAddress(account.address)).toBeTruthy()
|
|
57
|
-
expect(bsEthereum.validateKey(account.key)).toBeTruthy()
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it('Should be able to generate a account from wif', () => {
|
|
61
|
-
const accountFromWif = bsEthereum.generateAccountFromKey(wallet.privateKey)
|
|
62
|
-
expect(accountFromWif).toEqual(account)
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
it('Should be able to decrypt a encrypted key', async () => {
|
|
66
|
-
const password = 'TestPassword'
|
|
67
|
-
const validEncryptedJson = await bsEthereum.encrypt(wallet.privateKey, password)
|
|
68
|
-
const decryptedAccount = await bsEthereum.decrypt(validEncryptedJson, password)
|
|
69
|
-
expect(decryptedAccount).toEqual(account)
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
it('Should be able to encrypt key', async () => {
|
|
73
|
-
const password = 'TestPassword'
|
|
74
|
-
const validEncryptedJson = await bsEthereum.encrypt(wallet.privateKey, password)
|
|
75
|
-
expect(JSON.parse(validEncryptedJson)).toEqual(
|
|
76
|
-
expect.objectContaining({ address: wallet.address.replace('0x', '').toLowerCase() })
|
|
77
|
-
)
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
it.skip('Should be able to calculate transfer fee', async () => {
|
|
81
|
-
const account = bsEthereum.generateAccountFromKey(process.env.TESTNET_PRIVATE_KEY as string)
|
|
82
|
-
|
|
83
|
-
const fee = await bsEthereum.calculateTransferFee({
|
|
84
|
-
senderAccount: account,
|
|
85
|
-
intent: {
|
|
86
|
-
amount: '0.1',
|
|
87
|
-
receiverAddress: '0xFACf5446B71dB33E920aB1769d9427146183aEcd',
|
|
88
|
-
tokenDecimals: 18,
|
|
89
|
-
tokenHash: '0xBA62BCfcAaFc6622853cca2BE6Ac7d845BC0f2Dc',
|
|
90
|
-
},
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
expect(fee).toEqual(expect.any(String))
|
|
94
|
-
}, 50000)
|
|
95
|
-
|
|
96
|
-
it.skip('Should be able to transfer a native token', async () => {
|
|
97
|
-
const account = bsEthereum.generateAccountFromKey(process.env.TESTNET_PRIVATE_KEY as string)
|
|
98
|
-
|
|
99
|
-
const transactionHash = await bsEthereum.transfer({
|
|
100
|
-
senderAccount: account,
|
|
101
|
-
intent: {
|
|
102
|
-
amount: '0.00000001',
|
|
103
|
-
receiverAddress: '0xFACf5446B71dB33E920aB1769d9427146183aEcd',
|
|
104
|
-
tokenDecimals: 18,
|
|
105
|
-
tokenHash: '-',
|
|
106
|
-
},
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
expect(transactionHash).toEqual(expect.any(String))
|
|
110
|
-
}, 50000)
|
|
111
|
-
|
|
112
|
-
it.skip('Should be able to transfer a ERC20 token', async () => {
|
|
113
|
-
const account = bsEthereum.generateAccountFromKey(process.env.TESTNET_PRIVATE_KEY as string)
|
|
114
|
-
|
|
115
|
-
const transactionHash = await bsEthereum.transfer({
|
|
116
|
-
senderAccount: account,
|
|
117
|
-
intent: {
|
|
118
|
-
amount: '0.00000001',
|
|
119
|
-
receiverAddress: '0xFACf5446B71dB33E920aB1769d9427146183aEcd',
|
|
120
|
-
tokenDecimals: 18,
|
|
121
|
-
tokenHash: '0xba62bcfcaafc6622853cca2be6ac7d845bc0f2dc',
|
|
122
|
-
},
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
expect(transactionHash).toEqual(expect.any(String))
|
|
126
|
-
}, 50000)
|
|
127
|
-
|
|
128
|
-
it.skip('Should be able to transfer a native token with ledger', async () => {
|
|
129
|
-
const transport = await TransportNodeHid.create()
|
|
130
|
-
const publicKey = await bsEthereum.ledgerService.getPublicKey(transport)
|
|
131
|
-
const account = bsEthereum.generateAccountFromPublicKey(publicKey)
|
|
132
|
-
|
|
133
|
-
const transactionHash = await bsEthereum.transfer({
|
|
134
|
-
senderAccount: account,
|
|
135
|
-
intent: {
|
|
136
|
-
amount: '0.00000001',
|
|
137
|
-
receiverAddress: '0x82B5Cd984880C8A821429cFFf89f36D35BaeBE89',
|
|
138
|
-
tokenDecimals: 18,
|
|
139
|
-
tokenHash: '-',
|
|
140
|
-
},
|
|
141
|
-
isLedger: true,
|
|
142
|
-
ledgerTransport: transport,
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
expect(transactionHash).toEqual(expect.any(String))
|
|
146
|
-
}, 50000)
|
|
147
|
-
|
|
148
|
-
it.skip('Should be able to transfer a ERC20 token with ledger', async () => {
|
|
149
|
-
const transport = await TransportNodeHid.create()
|
|
150
|
-
const publicKey = await bsEthereum.ledgerService.getPublicKey(transport)
|
|
151
|
-
const account = bsEthereum.generateAccountFromPublicKey(publicKey)
|
|
152
|
-
|
|
153
|
-
const transactionHash = await bsEthereum.transfer({
|
|
154
|
-
senderAccount: account,
|
|
155
|
-
intent: {
|
|
156
|
-
amount: '0.00000001',
|
|
157
|
-
receiverAddress: '0x82B5Cd984880C8A821429cFFf89f36D35BaeBE89',
|
|
158
|
-
tokenDecimals: 18,
|
|
159
|
-
tokenHash: '0xcf185f2F3Fe19D82bFdcee59E3330FD7ba5f27ce',
|
|
160
|
-
},
|
|
161
|
-
isLedger: true,
|
|
162
|
-
ledgerTransport: transport,
|
|
163
|
-
})
|
|
164
|
-
|
|
165
|
-
expect(transactionHash).toEqual(expect.any(String))
|
|
166
|
-
}, 50000)
|
|
167
|
-
|
|
168
|
-
it('Should be able to resolve a name service domain', async () => {
|
|
169
|
-
const address = await bsEthereum.resolveNameServiceDomain('alice.eth')
|
|
170
|
-
expect(address).toEqual('0xa974890156A3649A23a6C0f2ebd77D6F7A7333d4')
|
|
171
|
-
}, 10000)
|
|
172
|
-
})
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { BitqueryBDSEthereum } from '../BitqueryBDSEthereum'
|
|
2
|
-
import { DEFAULT_URL_BY_NETWORK_TYPE } from '../constants'
|
|
3
|
-
|
|
4
|
-
const bitqueryBDSEthereum = new BitqueryBDSEthereum(
|
|
5
|
-
{ type: 'testnet', url: DEFAULT_URL_BY_NETWORK_TYPE.testnet },
|
|
6
|
-
process.env.BITQUERY_API_KEY as string
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
describe('BitqueryBDSEthereum', () => {
|
|
10
|
-
it('Should be able to get transaction - %s', async () => {
|
|
11
|
-
const hash = '0x43fa3015d077a13888409cfbd6228df8900abcd5314ff11ea6ce0c49e8b7c94d'
|
|
12
|
-
const transaction = await bitqueryBDSEthereum.getTransaction(hash)
|
|
13
|
-
|
|
14
|
-
expect(transaction).toEqual(
|
|
15
|
-
expect.objectContaining({
|
|
16
|
-
block: expect.any(Number),
|
|
17
|
-
hash,
|
|
18
|
-
notifications: [],
|
|
19
|
-
time: expect.any(Number),
|
|
20
|
-
})
|
|
21
|
-
)
|
|
22
|
-
transaction.transfers.forEach(transfer => {
|
|
23
|
-
expect(transfer).toEqual(
|
|
24
|
-
expect.objectContaining({
|
|
25
|
-
from: expect.any(String),
|
|
26
|
-
to: expect.any(String),
|
|
27
|
-
contractHash: expect.any(String),
|
|
28
|
-
amount: expect.any(String),
|
|
29
|
-
type: expect.any(String),
|
|
30
|
-
})
|
|
31
|
-
)
|
|
32
|
-
})
|
|
33
|
-
}, 10000)
|
|
34
|
-
|
|
35
|
-
it('Should be able to get transactions of address - %s', async () => {
|
|
36
|
-
const address = '0x82B5Cd984880C8A821429cFFf89f36D35BaeBE89'
|
|
37
|
-
const response = await bitqueryBDSEthereum.getTransactionsByAddress({ address: address, page: 1 })
|
|
38
|
-
expect(response.totalCount).toBeGreaterThan(0)
|
|
39
|
-
response.transactions.forEach(transaction => {
|
|
40
|
-
expect(transaction).toEqual(
|
|
41
|
-
expect.objectContaining({
|
|
42
|
-
block: expect.any(Number),
|
|
43
|
-
hash: expect.any(String),
|
|
44
|
-
notifications: [],
|
|
45
|
-
time: expect.any(Number),
|
|
46
|
-
fee: expect.any(String),
|
|
47
|
-
})
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
transaction.transfers.forEach(transfer => {
|
|
51
|
-
expect(transfer).toEqual(
|
|
52
|
-
expect.objectContaining({
|
|
53
|
-
from: expect.any(String),
|
|
54
|
-
to: expect.any(String),
|
|
55
|
-
contractHash: expect.any(String),
|
|
56
|
-
amount: expect.any(String),
|
|
57
|
-
type: expect.any(String),
|
|
58
|
-
})
|
|
59
|
-
)
|
|
60
|
-
})
|
|
61
|
-
})
|
|
62
|
-
}, 10000)
|
|
63
|
-
|
|
64
|
-
it('Should be able to get eth info - %s', async () => {
|
|
65
|
-
const hash = '-'
|
|
66
|
-
const token = await bitqueryBDSEthereum.getTokenInfo(hash)
|
|
67
|
-
|
|
68
|
-
expect(token).toEqual({
|
|
69
|
-
symbol: 'ETH',
|
|
70
|
-
name: 'Ethereum',
|
|
71
|
-
hash: '-',
|
|
72
|
-
decimals: 18,
|
|
73
|
-
})
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
it('Should be able to get token info - %s', async () => {
|
|
77
|
-
const hash = '0xBA62BCfcAaFc6622853cca2BE6Ac7d845BC0f2Dc'
|
|
78
|
-
const token = await bitqueryBDSEthereum.getTokenInfo(hash)
|
|
79
|
-
|
|
80
|
-
expect(token).toEqual({
|
|
81
|
-
hash: '0xba62bcfcaafc6622853cca2be6ac7d845bc0f2dc',
|
|
82
|
-
name: 'FaucetToken',
|
|
83
|
-
symbol: 'FAU',
|
|
84
|
-
decimals: 18,
|
|
85
|
-
})
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
it('Should be able to get balance - %s', async () => {
|
|
89
|
-
const address = '0x82B5Cd984880C8A821429cFFf89f36D35BaeBE89'
|
|
90
|
-
const balance = await bitqueryBDSEthereum.getBalance(address)
|
|
91
|
-
|
|
92
|
-
balance.forEach(balance => {
|
|
93
|
-
expect(balance).toEqual(
|
|
94
|
-
expect.objectContaining({
|
|
95
|
-
amount: expect.any(String),
|
|
96
|
-
token: {
|
|
97
|
-
hash: expect.any(String),
|
|
98
|
-
name: expect.any(String),
|
|
99
|
-
symbol: expect.any(String),
|
|
100
|
-
decimals: expect.any(Number),
|
|
101
|
-
},
|
|
102
|
-
})
|
|
103
|
-
)
|
|
104
|
-
})
|
|
105
|
-
})
|
|
106
|
-
})
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { BitqueryEDSEthereum } from '../BitqueryEDSEthereum'
|
|
2
|
-
|
|
3
|
-
let bitqueryEDSEthereum: BitqueryEDSEthereum
|
|
4
|
-
|
|
5
|
-
describe('FlamingoEDSNeo3', () => {
|
|
6
|
-
beforeAll(() => {
|
|
7
|
-
bitqueryEDSEthereum = new BitqueryEDSEthereum('mainnet', process.env.BITQUERY_API_KEY as string)
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
it('Should return a list with prices of tokens using USD', async () => {
|
|
11
|
-
const tokenPriceList = await bitqueryEDSEthereum.getTokenPrices('USD')
|
|
12
|
-
|
|
13
|
-
tokenPriceList.forEach(tokenPrice => {
|
|
14
|
-
expect(tokenPrice).toEqual({
|
|
15
|
-
price: expect.any(Number),
|
|
16
|
-
symbol: expect.any(String),
|
|
17
|
-
hash: expect.any(String),
|
|
18
|
-
})
|
|
19
|
-
})
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
it('Should return a list with prices of tokens using BRL', async () => {
|
|
23
|
-
const tokenPriceListInUSD = await bitqueryEDSEthereum.getTokenPrices('USD')
|
|
24
|
-
const tokenPriceList = await bitqueryEDSEthereum.getTokenPrices('BRL')
|
|
25
|
-
|
|
26
|
-
tokenPriceList.forEach((tokenPrice, index) => {
|
|
27
|
-
expect(tokenPrice.price).toBeGreaterThan(tokenPriceListInUSD[index].price)
|
|
28
|
-
expect(tokenPrice).toEqual({
|
|
29
|
-
price: expect.any(Number),
|
|
30
|
-
symbol: expect.any(String),
|
|
31
|
-
hash: expect.any(String),
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it('Should return a list with prices of tokens using EUR', async () => {
|
|
37
|
-
const tokenPriceListInUSD = await bitqueryEDSEthereum.getTokenPrices('USD')
|
|
38
|
-
const tokenPriceList = await bitqueryEDSEthereum.getTokenPrices('EUR')
|
|
39
|
-
|
|
40
|
-
tokenPriceList.forEach((tokenPrice, index) => {
|
|
41
|
-
expect(tokenPrice.price).toBeLessThan(tokenPriceListInUSD[index].price)
|
|
42
|
-
expect(tokenPrice).toEqual({
|
|
43
|
-
price: expect.any(Number),
|
|
44
|
-
symbol: expect.any(String),
|
|
45
|
-
hash: expect.any(String),
|
|
46
|
-
})
|
|
47
|
-
})
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it('Should return the ETH price in USD', async () => {
|
|
51
|
-
const tokenPriceList = await bitqueryEDSEthereum.getTokenPrices('USD')
|
|
52
|
-
|
|
53
|
-
expect(tokenPriceList).toEqual(expect.arrayContaining([{ symbol: 'ETH', hash: '-', price: expect.any(Number) }]))
|
|
54
|
-
})
|
|
55
|
-
})
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { GhostMarketNDSEthereum } from '../GhostMarketNDSEthereum'
|
|
2
|
-
|
|
3
|
-
let ghostMarketNDSEthereum: GhostMarketNDSEthereum
|
|
4
|
-
|
|
5
|
-
describe('GhostMarketNDSEthereum', () => {
|
|
6
|
-
beforeAll(() => {
|
|
7
|
-
ghostMarketNDSEthereum = new GhostMarketNDSEthereum('mainnet')
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
it('Get NFT', async () => {
|
|
11
|
-
const nft = await ghostMarketNDSEthereum.getNft({
|
|
12
|
-
contractHash: '0xeb3a9a839dfeeaf71db1b4ed6a8ae0ccb171b227',
|
|
13
|
-
tokenId: '379',
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
expect(nft).toEqual(
|
|
17
|
-
expect.objectContaining({
|
|
18
|
-
id: '379',
|
|
19
|
-
contractHash: '0xeb3a9a839dfeeaf71db1b4ed6a8ae0ccb171b227',
|
|
20
|
-
symbol: 'MOAR',
|
|
21
|
-
collectionImage: expect.any(String),
|
|
22
|
-
collectionName: '"MOAR" by Joan Cornella',
|
|
23
|
-
image: expect.any(String),
|
|
24
|
-
isSVG: expect.any(Boolean),
|
|
25
|
-
name: 'MOAR #379',
|
|
26
|
-
creator: {
|
|
27
|
-
address: '0xd71ef31e9d4e8674d9177c28cc2d0d633580615b',
|
|
28
|
-
name: undefined,
|
|
29
|
-
},
|
|
30
|
-
})
|
|
31
|
-
)
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
it('Get NFTS by address', async () => {
|
|
35
|
-
const nfts = await ghostMarketNDSEthereum.getNftsByAddress({
|
|
36
|
-
address: '0xd773c81a4a855556ce2f2372b12272710b95b26c',
|
|
37
|
-
})
|
|
38
|
-
expect(nfts.items.length).toBeGreaterThan(0)
|
|
39
|
-
nfts.items.forEach(nft => {
|
|
40
|
-
expect(nft).toEqual(
|
|
41
|
-
expect.objectContaining({
|
|
42
|
-
symbol: expect.any(String),
|
|
43
|
-
id: expect.any(String),
|
|
44
|
-
contractHash: expect.any(String),
|
|
45
|
-
})
|
|
46
|
-
)
|
|
47
|
-
})
|
|
48
|
-
})
|
|
49
|
-
})
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { RpcBDSEthereum } from '../RpcBDSEthereum'
|
|
2
|
-
import { DEFAULT_URL_BY_NETWORK_TYPE } from '../constants'
|
|
3
|
-
|
|
4
|
-
const rpcBDSEthereum = new RpcBDSEthereum({ type: 'testnet', url: DEFAULT_URL_BY_NETWORK_TYPE.testnet })
|
|
5
|
-
|
|
6
|
-
describe('RpcBDSEthereum', () => {
|
|
7
|
-
it('Should be able to get transaction', async () => {
|
|
8
|
-
const hash = '0x48eac645fac2280d7ac89a319372d7a38d52516f8b3003574bfaaed31b471ff3'
|
|
9
|
-
const transaction = await rpcBDSEthereum.getTransaction(hash)
|
|
10
|
-
|
|
11
|
-
expect(transaction).toEqual(
|
|
12
|
-
expect.objectContaining({
|
|
13
|
-
block: expect.any(Number),
|
|
14
|
-
hash,
|
|
15
|
-
notifications: [],
|
|
16
|
-
time: expect.any(Number),
|
|
17
|
-
})
|
|
18
|
-
)
|
|
19
|
-
transaction.transfers.forEach(transfer => {
|
|
20
|
-
expect(transfer).toEqual(
|
|
21
|
-
expect.objectContaining({
|
|
22
|
-
from: expect.any(String),
|
|
23
|
-
to: expect.any(String),
|
|
24
|
-
contractHash: expect.any(String),
|
|
25
|
-
amount: expect.any(String),
|
|
26
|
-
type: expect.any(String),
|
|
27
|
-
})
|
|
28
|
-
)
|
|
29
|
-
})
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
it('Should be able to get eth info', async () => {
|
|
33
|
-
const hash = '-'
|
|
34
|
-
const token = await rpcBDSEthereum.getTokenInfo(hash)
|
|
35
|
-
|
|
36
|
-
expect(token).toEqual({
|
|
37
|
-
symbol: 'ETH',
|
|
38
|
-
name: 'Ethereum',
|
|
39
|
-
hash: '-',
|
|
40
|
-
decimals: 18,
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
it('Should be able to get balance', async () => {
|
|
45
|
-
const address = '0xbA65F285D1F9E0bf76Ab01211547979a3b60011A'
|
|
46
|
-
const balance = await rpcBDSEthereum.getBalance(address)
|
|
47
|
-
|
|
48
|
-
balance.forEach(balance => {
|
|
49
|
-
expect(balance).toEqual(
|
|
50
|
-
expect.objectContaining({
|
|
51
|
-
amount: expect.any(String),
|
|
52
|
-
token: {
|
|
53
|
-
hash: expect.any(String),
|
|
54
|
-
name: expect.any(String),
|
|
55
|
-
symbol: expect.any(String),
|
|
56
|
-
decimals: expect.any(Number),
|
|
57
|
-
},
|
|
58
|
-
})
|
|
59
|
-
)
|
|
60
|
-
})
|
|
61
|
-
})
|
|
62
|
-
})
|
package/src/constants.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { NetworkType, Token } from '@cityofzion/blockchain-service'
|
|
2
|
-
import commom from './assets/tokens/common.json'
|
|
3
|
-
|
|
4
|
-
export type BitqueryNetwork = 'ethereum' | 'goerli'
|
|
5
|
-
|
|
6
|
-
export const TOKENS: Record<NetworkType, Token[]> = {
|
|
7
|
-
mainnet: [...commom],
|
|
8
|
-
testnet: commom,
|
|
9
|
-
custom: commom,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const NATIVE_ASSETS = commom
|
|
13
|
-
|
|
14
|
-
export const DEFAULT_URL_BY_NETWORK_TYPE: Record<NetworkType, string> = {
|
|
15
|
-
mainnet: 'https://ethereum-mainnet-rpc.allthatnode.com',
|
|
16
|
-
testnet: 'https://ethereum-sepolia-rpc.publicnode.com',
|
|
17
|
-
custom: 'http://127.0.0.1:8545',
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const BITQUERY_URL = 'https://graphql.bitquery.io'
|
|
21
|
-
export const BITQUERY_NETWORK_BY_NETWORK_TYPE: Record<Exclude<NetworkType, 'custom'>, BitqueryNetwork> = {
|
|
22
|
-
mainnet: 'ethereum',
|
|
23
|
-
testnet: 'goerli',
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const GHOSTMARKET_URL_BY_NETWORK_TYPE: Partial<Record<NetworkType, string>> = {
|
|
27
|
-
mainnet: 'https://api.ghostmarket.io/api/v2',
|
|
28
|
-
testnet: 'https://api-testnet.ghostmarket.io/api/v2',
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const GHOSTMARKET_CHAIN_BY_NETWORK_TYPE: Partial<Record<NetworkType, string>> = {
|
|
32
|
-
mainnet: 'eth',
|
|
33
|
-
testnet: 'etht',
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export const DERIVATION_PATH = "m/44'/60'/0'/0/?"
|