1
0
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:
mihaisc 2020-09-07 12:11:12 +03:00
commit a3b6da7530
10 changed files with 24174 additions and 1972 deletions

View 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')
}
}
}
}

24131
example/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -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": [
"browserslist": {
"production": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"react-app-rewired": "^2.1.6"
}
}

View File

@ -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,

View File

@ -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>
</>

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -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)

View File

@ -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,14 +104,7 @@ 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(
Logger.log('yResponse = await ocean.pool.buyDT(
account.getId(),
cheapestPool.address,
'1',
@ -131,13 +113,5 @@ export async function checkAndBuyDT(
)
Logger.log('DT buy response', buyResponse)
return buyResponse
} else {
const exchange = await ocean.fixedRateExchange.buyDT(
cheapestExchange.address,
'1',
account.getId()
)
return exchange
}
}
}

View File

@ -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'