-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from CityOfZion/CU-86dt261uc
CU-86dt261uc - Adjust NWM to use ETH RPC when running TESTNET (Temp fix while we migrate to BitQuery v2)
- Loading branch information
Showing
6 changed files
with
180 additions
and
128 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
common/changes/@cityofzion/bs-ethereum/CU-86dt261uc_2024-03-25-16-25.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@cityofzion/bs-ethereum", | ||
"comment": "Change Goerli to Sepolia and call RPC using testnet instead of Bitquery", | ||
"type": "patch" | ||
} | ||
], | ||
"packageName": "@cityofzion/bs-ethereum" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
106 changes: 106 additions & 0 deletions
106
packages/bs-ethereum/src/__tests__/BitqueryBDSEthereum.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import { BitqueryBDSEthereum } from '../BitqueryBDSEthereum' | ||
import { DEFAULT_URL_BY_NETWORK_TYPE } from '../constants' | ||
|
||
const bitqueryBDSEthereum = new BitqueryBDSEthereum( | ||
{ type: 'testnet', url: DEFAULT_URL_BY_NETWORK_TYPE.testnet }, | ||
process.env.BITQUERY_API_KEY as string | ||
) | ||
|
||
describe('BitqueryBDSEthereum', () => { | ||
it('Should be able to get transaction - %s', async () => { | ||
const hash = '0x43fa3015d077a13888409cfbd6228df8900abcd5314ff11ea6ce0c49e8b7c94d' | ||
const transaction = await bitqueryBDSEthereum.getTransaction(hash) | ||
|
||
expect(transaction).toEqual( | ||
expect.objectContaining({ | ||
block: expect.any(Number), | ||
hash, | ||
notifications: [], | ||
time: expect.any(Number), | ||
}) | ||
) | ||
transaction.transfers.forEach(transfer => { | ||
expect(transfer).toEqual( | ||
expect.objectContaining({ | ||
from: expect.any(String), | ||
to: expect.any(String), | ||
contractHash: expect.any(String), | ||
amount: expect.any(String), | ||
type: expect.any(String), | ||
}) | ||
) | ||
}) | ||
}, 10000) | ||
|
||
it('Should be able to get transactions of address - %s', async () => { | ||
const address = '0x82B5Cd984880C8A821429cFFf89f36D35BaeBE89' | ||
const response = await bitqueryBDSEthereum.getTransactionsByAddress({ address: address, page: 1 }) | ||
expect(response.totalCount).toBeGreaterThan(0) | ||
response.transactions.forEach(transaction => { | ||
expect(transaction).toEqual( | ||
expect.objectContaining({ | ||
block: expect.any(Number), | ||
hash: expect.any(String), | ||
notifications: [], | ||
time: expect.any(Number), | ||
fee: expect.any(String), | ||
}) | ||
) | ||
|
||
transaction.transfers.forEach(transfer => { | ||
expect(transfer).toEqual( | ||
expect.objectContaining({ | ||
from: expect.any(String), | ||
to: expect.any(String), | ||
contractHash: expect.any(String), | ||
amount: expect.any(String), | ||
type: expect.any(String), | ||
}) | ||
) | ||
}) | ||
}) | ||
}, 10000) | ||
|
||
it('Should be able to get eth info - %s', async () => { | ||
const hash = '-' | ||
const token = await bitqueryBDSEthereum.getTokenInfo(hash) | ||
|
||
expect(token).toEqual({ | ||
symbol: 'ETH', | ||
name: 'Ethereum', | ||
hash: '-', | ||
decimals: 18, | ||
}) | ||
}) | ||
|
||
it('Should be able to get token info - %s', async () => { | ||
const hash = '0xBA62BCfcAaFc6622853cca2BE6Ac7d845BC0f2Dc' | ||
const token = await bitqueryBDSEthereum.getTokenInfo(hash) | ||
|
||
expect(token).toEqual({ | ||
hash: '0xba62bcfcaafc6622853cca2be6ac7d845bc0f2dc', | ||
name: 'FaucetToken', | ||
symbol: 'FAU', | ||
decimals: 18, | ||
}) | ||
}) | ||
|
||
it('Should be able to get balance - %s', async () => { | ||
const address = '0x82B5Cd984880C8A821429cFFf89f36D35BaeBE89' | ||
const balance = await bitqueryBDSEthereum.getBalance(address) | ||
|
||
balance.forEach(balance => { | ||
expect(balance).toEqual( | ||
expect.objectContaining({ | ||
amount: expect.any(String), | ||
token: { | ||
hash: expect.any(String), | ||
name: expect.any(String), | ||
symbol: expect.any(String), | ||
decimals: expect.any(Number), | ||
}, | ||
}) | ||
) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { RpcBDSEthereum } from '../RpcBDSEthereum' | ||
import { DEFAULT_URL_BY_NETWORK_TYPE } from '../constants' | ||
|
||
const rpcBDSEthereum = new RpcBDSEthereum({ type: 'testnet', url: DEFAULT_URL_BY_NETWORK_TYPE.testnet }) | ||
|
||
describe('RpcBDSEthereum', () => { | ||
it('Should be able to get transaction', async () => { | ||
const hash = '0x48eac645fac2280d7ac89a319372d7a38d52516f8b3003574bfaaed31b471ff3' | ||
const transaction = await rpcBDSEthereum.getTransaction(hash) | ||
|
||
expect(transaction).toEqual( | ||
expect.objectContaining({ | ||
block: expect.any(Number), | ||
hash, | ||
notifications: [], | ||
time: expect.any(Number), | ||
}) | ||
) | ||
transaction.transfers.forEach(transfer => { | ||
expect(transfer).toEqual( | ||
expect.objectContaining({ | ||
from: expect.any(String), | ||
to: expect.any(String), | ||
contractHash: expect.any(String), | ||
amount: expect.any(String), | ||
type: expect.any(String), | ||
}) | ||
) | ||
}) | ||
}) | ||
|
||
it('Should be able to get eth info', async () => { | ||
const hash = '-' | ||
const token = await rpcBDSEthereum.getTokenInfo(hash) | ||
|
||
expect(token).toEqual({ | ||
symbol: 'ETH', | ||
name: 'Ethereum', | ||
hash: '-', | ||
decimals: 18, | ||
}) | ||
}) | ||
|
||
it('Should be able to get balance', async () => { | ||
const address = '0xbA65F285D1F9E0bf76Ab01211547979a3b60011A' | ||
const balance = await rpcBDSEthereum.getBalance(address) | ||
|
||
balance.forEach(balance => { | ||
expect(balance).toEqual( | ||
expect.objectContaining({ | ||
amount: expect.any(String), | ||
token: { | ||
hash: expect.any(String), | ||
name: expect.any(String), | ||
symbol: expect.any(String), | ||
decimals: expect.any(Number), | ||
}, | ||
}) | ||
) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters