mirror of
https://github.com/oceanprotocol/react.git
synced 2024-12-23 01:29:49 +01:00
Merge branch 'main' into feature/fixedPrice
This commit is contained in:
commit
a3b6da7530
14
example/config-overrides.js
Normal file
14
example/config-overrides.js
Normal file
@ -0,0 +1,14 @@
|
||||
module.exports = function override(config, env) {
|
||||
const path = require('path')
|
||||
|
||||
return {
|
||||
...config,
|
||||
resolve: {
|
||||
...config.resolve,
|
||||
alias: {
|
||||
...config.resolve.alias,
|
||||
react: path.resolve('../node_modules/react')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
24153
example/package-lock.json
generated
24153
example/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -4,34 +4,43 @@
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@oceanprotocol/lib": "^0.1.17",
|
||||
"@oceanprotocol/react": "file:..",
|
||||
"@toruslabs/torus-embed": "^1.8.2",
|
||||
"@oceanprotocol/react": "file:../",
|
||||
"@testing-library/jest-dom": "^4.2.4",
|
||||
"@testing-library/react": "^9.5.0",
|
||||
"@testing-library/user-event": "^7.2.1",
|
||||
"@types/jest": "^24.9.1",
|
||||
"@types/node": "^12.12.47",
|
||||
"@types/react": "^16.9.41",
|
||||
"@types/node": "^12.12.54",
|
||||
"@types/react": "^16.9.49",
|
||||
"@types/react-dom": "^16.9.8",
|
||||
"@types/shortid": "^0.0.29",
|
||||
"@walletconnect/web3-provider": "^1.1.0",
|
||||
"@types/shortid": "0.0.29",
|
||||
"react": "^16.13.1",
|
||||
"react-dom": "^16.13.1",
|
||||
"react-scripts": "3.4.1",
|
||||
"react-scripts": "3.4.3",
|
||||
"shortid": "^2.2.15",
|
||||
"typescript": "^3.9.7",
|
||||
"web3-eth-contract": "^1.2.11"
|
||||
"typescript": "^3.7.5"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
"start": "react-app-rewired start",
|
||||
"build": "react-app-rewired build",
|
||||
"test": "react-app-rewired test",
|
||||
"eject": "react-app-rewired eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "@oceanprotocol/react"
|
||||
},
|
||||
"browserslist": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not ie <= 11",
|
||||
"not op_mini all"
|
||||
]
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"react-app-rewired": "^2.1.6"
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,8 @@ import { OceanProvider } from '@oceanprotocol/react'
|
||||
import { Wallet } from './Wallet'
|
||||
import { Publish } from './Publish'
|
||||
import { Config, ConfigHelper } from '@oceanprotocol/lib'
|
||||
import { AllDdos } from './AllDdos'
|
||||
import { ConsumeDdo } from './ConsumeDdo'
|
||||
|
||||
|
||||
import { NetworkMonitor } from './NetworkMonitor'
|
||||
import { MetadataExample } from './MetadataExample'
|
||||
imprt { ConsumeDdo } from './Consume'
|
||||
import { NetworkMonitor } from './NetworkMonadataExample from './MetadataExample'
|
||||
|
||||
// factory Address needs to be updated each time you deploy the contract on local network
|
||||
const config = {
|
||||
@ -21,9 +17,7 @@ const config = {
|
||||
|
||||
const configRinkeby = new ConfigHelper().getConfig('rinkeby')
|
||||
|
||||
const providerOptions = {
|
||||
|
||||
}
|
||||
const providerOptions = {}
|
||||
|
||||
export const web3ModalOpts = {
|
||||
cacheProvider: true,
|
||||
|
@ -8,7 +8,7 @@ export function Publish() {
|
||||
const { accountId, ocean } = useOcean()
|
||||
const { publish, publishStepText, isLoading } = usePublish()
|
||||
const [ddo, setDdo] = useState<DDO | undefined>()
|
||||
|
||||
|
||||
const asset = {
|
||||
main: {
|
||||
type: 'dataset',
|
||||
@ -59,7 +59,9 @@ export function Publish() {
|
||||
<div>
|
||||
<button onClick={publishAsset}>Publish</button>
|
||||
</div>
|
||||
<div>IsLoading: {isLoading.toString()} || Status: {publishStepText}</div>
|
||||
<div>
|
||||
IsLoading: {isLoading.toString()} || Status: {publishStepText}
|
||||
</div>
|
||||
|
||||
<div>DID: {ddo && ddo.id} </div>
|
||||
</>
|
||||
|
@ -6,14 +6,14 @@
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react",
|
||||
"strict": true
|
||||
"jsx": "react"
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
|
1856
package-lock.json
generated
1856
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -55,8 +55,11 @@ function usePublish(): UsePublish {
|
||||
setIsLoading(true)
|
||||
setPublishError(undefined)
|
||||
try {
|
||||
<<<<<<< HEAD
|
||||
const tokensToMint = priceOptions.tokensToMint.toString()
|
||||
|
||||
=======
|
||||
>>>>>>> main
|
||||
const publishedDate =
|
||||
new Date(Date.now()).toISOString().split('.')[0] + 'Z'
|
||||
const timeout = 0
|
||||
@ -132,6 +135,7 @@ function usePublish(): UsePublish {
|
||||
setStep(7)
|
||||
await mint(ddo.dataToken, tokensToMint)
|
||||
Logger.log(`minted ${tokensToMint} tokens`)
|
||||
setStep(8)
|
||||
|
||||
await createPricing(priceOptions, ddo.dataToken)
|
||||
setStep(8)
|
||||
|
@ -19,13 +19,7 @@ export async function getCheapestPool(
|
||||
address: '',
|
||||
price: ''
|
||||
}
|
||||
}
|
||||
let cheapestPoolAddress
|
||||
let cheapestPoolPrice = new Decimal(999999999999)
|
||||
|
||||
if (tokenPools) {
|
||||
for (let i = 0; i < tokenPools.length; i++) {
|
||||
const poolPrice = await ocean.pool.getOceanNeeded(
|
||||
let cheapestPoolAddresspoolPrice = await ocean.pool.getOceanNeeded(
|
||||
accountId,
|
||||
tokenPools[i],
|
||||
'1'
|
||||
@ -61,11 +55,6 @@ export async function getCheapestExchange(
|
||||
if (!ocean || !dataTokenAddress) return
|
||||
|
||||
const tokenExchanges = await ocean.fixedRateExchange.searchforDT(
|
||||
dataTokenAddress,
|
||||
'1'
|
||||
)
|
||||
Logger.log('Exchanges found', tokenExchanges)
|
||||
if (tokenExchanges === undefined || tokenExchanges.length === 0) {
|
||||
return {
|
||||
address: '',
|
||||
price: ''
|
||||
@ -115,29 +104,14 @@ export async function checkAndBuyDT(
|
||||
)
|
||||
const cheapestExchange = await getCheapestExchange(ocean, dataTokenAddress)
|
||||
Decimal.set({ precision: 5 })
|
||||
const cheapestPoolPrice = new Decimal(cheapestPool.price)
|
||||
const cheapestExchangePrice = new Decimal(cheapestExchange.price)
|
||||
|
||||
if (cheapestExchangePrice > cheapestPoolPrice) {
|
||||
const price = new Decimal(cheapestPool.price).times(1.05).toString()
|
||||
const maxPrice = new Decimal(cheapestPool.price).times(2).toString()
|
||||
Logger.log('Buying token', cheapestPool, account.getId(), price)
|
||||
const buyResponse = await ocean.pool.buyDT(
|
||||
account.getId(),
|
||||
cheapestPool.address,
|
||||
'1',
|
||||
price,
|
||||
maxPrice
|
||||
)
|
||||
Logger.log('DT buy response', buyResponse)
|
||||
return buyResponse
|
||||
} else {
|
||||
const exchange = await ocean.fixedRateExchange.buyDT(
|
||||
cheapestExchange.address,
|
||||
'1',
|
||||
account.getId()
|
||||
)
|
||||
return exchange
|
||||
}
|
||||
Logger.log('yResponse = await ocean.pool.buyDT(
|
||||
account.getId(),
|
||||
cheapestPool.address,
|
||||
'1',
|
||||
price,
|
||||
maxPrice
|
||||
)
|
||||
Logger.log('DT buy response', buyResponse)
|
||||
return buyResponse
|
||||
}
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ export const publishFeedback: { [key in number]: string } = {
|
||||
2: '2/6 Encrypting files ...',
|
||||
4: '3/6 Generating proof ...',
|
||||
6: '4/6 Storing ddo ...',
|
||||
7: '5/6 Minting tokens ...',
|
||||
8: '6/6 Asset published succesfully'
|
||||
7: '2/6 Minting tokens ...',
|
||||
8: '4/6 Asset published succesfully'
|
||||
}
|
||||
|
||||
export * from './web3'
|
||||
|
Loading…
Reference in New Issue
Block a user