deltaDAO / nautilus

The Data Economy TypeScript Toolkit
https://nautilus.delta-dao.com
Apache License 2.0
4 stars 2 forks source link

[BUG] Cannot create Service with parameter #69

Closed BjBe82 closed 6 months ago

BjBe82 commented 6 months ago

Summary

I tried to create a SaaS service description, which produces multiple errors when using the Nautilus API. To dig down what the error is i replaced all the code with the provided example code to publish a service see below. The only thing changed was to add a parameter.

export async function publishAnalysisStack(
  nautilus: Nautilus,
  networkConfig: NetworkConfig,
  pricingConfig: PricingConfigWithoutOwner,
  wallet: Wallet,
) {
  const owner = await wallet.getAddress();
  console.log(`The owner address is ${owner}`);
  const serviceBuilder = new ServiceBuilder({
    serviceType: ServiceTypes.ACCESS,
    fileType: FileTypes.URL,
  }); // access type dataset with URL data source

  const urlFile: UrlFile = {
    type: 'url', // there are multiple supported data source types, see https://docs.oceanprotocol.com/developers/storage
    url: 'https://raw.githubusercontent.com/deltaDAO/nautilus-examples/main/example_publish_assets/example-dataset.json', // link to your file or api
    method: 'GET', // HTTP request method
  };

  const consumerParameterBuilder = new ConsumerParameterBuilder();
  const petitionerParam = consumerParameterBuilder
    .setType('text')
    .setName('Public Address')
    .setLabel('Public Address Label')
    .setDescription('Web3 Public Address of the petitioner.')
    .setRequired(true)
    .build();

  const service = serviceBuilder
    .setServiceEndpoint(networkConfig.providerUri)
    .setTimeout(60)
    .addFile(urlFile)
    .setPricing(pricingConfig)
    .addConsumerParameter(petitionerParam)
    .setDatatokenNameAndSymbol('My Datatoken Name', 'SYMBOL') // important for following access token transactions in the explorer
    .build();

  const assetBuilder = new AssetBuilder();
  const asset = assetBuilder
    .setType('dataset')
    .setName('Nautilus-Example: Access Dataset Name')
    .setDescription(
      '# Nautilus-Example Description \n\nThis asset has been published using the [nautilus-examples](https://github.com/deltaDAO/nautilus-examples) repository.',
    )
    .setAuthor('Company Name')
    .setLicense('MIT')
    .addService(service)
    .setOwner(owner)
    .build();

  const result = await nautilus.publish(asset);
  console.log(result);
}

Current Behavior

Trying to execute the code throws an error:

Error: Validating Metadata failed: [object Object]
    at E:\Arbeit\COOP\coop-stack\gaia-x-nautilus\node_modules\@deltadao\nautilus\dist\lib.js:1:26030
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async publishAnalysisStack (E:\Arbeit\COOP\coop-stack\gaia-x-nautilus\dist\publish-analysis-stack.js:43:20)
    at async main (E:\Arbeit\COOP\coop-stack\gaia-x-nautilus\dist\index.js:42:20)

Expected Behavior

A Service description with parameter is available in the portal.

Environment

moritzkirstein commented 6 months ago

Hi @BjBe82

From the example above it looks like you are missing the setDefault() function in the consumerParameter. As of right now a default value is required as defined in the OceanProtocol DDO spec.

 const consumerParameterBuilder = new ConsumerParameterBuilder();
  const petitionerParam = consumerParameterBuilder
    .setType('text')
    .setName('Public Address')
    .setLabel('Public Address Label')
    .setDescription('Web3 Public Address of the petitioner.')
    .setRequired(true)
    .setDefault('my default value') // add this to match the DDO spec
    .build();
BjBe82 commented 6 months ago

Thanks. With the default value, the code above runs. The service does not show up in https://cooperants.pontus-x.eu/profile, but this might be another issue.