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

lib update #106

Merged
merged 1 commit into from
Sep 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
202 changes: 20 additions & 182 deletions example/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"eject": "react-app-rewired eject"
},
"dependencies": {
"@oceanprotocol/lib": "^0.1.17",
"@oceanprotocol/lib": "^0.2.0",
"@oceanprotocol/react": "file:../",
"react": "^16.13.1",
"react-dom": "^16.13.1",
Expand Down
2 changes: 1 addition & 1 deletion example/src/Publish.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function Publish() {
liquidityProviderFee: ''
}

const ddo = await publish(asset as Metadata, priceOptions, 'access', '', '')
const ddo = await publish(asset as Metadata, priceOptions, 'access')
console.log(ddo)
setDdo(ddo)
}
Expand Down
26 changes: 17 additions & 9 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.1.17",
"@oceanprotocol/lib": "^0.2.0",
"axios": "^0.20.0",
"decimal.js": "^10.2.0",
"web3": "^1.2.11",
Expand Down
5 changes: 5 additions & 0 deletions src/hooks/usePublish/DataTokenOptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface DataTokenOptions {
cap?: string
name?: string
symbol?: string
}
1 change: 1 addition & 0 deletions src/hooks/usePublish/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './usePublish'
export * from './PriceOptions'
export * from './DataTokenOptions'
17 changes: 13 additions & 4 deletions src/hooks/usePublish/usePublish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
} from '@oceanprotocol/lib/dist/node/ddo/interfaces/Service'
import { PriceOptions } from './PriceOptions'
import { publishFeedback } from '../../utils'
import { DataTokenOptions } from '.'

interface UsePublish {
publish: (
asset: Metadata,
priceOptions: PriceOptions,
serviceConfigs: ServiceType,
mpAddress: string,
mpFee: string
dataTokenOptions?: DataTokenOptions
) => Promise<DDO>
mint: (tokenAddress: string, tokensToMint: string) => void
publishStep?: number
Expand All @@ -42,14 +42,16 @@ function usePublish(): UsePublish {
* @param {Metadata} asset The metadata of the asset.
* @param {PriceOptions} priceOptions : number of tokens to mint, datatoken weight , liquidity fee, type : fixed, dynamic
* @param {ServiceType} serviceType Desired service type of the asset access or compute
* @param {DataTokenOptions} dataTokenOptions custom name, symbol and cap for datatoken
* @param {string} mpAddress The address of the market
* @param {string} mpFee The fee of the market
* @return {Promise<DDO>} Returns the newly published ddo
*/
async function publish(
asset: Metadata,
priceOptions: PriceOptions,
serviceType: ServiceType
serviceType: ServiceType,
dataTokenOptions?: DataTokenOptions
): Promise<DDO> {
if (status !== ProviderStatus.CONNECTED || !ocean || !account) return
setIsLoading(true)
Expand Down Expand Up @@ -126,7 +128,14 @@ function usePublish(): UsePublish {
Logger.log('services created', services)

const ddo = await ocean.assets
.create(asset, account, services)
.create(
asset,
account,
services,
dataTokenOptions?.cap,
dataTokenOptions?.name,
dataTokenOptions?.symbol
)
.next(setStep)
Logger.log('ddo created', ddo)
setStep(7)
Expand Down