mirror of
https://github.com/oceanprotocol/market.git
synced 2024-06-28 00:27:49 +02:00
* get poolShares dt addresses * style fixes * class names fix * remove useless changes * fix * try/catch blocks, loading fix * show pool shares fix * delete logs, fix build * more try/catch blocks * check subgraph url, add try/catch block * fixes * pool fields fix * minor code fixes * fix subgraph fetch Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove unused function, fixes * use LoggerInstance, remove useless setter * error messages fix, get rid of dt column * small tweaks and tests * fixes * fixes * modified flow for pool shares * loading UX fixes * unified calculations for pool liquidity * stop the refetch madness * profile provider already sets interval fetching for pool shares * pool shares will change when chainIds, accountId is changed so no need to listen for changes again * calculation tweaks * pool stats tweak * fix pool transactions * fix data display in pool shares section * minor fix, delete comment * subgraph typings generation fix * pool stats display tweaks * price sizing fix * rabbit hole fixes * more price UI fixes * cleanup * wording consistency * render all frontpage sections by default, load in assets after Co-authored-by: ClaudiaHolhos <claudia@oceanprotocol.com> Co-authored-by: mihaisc <mihai.scarlat@smartcontrol.ro> Co-authored-by: mihaisc <mihai@oceanprotocol.com> Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
75 lines
2.0 KiB
TypeScript
75 lines
2.0 KiB
TypeScript
import { ConfigHelper, LoggerInstance, Config } from '@oceanprotocol/lib'
|
|
// import contractAddresses from '@oceanprotocol/contracts/artifacts/address.json'
|
|
import { AbiItem } from 'web3-utils/types'
|
|
import Web3 from 'web3'
|
|
|
|
export function getOceanConfig(network: string | number): Config {
|
|
const config = new ConfigHelper().getConfig(
|
|
network,
|
|
network === 'polygon' ||
|
|
network === 'moonbeamalpha' ||
|
|
network === 1287 ||
|
|
network === 'bsc' ||
|
|
network === 56 ||
|
|
network === 'gaiaxtestnet' ||
|
|
network === 2021000
|
|
? undefined
|
|
: process.env.NEXT_PUBLIC_INFURA_PROJECT_ID
|
|
) as Config
|
|
return config as Config
|
|
}
|
|
|
|
export function getDevelopmentConfig(): Config {
|
|
return {
|
|
// factoryAddress: contractAddresses.development?.DTFactory,
|
|
// poolFactoryAddress: contractAddresses.development?.BFactory,
|
|
// fixedRateExchangeAddress: contractAddresses.development?.FixedRateExchange,
|
|
// metadataContractAddress: contractAddresses.development?.Metadata,
|
|
// oceanTokenAddress: contractAddresses.development?.Ocean,
|
|
// There is no subgraph in barge so we hardcode the Rinkeby one for now
|
|
subgraphUri: 'https://v4.subgraph.rinkeby.oceanprotocol.com'
|
|
} as Config
|
|
}
|
|
|
|
export async function getOceanBalance(
|
|
accountId: string,
|
|
networkId: number,
|
|
web3: Web3
|
|
): Promise<string> {
|
|
const minABI = [
|
|
{
|
|
constant: true,
|
|
inputs: [
|
|
{
|
|
name: '_owner',
|
|
type: 'address'
|
|
}
|
|
],
|
|
name: 'balanceOf',
|
|
outputs: [
|
|
{
|
|
name: 'balance',
|
|
type: 'uint256'
|
|
}
|
|
],
|
|
payable: false,
|
|
stateMutability: 'view',
|
|
type: 'function'
|
|
}
|
|
] as AbiItem[]
|
|
|
|
try {
|
|
const token = new web3.eth.Contract(
|
|
minABI,
|
|
getOceanConfig(networkId).oceanTokenAddress,
|
|
{ from: accountId }
|
|
)
|
|
const result = web3.utils.fromWei(
|
|
await token.methods.balanceOf(accountId).call()
|
|
)
|
|
return result
|
|
} catch (e) {
|
|
LoggerInstance.error(`ERROR: Failed to get the balance: ${e.message}`)
|
|
}
|
|
}
|