1
0
mirror of https://github.com/oceanprotocol/react.git synced 2025-02-14 21:10:38 +01:00

Merge pull request #164 from oceanprotocol/update/ocean.js-bump

Update/ocean.js bump
This commit is contained in:
Matthias Kretschmann 2020-10-26 15:41:27 +01:00 committed by GitHub
commit 45c9d47d45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 19 deletions

View File

@ -7,21 +7,30 @@ import { Metadata } from '@oceanprotocol/lib/dist/node/ddo/interfaces/Metadata'
export function Trade() { export function Trade() {
const { ocean, accountId } = useOcean() const { ocean, accountId } = useOcean()
const { createPricing,buyDT,sellDT,mint,pricingStep,pricingStepText,pricingIsLoading, pricingError} = usePricing() const {
createPricing,
buyDT,
sellDT,
mint,
pricingStep,
pricingStepText,
pricingIsLoading,
pricingError
} = usePricing()
const [datatoken, setDatatoken] = useState<string | undefined>() const [datatoken, setDatatoken] = useState<string | undefined>()
const handleBuy = async () => { const handleBuy = async () => {
const tx = await buyDT(datatoken,'1') const tx = await buyDT(datatoken, '1')
console.log(tx) console.log(tx)
} }
const handleSell = async () => { const handleSell = async () => {
const tx = await buyDT(datatoken,'1') const tx = await buyDT(datatoken, '1')
console.log(tx) console.log(tx)
} }
const handleChange = (e: any) => { const handleChange = (e: any) => {
setDatatoken(e.target.value) setDatatoken(e.target.value)
} }
const handlePostForSale = async () => { const handlePostForSale = async () => {
if(datatoken){ if (datatoken) {
const priceOptions = { const priceOptions = {
price: 7, price: 7,
dtAmount: 10, dtAmount: 10,
@ -29,7 +38,7 @@ export function Trade() {
weightOnDataToken: '', weightOnDataToken: '',
swapFee: '' swapFee: ''
} }
const tx = await createPricing(datatoken,priceOptions) const tx = await createPricing(datatoken, priceOptions)
console.log(tx) console.log(tx)
} }
} }
@ -51,7 +60,6 @@ export function Trade() {
<div> <div>
IsLoading: {pricingIsLoading.toString()} || Status: {pricingStepText} IsLoading: {pricingIsLoading.toString()} || Status: {pricingStepText}
</div> </div>
</> </>
) )
} }

View File

@ -6,7 +6,13 @@ import { Metadata } from '@oceanprotocol/lib/dist/node/ddo/interfaces/Metadata'
export function Publish() { export function Publish() {
const { publish, publishStepText, isLoading } = usePublish() const { publish, publishStepText, isLoading } = usePublish()
const { createPricing, pricingStep, pricingStepText, pricingIsLoading, pricingError} = usePricing() const {
createPricing,
pricingStep,
pricingStepText,
pricingIsLoading,
pricingError
} = usePricing()
const [ddo, setDdo] = useState<DDO | undefined | null>() const [ddo, setDdo] = useState<DDO | undefined | null>()
const asset = { const asset = {
@ -31,16 +37,12 @@ export function Publish() {
} }
const publishAsset = async () => { const publishAsset = async () => {
const datatokenOptions = {}
const datatokenOptions = {
}
const ddo = await publish(asset as Metadata, 'access', datatokenOptions) const ddo = await publish(asset as Metadata, 'access', datatokenOptions)
console.log(ddo) console.log(ddo)
setDdo(ddo) setDdo(ddo)
} }
return ( return (
<> <>
<div>Publish</div> <div>Publish</div>
@ -51,7 +53,6 @@ export function Publish() {
IsLoading: {isLoading.toString()} || Status: {publishStepText} IsLoading: {isLoading.toString()} || Status: {publishStepText}
</div> </div>
<div>DID: {ddo && ddo.id} </div> <div>DID: {ddo && ddo.id} </div>
</> </>
) )
} }

6
package-lock.json generated
View File

@ -1521,9 +1521,9 @@
"integrity": "sha512-p0oOHXr60hXZuLNsQ/PsOQtCfia79thm7MjPxTrnnBvD+csJoHzARYMB0IFj/KTw6U5vLXODgjJAn8x6QksLwg==" "integrity": "sha512-p0oOHXr60hXZuLNsQ/PsOQtCfia79thm7MjPxTrnnBvD+csJoHzARYMB0IFj/KTw6U5vLXODgjJAn8x6QksLwg=="
}, },
"@oceanprotocol/lib": { "@oceanprotocol/lib": {
"version": "0.8.0", "version": "0.9.0",
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.8.0.tgz", "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.9.0.tgz",
"integrity": "sha512-FZALOw3LMAPo2US+YjJv5Fkz7IDS9m89PZzF7uKZKYT8V3xB/m0PV91vV1pEPC0eVWk3Sl1IXyT0L3ASFEUjvg==", "integrity": "sha512-BI00ZXTdGXJZNTJhwtqsnXjKtlcl1PXB18e26aCo5g1VT9S19urPLT04k9Zkz4k+3HepSc5QdOu+yo47MS1I7g==",
"requires": { "requires": {
"@ethereum-navigator/navigator": "^0.5.0", "@ethereum-navigator/navigator": "^0.5.0",
"@oceanprotocol/contracts": "^0.5.7", "@oceanprotocol/contracts": "^0.5.7",

View File

@ -25,7 +25,7 @@
"dist/" "dist/"
], ],
"dependencies": { "dependencies": {
"@oceanprotocol/lib": "^0.8.0", "@oceanprotocol/lib": "^0.9.0",
"axios": "^0.21.0", "axios": "^0.21.0",
"decimal.js": "^10.2.1", "decimal.js": "^10.2.1",
"web3": "^1.3.0", "web3": "^1.3.0",

View File

@ -1,6 +1,7 @@
export interface PriceOptions { export interface PriceOptions {
price: number price: number
dtAmount: number dtAmount: number
oceanAmount: number
type: 'fixed' | 'dynamic' | string type: 'fixed' | 'dynamic' | string
weightOnDataToken: string weightOnDataToken: string
swapFee: string swapFee: string

View File

@ -201,7 +201,14 @@ function usePricing(ddo: DDO): UsePricing {
): Promise<TransactionReceipt | void> { ): Promise<TransactionReceipt | void> {
if (!ocean || !accountId || !dtSymbol) return if (!ocean || !accountId || !dtSymbol) return
const { type, dtAmount, price, weightOnDataToken, swapFee } = priceOptions const {
type,
dtAmount,
oceanAmount,
price,
weightOnDataToken,
swapFee
} = priceOptions
const isPool = type === 'dynamic' const isPool = type === 'dynamic'
if (!isPool && !config.fixedRateExchangeAddress) { if (!isPool && !config.fixedRateExchangeAddress) {
@ -224,6 +231,7 @@ function usePricing(ddo: DDO): UsePricing {
dataToken, dataToken,
`${dtAmount}`, `${dtAmount}`,
weightOnDataToken, weightOnDataToken,
`${oceanAmount}`,
swapFee swapFee
) )
.next((step: number) => setStep(step, 'pool')) .next((step: number) => setStep(step, 'pool'))