mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
fix publish with pool
This commit is contained in:
parent
c9faca8666
commit
8e60738071
@ -16,6 +16,10 @@ export function getOceanConfig(network: string | number): Config {
|
|||||||
? undefined
|
? undefined
|
||||||
: process.env.NEXT_PUBLIC_INFURA_PROJECT_ID
|
: process.env.NEXT_PUBLIC_INFURA_PROJECT_ID
|
||||||
) as Config
|
) as Config
|
||||||
|
|
||||||
|
// TODO: remove hack once address is fixed
|
||||||
|
if (network === 'rinkeby' || network === 4)
|
||||||
|
config.oceanTokenAddress = '0x8967bcf84170c91b0d24d4302c2376283b0b3a07'
|
||||||
return config as Config
|
return config as Config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import axios, { CancelToken, AxiosResponse } from 'axios'
|
import axios, { CancelToken, AxiosResponse, Method } from 'axios'
|
||||||
import {
|
import {
|
||||||
FileMetadata,
|
FileMetadata,
|
||||||
LoggerInstance,
|
LoggerInstance,
|
||||||
@ -22,9 +22,11 @@ export async function getEncryptedFiles(
|
|||||||
const response = await ProviderInstance.encrypt(
|
const response = await ProviderInstance.encrypt(
|
||||||
files,
|
files,
|
||||||
providerUrl,
|
providerUrl,
|
||||||
(url: string, body: string) => {
|
(httpMethod: Method, url: string, body: string, headers: any) => {
|
||||||
return axios.post(url, body, {
|
return axios(url, {
|
||||||
headers: { 'Content-Type': 'application/octet-stream' }
|
method: httpMethod,
|
||||||
|
data: body,
|
||||||
|
headers: headers
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -23,11 +23,13 @@ import {
|
|||||||
FreCreationParams,
|
FreCreationParams,
|
||||||
PoolCreationParams,
|
PoolCreationParams,
|
||||||
ProviderInstance,
|
ProviderInstance,
|
||||||
ZERO_ADDRESS
|
ZERO_ADDRESS,
|
||||||
|
Pool,
|
||||||
|
LoggerInstance
|
||||||
} from '@oceanprotocol/lib'
|
} from '@oceanprotocol/lib'
|
||||||
import { useSiteMetadata } from '@hooks/useSiteMetadata'
|
import { useSiteMetadata } from '@hooks/useSiteMetadata'
|
||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
import axios from 'axios'
|
import axios, { Method } from 'axios'
|
||||||
import { useCancelToken } from '@hooks/useCancelToken'
|
import { useCancelToken } from '@hooks/useCancelToken'
|
||||||
import { getOceanConfig } from '@utils/ocean'
|
import { getOceanConfig } from '@utils/ocean'
|
||||||
|
|
||||||
@ -100,22 +102,24 @@ export default function PublishPage({
|
|||||||
publisherAddress: accountId,
|
publisherAddress: accountId,
|
||||||
marketFeeCollector: appConfig.marketFeeAddress,
|
marketFeeCollector: appConfig.marketFeeAddress,
|
||||||
poolTemplateAddress: config.poolTemplateAddress,
|
poolTemplateAddress: config.poolTemplateAddress,
|
||||||
rate: values.pricing.price,
|
rate: values.pricing.price.toString(),
|
||||||
basetokenDecimals: 18,
|
basetokenDecimals: 18,
|
||||||
vestingAmount: '0',
|
vestingAmount: '0',
|
||||||
vestedBlocks: 2726000,
|
vestedBlocks: 2726000,
|
||||||
initialBasetokenLiquidity: values.pricing.amountOcean,
|
initialBasetokenLiquidity: values.pricing.amountOcean.toString(),
|
||||||
swapFeeLiquidityProvider: 1e15,
|
swapFeeLiquidityProvider: 1e15,
|
||||||
swapFeeMarketRunner: 1e15
|
swapFeeMarketRunner: 1e15
|
||||||
}
|
}
|
||||||
const token = new Datatoken(web3)
|
|
||||||
// the spender in this case is the erc721Factory because we are delegating
|
// the spender in this case is the erc721Factory because we are delegating
|
||||||
token.approve(
|
const pool = new Pool(web3, LoggerInstance)
|
||||||
|
const txApp = await pool.approve(
|
||||||
|
accountId,
|
||||||
config.oceanTokenAddress,
|
config.oceanTokenAddress,
|
||||||
config.erc721FactoryAddress,
|
config.erc721FactoryAddress,
|
||||||
values.pricing.amountOcean.toString(),
|
'200',
|
||||||
accountId
|
false
|
||||||
)
|
)
|
||||||
|
console.log('aprove', txApp)
|
||||||
const result = await nftFactory.createNftErcWithPool(
|
const result = await nftFactory.createNftErcWithPool(
|
||||||
accountId,
|
accountId,
|
||||||
nftCreateData,
|
nftCreateData,
|
||||||
@ -135,7 +139,7 @@ export default function PublishPage({
|
|||||||
marketFeeCollector: appConfig.marketFeeAddress,
|
marketFeeCollector: appConfig.marketFeeAddress,
|
||||||
baseTokenDecimals: 18,
|
baseTokenDecimals: 18,
|
||||||
dataTokenDecimals: 18,
|
dataTokenDecimals: 18,
|
||||||
fixedRate: values.pricing.price,
|
fixedRate: values.pricing.price.toString(),
|
||||||
marketFee: 1e15,
|
marketFee: 1e15,
|
||||||
withMint: true
|
withMint: true
|
||||||
}
|
}
|
||||||
@ -188,9 +192,11 @@ export default function PublishPage({
|
|||||||
const encryptedResponse = await ProviderInstance.encrypt(
|
const encryptedResponse = await ProviderInstance.encrypt(
|
||||||
ddo,
|
ddo,
|
||||||
config.providerUri,
|
config.providerUri,
|
||||||
(url: string, body: string) => {
|
(httpMethod: Method, url: string, body: string, headers: any) => {
|
||||||
return axios.post(url, body, {
|
return axios(url, {
|
||||||
headers: { 'Content-Type': 'application/octet-stream' },
|
method: httpMethod,
|
||||||
|
data: body,
|
||||||
|
headers: headers,
|
||||||
cancelToken: newCancelToken()
|
cancelToken: newCancelToken()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user