Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README examples fail #63

Open
pata-eth opened this issue Aug 23, 2024 · 0 comments
Open

README examples fail #63

pata-eth opened this issue Aug 23, 2024 · 0 comments

Comments

@pata-eth
Copy link

hi, folks. I started a node project from scratch to test out this module. I placed the following snippet from the README into index.js

import { MetadataApi } from '@cowprotocol/app-data'

export const metadataApi = new MetadataApi()

const appCode = 'YOUR_APP_CODE'
const environment = 'prod'
const referrer = { address: `REFERRER_ADDRESS` }

const quote = { slippageBips: '0.5' } // Slippage percent, it's 0 to 100
const orderClass = { orderClass: 'market' } // "market" | "limit" | "liquidity"

const appDataDoc = await metadataApi.generateAppDataDoc({
  appCode,
  environment,
  metadata: {
    referrer,
    quote,
    orderClass,
  },
})

const { cid, appDataHex, appDataContent } = await metadataApi.appDataToCid(appDataDoc)

run node index.js and fails with

[Error]: Invalid appData provided: AppData version 1.1.0 doesn't exist
    at f (file:///Users/pata/projects/appdata/node_modules/@cowprotocol/app-data/dist/index.modern.mjs:1:2169)

package.json needs "type": "module" to run this script and replicate. What am I missing? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant