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

update market to ocean.js@2.0.2 (#1661)

* update ocean js

* refactoring ocean.js 2.0.0

* removed deleted method

* added type in publish utils

* fix FixedRateExchange parameters

* use 2.0.0 lib version

* remove cast on approveWei and fix algo asset selection list issue

* bump oceanlib to 2.0.1

* bump oceanlib to 2.0.2

Co-authored-by: Bogdan Fazakas <bogdan.fazakas@gmail.com>
This commit is contained in:
EnzoVezzaro 2022-09-13 05:19:56 -04:00 committed by GitHub
parent 939c8aad0d
commit 4dca7d3442
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 1256 additions and 7147 deletions

8360
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,7 @@
"@coingecko/cryptoformat": "^0.5.4", "@coingecko/cryptoformat": "^0.5.4",
"@loadable/component": "^5.15.2", "@loadable/component": "^5.15.2",
"@oceanprotocol/art": "^3.2.0", "@oceanprotocol/art": "^3.2.0",
"@oceanprotocol/lib": "^1.1.6", "@oceanprotocol/lib": "^2.0.2",
"@oceanprotocol/typographies": "^0.1.0", "@oceanprotocol/typographies": "^0.1.0",
"@tippyjs/react": "^4.2.6", "@tippyjs/react": "^4.2.6",
"@urql/exchange-refocus": "^0.2.5", "@urql/exchange-refocus": "^0.2.5",

View File

@ -10,7 +10,7 @@ function useNftFactory(): NftFactory {
useEffect(() => { useEffect(() => {
if (!web3 || !chainId) return if (!web3 || !chainId) return
const config = getOceanConfig(chainId) const config = getOceanConfig(chainId)
const factory = new NftFactory(config?.erc721FactoryAddress, web3) const factory = new NftFactory(config?.nftFactoryAddress, web3)
setNftFactory(factory) setNftFactory(factory)
}, [web3, chainId]) }, [web3, chainId])

View File

@ -23,7 +23,7 @@ import {
const tokensPriceQuery = gql` const tokensPriceQuery = gql`
query TokensPriceQuery($datatokenIds: [ID!], $account: String) { query TokensPriceQuery($datatokenIds: [ID!], $account: String) {
tokens(where: { id_in: $datatokenIds }) { tokens(first: 1000, where: { id_in: $datatokenIds }) {
id id
symbol symbol
name name

View File

@ -9,7 +9,7 @@ export async function setMinterToPublisher(
accountId: string, accountId: string,
setError: (msg: string) => void setError: (msg: string) => void
): Promise<TransactionReceipt> { ): Promise<TransactionReceipt> {
const dispenserInstance = new Dispenser(web3, dispenserAddress) const dispenserInstance = new Dispenser(dispenserAddress, web3)
const status = await dispenserInstance.status(datatokenAddress) const status = await dispenserInstance.status(datatokenAddress)
if (!status?.active) return if (!status?.active) return

View File

@ -25,8 +25,8 @@ export async function getFixedBuyPrice(
const config = getOceanConfig(chainId) const config = getOceanConfig(chainId)
const fixed = new FixedRateExchange(web3, config.fixedRateExchangeAddress) const fixed = new FixedRateExchange(config.fixedRateExchangeAddress, web3)
const estimatedPrice = await fixed.calcBaseInGivenOutDT( const estimatedPrice = await fixed.calcBaseInGivenDatatokensOut(
accessDetails.addressOrId, accessDetails.addressOrId,
'1', '1',
consumeMarketFixedSwapFee consumeMarketFixedSwapFee

View File

@ -171,15 +171,6 @@ export async function setNFTMetadataAndTokenURI(
metadataProofs: [] 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( const setMetadataAndTokenURITx = await nft.setMetadataAndTokenURI(
asset.nftAddress, asset.nftAddress,
accountId, accountId,

View File

@ -68,6 +68,7 @@ export async function order(
// this assumes all fees are in ocean // this assumes all fees are in ocean
const txApprove = await approve( const txApprove = await approve(
web3, web3,
config,
accountId, accountId,
asset.accessDetails.baseToken.address, asset.accessDetails.baseToken.address,
asset.accessDetails.datatoken.address, asset.accessDetails.datatoken.address,
@ -154,19 +155,21 @@ async function approveProviderFee(
accountId: string, accountId: string,
web3: Web3, web3: Web3,
providerFeeAmount: string providerFeeAmount: string
): Promise<string> { ): Promise<TransactionReceipt> {
const config = getOceanConfig(asset.chainId)
const baseToken = const baseToken =
asset?.accessDetails?.type === 'free' asset?.accessDetails?.type === 'free'
? getOceanConfig(asset.chainId).oceanTokenAddress ? getOceanConfig(asset.chainId).oceanTokenAddress
: asset?.accessDetails?.baseToken?.address : asset?.accessDetails?.baseToken?.address
const txApproveWei = await approveWei( const txApproveWei = await approveWei(
web3, web3,
config,
accountId, accountId,
baseToken, baseToken,
asset?.accessDetails?.datatoken?.address, asset?.accessDetails?.datatoken?.address,
providerFeeAmount providerFeeAmount
) )
return txApproveWei as string // thanks ocean.js return txApproveWei
} }
async function startOrder( async function startOrder(

View File

@ -43,8 +43,8 @@ export default function Edit({
const config = getOceanConfig(asset.chainId) const config = getOceanConfig(asset.chainId)
const fixedRateInstance = new FixedRateExchange( const fixedRateInstance = new FixedRateExchange(
web3, config.fixedRateExchangeAddress,
config.fixedRateExchangeAddress web3
) )
const setPriceResp = await fixedRateInstance.setRate( const setPriceResp = await fixedRateInstance.setRate(

View File

@ -1,9 +1,10 @@
import { import {
Config, Config,
DDO, DDO,
Erc20CreateParams,
FreCreationParams, FreCreationParams,
generateDid, generateDid,
DatatokenCreateParams,
DispenserCreationParams,
getHash, getHash,
LoggerInstance, LoggerInstance,
Metadata, Metadata,
@ -202,7 +203,7 @@ export async function createTokensAndPricing(
LoggerInstance.log('[publish] Creating NFT with metadata', nftCreateData) LoggerInstance.log('[publish] Creating NFT with metadata', nftCreateData)
// TODO: cap is hardcoded for now to 1000, this needs to be discussed at some point // TODO: cap is hardcoded for now to 1000, this needs to be discussed at some point
const ercParams: Erc20CreateParams = { const ercParams: DatatokenCreateParams = {
templateIndex: 2, templateIndex: 2,
minter: accountId, minter: accountId,
paymentCollector: accountId, paymentCollector: accountId,
@ -238,7 +239,7 @@ export async function createTokensAndPricing(
freParams freParams
) )
const result = await nftFactory.createNftErc20WithFixedRate( const result = await nftFactory.createNftWithDatatokenWithFixedRate(
accountId, accountId,
nftCreateData, nftCreateData,
ercParams, 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 // 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 // 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 // both will be just 1 for the market
const dispenserParams = { const dispenserParams: DispenserCreationParams = {
dispenserAddress: config.dispenserAddress, dispenserAddress: config.dispenserAddress,
maxTokens: web3.utils.toWei('1'), maxTokens: web3.utils.toWei('1'),
maxBalance: web3.utils.toWei('1'), maxBalance: web3.utils.toWei('1'),
@ -270,7 +271,7 @@ export async function createTokensAndPricing(
dispenserParams dispenserParams
) )
const result = await nftFactory.createNftErc20WithDispenser( const result = await nftFactory.createNftWithDatatokenWithDispenser(
accountId, accountId,
nftCreateData, nftCreateData,
ercParams, ercParams,