1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

Updating paymentCollector on submit

This commit is contained in:
Jamie Hewitt 2022-11-15 11:38:43 +03:00
parent e22407ad43
commit fd30d5e138

View File

@ -46,20 +46,17 @@ export default function Edit({
async function getInitialPaymentCollector() { async function getInitialPaymentCollector() {
let paymentCollector let paymentCollector
try { try {
console.log('owner', asset?.nft.owner)
const datatoken = new Datatoken(web3) const datatoken = new Datatoken(web3)
console.log('datatoken', datatoken)
paymentCollector = await datatoken.getPaymentCollector( paymentCollector = await datatoken.getPaymentCollector(
asset?.datatokens[0].address asset?.datatokens[0].address
) )
console.log('paymentCollector', paymentCollector)
setPaymentCollector(paymentCollector) setPaymentCollector(paymentCollector)
} catch (error) { } catch (error) {
console.log(error) console.error(error)
} }
} }
getInitialPaymentCollector() getInitialPaymentCollector()
}, [asset]) }, [asset, web3])
async function updateFixedPrice(newPrice: string) { async function updateFixedPrice(newPrice: string) {
const config = getOceanConfig(asset.chainId) const config = getOceanConfig(asset.chainId)
@ -102,6 +99,15 @@ export default function Edit({
values.price !== asset.accessDetails.price && values.price !== asset.accessDetails.price &&
(await updateFixedPrice(values.price)) (await updateFixedPrice(values.price))
if (values.paymentCollector !== paymentCollector) {
const datatoken = new Datatoken(web3)
await datatoken.setPaymentCollector(
asset?.datatokens[0].address,
accountId,
values.paymentCollector
)
}
if (values.files[0]?.url) { if (values.files[0]?.url) {
const file = { const file = {
nftAddress: asset.nftAddress, nftAddress: asset.nftAddress,