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:
parent
939c8aad0d
commit
4dca7d3442
8360
package-lock.json
generated
8360
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.2",
|
||||
"@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(
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user