mirror of
https://github.com/kremalicious/blowfish.git
synced 2024-11-21 09:16:57 +01:00
get balance from chain
This commit is contained in:
parent
26df59c687
commit
41fda20563
@ -1 +1,2 @@
|
||||
ETHERSCAN_API_KEY=
|
||||
ETHERSCAN_API_KEY=
|
||||
INFURA_PROJECT_ID=
|
@ -30,13 +30,14 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@coingecko/cryptoformat": "^0.3.4",
|
||||
"@oceanprotocol/keeper-contracts": "^0.13.2",
|
||||
"axios": "^0.19.2",
|
||||
"electron-is-dev": "^1.1.0",
|
||||
"electron-next": "^3.1.5",
|
||||
"electron-store": "^5.1.1",
|
||||
"ethereum-address": "^0.0.4",
|
||||
"ethereum-blockies": "github:MyEtherWallet/blockies",
|
||||
"ethjs-unit": "^0.1.6",
|
||||
"ethjs": "^0.4.0",
|
||||
"ms": "^2.1.2",
|
||||
"shortid": "^2.2.15"
|
||||
},
|
||||
|
@ -36,7 +36,8 @@ const withElectron = (nextConfig = {}) => {
|
||||
module.exports = withSvgr(
|
||||
withElectron({
|
||||
env: {
|
||||
ETHERSCAN_API_KEY: process.env.ETHERSCAN_API_KEY
|
||||
ETHERSCAN_API_KEY: process.env.ETHERSCAN_API_KEY,
|
||||
INFURA_PROJECT_ID: process.env.INFURA_PROJECT_ID
|
||||
},
|
||||
exportPathMap() {
|
||||
return {
|
||||
|
@ -1,7 +1,8 @@
|
||||
import Store from 'electron-store'
|
||||
import unit from 'ethjs-unit'
|
||||
import Eth from 'ethjs'
|
||||
import { fetchData } from '../../utils'
|
||||
import { oceanTokenContract, conversions } from '../../config'
|
||||
import { abi } from '@oceanprotocol/keeper-contracts/artifacts/OceanToken.pacific.json'
|
||||
|
||||
export async function fetchAndSetPrices(prices) {
|
||||
const currencies = conversions.join(',')
|
||||
@ -22,12 +23,14 @@ export async function fetchAndSetPrices(prices) {
|
||||
}
|
||||
|
||||
export async function getBalance(account) {
|
||||
const json = await fetchData(
|
||||
`https://api.etherscan.io/api?module=account&action=tokenbalance&contractaddress=${oceanTokenContract}&address=${account}&tag=latest&apikey=${process.env.ETHERSCAN_API_KEY}`
|
||||
const provider = new Eth.HttpProvider(
|
||||
`https://mainnet.infura.io/v3/${process.env.INFURA_PROJECT_ID}`
|
||||
)
|
||||
const eth = new Eth(provider)
|
||||
const token = eth.contract(abi).at(oceanTokenContract)
|
||||
const balance = await token.balanceOf(account)
|
||||
|
||||
const balance = unit.fromWei(`${json.result}`, 'ether')
|
||||
return balance
|
||||
return Eth.fromWei(balance[0], 'ether')
|
||||
}
|
||||
|
||||
export async function getAccounts() {
|
||||
|
Loading…
Reference in New Issue
Block a user