mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
lib update
This commit is contained in:
parent
939c8aad0d
commit
d272d79210
@ -12,6 +12,10 @@
|
||||
{
|
||||
"name": "Profile",
|
||||
"link": "/profile"
|
||||
},
|
||||
{
|
||||
"name": "Staking",
|
||||
"link": "/staking"
|
||||
}
|
||||
],
|
||||
"announcement": "Explore [OceanONDA V4](https://blog.oceanprotocol.com/how-to-publish-a-data-nft-f58ad2a622a9).",
|
||||
|
8629
package-lock.json
generated
8629
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -26,7 +26,7 @@
|
||||
"@coingecko/cryptoformat": "^0.5.4",
|
||||
"@loadable/component": "^5.15.2",
|
||||
"@oceanprotocol/art": "^3.2.0",
|
||||
"@oceanprotocol/lib": "^1.1.6",
|
||||
"@oceanprotocol/lib": "^2.0.0",
|
||||
"@oceanprotocol/typographies": "^0.1.0",
|
||||
"@tippyjs/react": "^4.2.6",
|
||||
"@urql/exchange-refocus": "^0.2.5",
|
||||
|
@ -10,7 +10,7 @@ function useNftFactory(): NftFactory {
|
||||
useEffect(() => {
|
||||
if (!web3 || !chainId) return
|
||||
const config = getOceanConfig(chainId)
|
||||
const factory = new NftFactory(config?.erc721FactoryAddress, web3)
|
||||
const factory = new NftFactory(config?.nftFactoryAddress, web3)
|
||||
setNftFactory(factory)
|
||||
}, [web3, chainId])
|
||||
|
||||
|
@ -23,7 +23,7 @@ import {
|
||||
|
||||
const tokensPriceQuery = gql`
|
||||
query TokensPriceQuery($datatokenIds: [ID!], $account: String) {
|
||||
tokens(where: { id_in: $datatokenIds }) {
|
||||
tokens(first: 1000, where: { id_in: $datatokenIds }) {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
|
@ -9,7 +9,7 @@ export async function setMinterToPublisher(
|
||||
accountId: string,
|
||||
setError: (msg: string) => void
|
||||
): Promise<TransactionReceipt> {
|
||||
const dispenserInstance = new Dispenser(web3, dispenserAddress)
|
||||
const dispenserInstance = new Dispenser(dispenserAddress, web3)
|
||||
const status = await dispenserInstance.status(datatokenAddress)
|
||||
if (!status?.active) return
|
||||
|
||||
|
@ -25,8 +25,8 @@ export async function getFixedBuyPrice(
|
||||
|
||||
const config = getOceanConfig(chainId)
|
||||
|
||||
const fixed = new FixedRateExchange(web3, config.fixedRateExchangeAddress)
|
||||
const estimatedPrice = await fixed.calcBaseInGivenOutDT(
|
||||
const fixed = new FixedRateExchange(config.fixedRateExchangeAddress, web3)
|
||||
const estimatedPrice = await fixed.calcBaseInGivenDatatokensOut(
|
||||
accessDetails.addressOrId,
|
||||
'1',
|
||||
consumeMarketFixedSwapFee
|
||||
|
@ -171,15 +171,6 @@ export async function setNFTMetadataAndTokenURI(
|
||||
metadataProofs: []
|
||||
}
|
||||
|
||||
const estGasSetMetadataAndTokenURI = await nft.estGasSetMetadataAndTokenURI(
|
||||
asset.nftAddress,
|
||||
accountId,
|
||||
metadataAndTokenURI
|
||||
)
|
||||
LoggerInstance.log(
|
||||
'[setNFTMetadataAndTokenURI] est Gas set metadata and token uri --',
|
||||
estGasSetMetadataAndTokenURI
|
||||
)
|
||||
const setMetadataAndTokenURITx = await nft.setMetadataAndTokenURI(
|
||||
asset.nftAddress,
|
||||
accountId,
|
||||
|
@ -68,6 +68,7 @@ export async function order(
|
||||
// this assumes all fees are in ocean
|
||||
const txApprove = await approve(
|
||||
web3,
|
||||
config,
|
||||
accountId,
|
||||
asset.accessDetails.baseToken.address,
|
||||
asset.accessDetails.datatoken.address,
|
||||
@ -154,19 +155,21 @@ async function approveProviderFee(
|
||||
accountId: string,
|
||||
web3: Web3,
|
||||
providerFeeAmount: string
|
||||
): Promise<string> {
|
||||
): Promise<TransactionReceipt> {
|
||||
const config = getOceanConfig(asset.chainId)
|
||||
const baseToken =
|
||||
asset?.accessDetails?.type === 'free'
|
||||
? getOceanConfig(asset.chainId).oceanTokenAddress
|
||||
: asset?.accessDetails?.baseToken?.address
|
||||
const txApproveWei = await approveWei(
|
||||
web3,
|
||||
config,
|
||||
accountId,
|
||||
baseToken,
|
||||
asset?.accessDetails?.datatoken?.address,
|
||||
providerFeeAmount
|
||||
)
|
||||
return txApproveWei as string // thanks ocean.js
|
||||
return txApproveWei
|
||||
}
|
||||
|
||||
async function startOrder(
|
||||
|
10
src/components/Asset/AssetActions/VeAllocation/index.tsx
Normal file
10
src/components/Asset/AssetActions/VeAllocation/index.tsx
Normal file
@ -0,0 +1,10 @@
|
||||
import { VeAllocate } from '@oceanprotocol/lib'
|
||||
import React, { ReactElement, useEffect } from 'react'
|
||||
|
||||
export default function VeAllocation(): ReactElement {
|
||||
useEffect(() => {
|
||||
const veAllocation = new VeAllocate()
|
||||
}, [])
|
||||
|
||||
return <div>Ve Allocation</div>
|
||||
}
|
@ -16,6 +16,7 @@ import { useFormikContext } from 'formik'
|
||||
import { FormPublishData } from 'src/components/Publish/_types'
|
||||
import { getTokenBalanceFromSymbol } from '@utils/web3'
|
||||
import AssetStats from './AssetStats'
|
||||
import VeAllocation from './VeAllocation'
|
||||
|
||||
export default function AssetActions({
|
||||
asset
|
||||
@ -148,7 +149,10 @@ export default function AssetActions({
|
||||
</>
|
||||
)
|
||||
|
||||
const tabs: TabsItem[] = [{ title: 'Use', content: UseContent }]
|
||||
const tabs: TabsItem[] = [
|
||||
{ title: 'Use', content: UseContent },
|
||||
{ title: 'VeAllocation', content: <VeAllocation /> }
|
||||
]
|
||||
|
||||
return (
|
||||
<>
|
||||
|
@ -43,8 +43,8 @@ export default function Edit({
|
||||
const config = getOceanConfig(asset.chainId)
|
||||
|
||||
const fixedRateInstance = new FixedRateExchange(
|
||||
web3,
|
||||
config.fixedRateExchangeAddress
|
||||
config.fixedRateExchangeAddress,
|
||||
web3
|
||||
)
|
||||
|
||||
const setPriceResp = await fixedRateInstance.setRate(
|
||||
|
@ -1,9 +1,10 @@
|
||||
import {
|
||||
Config,
|
||||
DDO,
|
||||
Erc20CreateParams,
|
||||
FreCreationParams,
|
||||
generateDid,
|
||||
DatatokenCreateParams,
|
||||
DispenserCreationParams,
|
||||
getHash,
|
||||
LoggerInstance,
|
||||
Metadata,
|
||||
@ -202,7 +203,7 @@ export async function createTokensAndPricing(
|
||||
LoggerInstance.log('[publish] Creating NFT with metadata', nftCreateData)
|
||||
|
||||
// TODO: cap is hardcoded for now to 1000, this needs to be discussed at some point
|
||||
const ercParams: Erc20CreateParams = {
|
||||
const ercParams: DatatokenCreateParams = {
|
||||
templateIndex: 2,
|
||||
minter: accountId,
|
||||
paymentCollector: accountId,
|
||||
@ -238,7 +239,7 @@ export async function createTokensAndPricing(
|
||||
freParams
|
||||
)
|
||||
|
||||
const result = await nftFactory.createNftErc20WithFixedRate(
|
||||
const result = await nftFactory.createNftWithDatatokenWithFixedRate(
|
||||
accountId,
|
||||
nftCreateData,
|
||||
ercParams,
|
||||
@ -257,7 +258,7 @@ export async function createTokensAndPricing(
|
||||
// maxTokens - how many tokens cand be dispensed when someone requests . If maxTokens=2 then someone can't request 3 in one tx
|
||||
// maxBalance - how many dt the user has in it's wallet before the dispenser will not dispense dt
|
||||
// both will be just 1 for the market
|
||||
const dispenserParams = {
|
||||
const dispenserParams: DispenserCreationParams = {
|
||||
dispenserAddress: config.dispenserAddress,
|
||||
maxTokens: web3.utils.toWei('1'),
|
||||
maxBalance: web3.utils.toWei('1'),
|
||||
@ -270,7 +271,7 @@ export async function createTokensAndPricing(
|
||||
dispenserParams
|
||||
)
|
||||
|
||||
const result = await nftFactory.createNftErc20WithDispenser(
|
||||
const result = await nftFactory.createNftWithDatatokenWithDispenser(
|
||||
accountId,
|
||||
nftCreateData,
|
||||
ercParams,
|
||||
|
9
src/components/Staking/index.tsx
Normal file
9
src/components/Staking/index.tsx
Normal file
@ -0,0 +1,9 @@
|
||||
import React, { ReactElement } from 'react'
|
||||
|
||||
export default function StakingPage({
|
||||
accountId
|
||||
}: {
|
||||
accountId: string
|
||||
}): ReactElement {
|
||||
return <div>Test staking</div>
|
||||
}
|
3
src/pages/staking/[account].tsx
Normal file
3
src/pages/staking/[account].tsx
Normal file
@ -0,0 +1,3 @@
|
||||
import PageStaking from '.'
|
||||
|
||||
export default PageStaking
|
45
src/pages/staking/index.tsx
Normal file
45
src/pages/staking/index.tsx
Normal file
@ -0,0 +1,45 @@
|
||||
import React, { ReactElement, useEffect, useState } from 'react'
|
||||
import Page from '@shared/Page'
|
||||
import { accountTruncate } from '@utils/web3'
|
||||
import { useWeb3 } from '@context/Web3'
|
||||
import { useRouter } from 'next/router'
|
||||
import web3 from 'web3'
|
||||
import StakingPage from 'src/components/Staking'
|
||||
|
||||
export default function PageStaking(): ReactElement {
|
||||
const router = useRouter()
|
||||
const { accountId } = useWeb3()
|
||||
const [finalAccountId, setFinalAccountId] = useState<string>()
|
||||
|
||||
// Have accountId in path take over, if not present fall back to web3
|
||||
useEffect(() => {
|
||||
async function init() {
|
||||
if (!router?.asPath) return
|
||||
|
||||
// Path is root /profile, have web3 take over
|
||||
if (router.asPath === '/staking') {
|
||||
setFinalAccountId(accountId)
|
||||
return
|
||||
}
|
||||
|
||||
const pathAccount = router.query.account as string
|
||||
|
||||
// Path has ETH addreess
|
||||
if (web3.utils.isAddress(pathAccount)) {
|
||||
const finalAccountId = pathAccount || accountId
|
||||
setFinalAccountId(finalAccountId)
|
||||
}
|
||||
}
|
||||
init()
|
||||
}, [router, accountId])
|
||||
|
||||
return (
|
||||
<Page
|
||||
uri={router.route}
|
||||
title={accountTruncate(finalAccountId)}
|
||||
noPageHeader
|
||||
>
|
||||
<StakingPage accountId={finalAccountId} />
|
||||
</Page>
|
||||
)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user