![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@cowprotocol/app-data
Advanced tools
AppData schema definitions
These schemas are used in the data encoded on appData
field for CowProtocol orders.
For more details, check the docs.
yarn add @cowprotocol/app-data
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: 1 } // 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,
},
})
Schemas are exposed as json files, where the version is the file name:
// Getting the version v0.4.0
const schema = require('@cowprotocol/app-data/schemas/v0.4.0.json')
// Now you can for example run validation against a schema
There are also type definitions
import { v0_4_0 } from '@cowprotocol/app-data'
// Note: this example is
function createAppDataV0_4_0(appCode: v0_4_0.AppCode, metadata: v0_4_0.Metadata): v0_4_0.AppDataRootSchema {
return {
version: '0.4.0',
appCode,
metadata,
}
}
The latest version names are exposed as constants
import {
LATEST_APP_DATA_VERSION,
LATEST_QUOTE_METADATA_VERSION,
LATEST_REFERRER_METADATA_VERSION,
} from '@cowprotocol/app-data'
Get appData schema
To get a schema definition by version
import { getAppDataSchema } from '@cowprotocol/app-data'
const schema = getAppDataSchema('0.1.0')
It'll throw if the version does not exist
Validate appDataDoc
To validate a document, pass it to validateAppDataDoc
.
It'll return an object with a boolean indicating success
and errors
, if any.
The version to validate against will be taken from the doc itself.
import { validateAppDataDoc } from '@cowprotocol/app-data'
let doc = { version: '0.4.0', metadata: {} }
let result = await validateAppDataDoc(doc)
console.log(result) // { success: true }
doc = { version: '0.0.0', metadata: {} }
result = await validateAppDataDoc(doc)
// Contrary to `getAppDataSchema`, invalid or non-existing schemas won't throw
console.log(result) // { success: false, errors: 'AppData version 0.0.0 doesn\'t exist'}
Fork the repo so you can create a new PR. Then:
src/schemas/<old-version>.json
to src/schemas/<new-version>.json
<meta-data-name>/v0.1.0.json
"$ref": "<meta-data-name>/v0.1.0.json#"
.<meta-data-name>/<new-version>.json
"<meta-data-name>": { "$ref": "<meta-data-name>/<new-version>.json#" }
compile.ts
scriptyarn build
FAQs
CowProtocol AppData schema definitions
The npm package @cowprotocol/app-data receives a total of 2,784 weekly downloads. As such, @cowprotocol/app-data popularity was classified as popular.
We found that @cowprotocol/app-data demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.