Skip to content
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #164 from oceanprotocol/update/ocean.js-bump
Browse files Browse the repository at this point in the history
Update/ocean.js bump
  • Loading branch information
kremalicious authored Oct 26, 2020
2 parents 02b214b + 76a5953 commit 45c9d47
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 19 deletions.
22 changes: 15 additions & 7 deletions example/src/Pricing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,38 @@ import { Metadata } from '@oceanprotocol/lib/dist/node/ddo/interfaces/Metadata'

export function Trade() {
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 handleBuy = async () => {
const tx = await buyDT(datatoken,'1')
const tx = await buyDT(datatoken, '1')
console.log(tx)
}
const handleSell = async () => {
const tx = await buyDT(datatoken,'1')
console.log(tx)
const tx = await buyDT(datatoken, '1')
console.log(tx)
}
const handleChange = (e: any) => {
setDatatoken(e.target.value)
}
const handlePostForSale = async () => {
if(datatoken){
if (datatoken) {
const priceOptions = {
price: 7,
dtAmount: 10,
type: 'fixed',
weightOnDataToken: '',
swapFee: ''
}
const tx = await createPricing(datatoken,priceOptions)
const tx = await createPricing(datatoken, priceOptions)
console.log(tx)
}
}
Expand All @@ -51,7 +60,6 @@ export function Trade() {
<div>
IsLoading: {pricingIsLoading.toString()} || Status: {pricingStepText}
</div>

</>
)
}
15 changes: 8 additions & 7 deletions example/src/Publish.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import { Metadata } from '@oceanprotocol/lib/dist/node/ddo/interfaces/Metadata'

export function Publish() {
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 asset = {
Expand All @@ -31,16 +37,12 @@ export function Publish() {
}

const publishAsset = async () => {

const datatokenOptions = {

}
const datatokenOptions = {}
const ddo = await publish(asset as Metadata, 'access', datatokenOptions)
console.log(ddo)
setDdo(ddo)
}


return (
<>
<div>Publish</div>
Expand All @@ -51,7 +53,6 @@ export function Publish() {
IsLoading: {isLoading.toString()} || Status: {publishStepText}
</div>
<div>DID: {ddo && ddo.id} </div>

</>
)
}
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"dist/"
],
"dependencies": {
"@oceanprotocol/lib": "^0.8.0",
"@oceanprotocol/lib": "^0.9.0",
"axios": "^0.21.0",
"decimal.js": "^10.2.1",
"web3": "^1.3.0",
Expand Down
1 change: 1 addition & 0 deletions src/hooks/usePricing/PriceOptions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export interface PriceOptions {
price: number
dtAmount: number
oceanAmount: number
type: 'fixed' | 'dynamic' | string
weightOnDataToken: string
swapFee: string
Expand Down
10 changes: 9 additions & 1 deletion src/hooks/usePricing/usePricing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,14 @@ function usePricing(ddo: DDO): UsePricing {
): Promise<TransactionReceipt | void> {
if (!ocean || !accountId || !dtSymbol) return

const { type, dtAmount, price, weightOnDataToken, swapFee } = priceOptions
const {
type,
dtAmount,
oceanAmount,
price,
weightOnDataToken,
swapFee
} = priceOptions
const isPool = type === 'dynamic'

if (!isPool && !config.fixedRateExchangeAddress) {
Expand All @@ -224,6 +231,7 @@ function usePricing(ddo: DDO): UsePricing {
dataToken,
`${dtAmount}`,
weightOnDataToken,
`${oceanAmount}`,
swapFee
)
.next((step: number) => setStep(step, 'pool'))
Expand Down

0 comments on commit 45c9d47

Please sign in to comment.