@cowprotocol/app-data
AppData schema definitions
These schemas are used in the data encoded on appData
field for CowProtocol orders.
For more details, check the docs.
Usage
Schemas
Schemas are exposed as json files, where the version is the file name:
const schema = require('@cowprotocol/app-data/schemas/v0.4.0.json')
Type definitions
There are also type definitions
import {v0_4_0} from '@cowprotocol/app-data'
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
}
}
Constants
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'
Utils
There are util functions to handle the creation of valid schema docs for the latest version
import {
createAppDataDoc, createReferrerMetadata, createQuoteMetadata
} from '@cowprotocol/app-data'
const referrer = createReferrerMetadata({address: '0x...'})
const quote = createQuoteMetadata({slippageBips: '100'})
const appDataDoc = createAppDataDoc({appCode: 'myApp', metadata: {referrer, quote}})
TODO: