1
0
mirror of https://github.com/oceanprotocol/react.git synced 2025-01-24 09:13:29 +01:00

add marketFeeAddress

This commit is contained in:
mihaisc 2020-08-12 14:50:01 +03:00
parent 0ace964925
commit 867b52fb31
3 changed files with 12 additions and 2 deletions

View File

@ -15,7 +15,7 @@ interface UseMetadata {
}
function useMetadata(did?: DID | string): UseMetadata {
const { ocean, status, config, accountId } = useOcean()
const { ocean, status, config, accountId, marketFeeAddress } = useOcean()
const [ddo, setDDO] = useState<DDO | undefined>()
const [metadata, setMetadata] = useState<Metadata | undefined>()
const [title, setTitle] = useState<string | undefined>()
@ -33,7 +33,11 @@ function useMetadata(did?: DID | string): UseMetadata {
}
async function getBestPrice(dataTokenAddress: string): Promise<string> {
return await getBestDataTokenPrice(ocean, accountId, dataTokenAddress)
return await getBestDataTokenPrice(
ocean,
marketFeeAddress,
dataTokenAddress
)
}
async function getMetadata(did: DID | string): Promise<Metadata> {

View File

@ -28,6 +28,7 @@ interface OceanProviderValue {
balance: Balance
chainId: number | undefined
status: ProviderStatus
marketFeeAddress: string
connect: (config?: Config) => Promise<void>
logout: () => Promise<void>
refreshBalance: () => Promise<void>
@ -38,10 +39,12 @@ const OceanContext = createContext(null)
function OceanProvider({
initialConfig,
web3ModalOpts,
marketFeeAddress,
children
}: {
initialConfig: Config
web3ModalOpts?: Partial<ICoreOptions>
marketFeeAddress: string
children: any
}): ReactElement {
const [web3, setWeb3] = useState<Web3 | undefined>()
@ -169,6 +172,7 @@ function OceanProvider({
chainId,
status,
config,
marketFeeAddress,
connect,
logout,
refreshBalance

View File

@ -5,6 +5,8 @@ export async function getCheapestPool(
accountId: string,
dataTokenAddress: string
): Promise<{ poolAddress: string; poolPrice: string }> {
if (!ocean || !accountId || !dataTokenAddress) return
const tokenPools = await ocean.pool.searchPoolforDT(
accountId,
dataTokenAddress