Skip to content

Commit

Permalink
feat(api): add BOBA price feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommytrg committed Sep 10, 2021
1 parent 087372f commit af36b2f
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/api/sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ ETHEREUM_RINKEBY_PROVIDER=https://rinkeby.infura.io/v3/<TOKEN>
ETHEREUM_MAINNET_PROVIDER=https://mainnet.infura.io/v3/<TOKEN>
CONFLUX_MAINNET_PROVIDER=url
CONFLUX_TESTNET_PROVIDER=url
BOBA_RINKEBY_PROVIDER=url
DATA_FEED_CONFIG_PATH=/dataFeeds.json
35 changes: 34 additions & 1 deletion packages/api/src/dataFeeds.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,38 @@
"pollingPeriod": 15000,
"color": "#be4141de",
"blockExplorer": "https://testnet.confluxscan.io/address/{address}"
},
{
"feedFullName": "boba-rinkeby_omg-btc_9",
"abi": "./src/abi/PriceFeed.json",
"address": "0x74fcc16D8d17BCF9D2b5028a345b398449BEe63f",
"network": "boba-rinkeby",
"name": "omg/btc",
"label": "$",
"pollingPeriod": 120000,
"color": "#1cd8d2",
"blockExplorer": "https://blockexplorer.rinkeby.boba.network/address/{address}/transactions"
},
{
"feedFullName": "boba-rinkeby_omg-eth_9",
"abi": "./src/abi/PriceFeed.json",
"address": "0x904D5786ab5C21726e7b324487a4Adf57BC9Cd1c",
"network": "boba-rinkeby",
"name": "omg/eth",
"label": "$",
"pollingPeriod": 120000,
"color": "#1cd8d2",
"blockExplorer": "https://blockexplorer.rinkeby.boba.network/address/{address}/transactions"
},
{
"feedFullName": "boba-rinkeby_omg-usdt_6",
"abi": "./src/abi/PriceFeed.json",
"address": "0x1553c2F110C443FA485E233DAa611243fC2f4A47",
"network": "boba-rinkeby",
"name": "omg/usdt",
"label": "$",
"pollingPeriod": 120000,
"color": "#1cd8d2",
"blockExplorer": "https://blockexplorer.rinkeby.boba.network/address/{address}/transactions"
}
]
]
3 changes: 2 additions & 1 deletion packages/api/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export enum Network {
EthereumKovan = 'ethereum-kovan',
EthereumRinkeby = 'ethereum-rinkeby',
ConfluxTestnet = 'conflux-testnet',
ConfluxMainnet = 'conflux-mainnet'
ConfluxMainnet = 'conflux-mainnet',
BobaRinkeby = 'boba-rinkeby'
}

export type FeedInfoGeneric<ABI> = {
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/web3Middleware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export class Web3Middleware {

listenToDataFeed (feedInfo: FeedInfo, feedId: ObjectId) {
const provider = getProvider(feedInfo.network)
console.log('provider', provider)
const web3 = new this.Web3(provider)
const feedContract = new web3.eth.Contract(feedInfo.abi, feedInfo.address)
const interval = setInterval(async () => {
Expand Down
6 changes: 4 additions & 2 deletions packages/api/src/web3Middleware/provider.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { Network } from './../types'

export function getProvider (network: Network) {
console.log('network', network)
const providers: Record<Network, string> = {
[Network.EthereumMainnet]: process.env.ETHEREUM_MAINNET_PROVIDER,
[Network.EthereumGoerli]: process.env.ETHEREUM_GOERLI_PROVIDER,
[Network.EthereumKovan]: process.env.ETHEREUM_KOVAN_PROVIDER,
[Network.EthereumRinkeby]: process.env.ETHEREUM_RINKEBY_PROVIDER,
[Network.ConfluxTestnet]: process.env.CONFLUX_TESTNET_PROVIDER,
[Network.ConfluxMainnet]: process.env.CONFLUX_MAINNET_PROVIDER
[Network.ConfluxMainnet]: process.env.CONFLUX_MAINNET_PROVIDER,
[Network.BobaRinkeby]: process.env.BOBA_RINKEBY_PROVIDER
}

console.log('provider', network, providers[network])
return providers[network]
}
8 changes: 8 additions & 0 deletions packages/ui/assets/svg/omgbtc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions packages/ui/assets/svg/omgeth.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions packages/ui/assets/svg/omgusdt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/ui/components/Chart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default {
required: true,
},
decimals: {
type: Number,
type: String,
required: true,
},
},
Expand Down
1 change: 1 addition & 0 deletions sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ ETHEREUM_RINKEBY_PROVIDER=https://rinkeby.infura.io/v3/<token>
ETHEREUM_MAINNET_PROVIDER=https://mainnet.infura.io/v3/<token>
CONFLUX_MAINNET_PROVIDER=url
CONFLUX_MAINNET_TESTNET=url
BOBA_RINKEBY_PROVIDER=url
API_ENDPOINT="http://api:4000"

0 comments on commit af36b2f

Please sign in to comment.