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