Skip to main content

Class: MetadataApi

Constructors

constructor

new MetadataApi(): MetadataApi

Returns

MetadataApi

Properties

appDataHexToCid

appDataHexToCid: (appDataHex: string) => Promise<string> = appDataHexToCid

Type declaration

▸ (appDataHex): Promise<string>

Convert an app-data hex string to a CID

Parameters
NameTypeDescription
appDataHexstringThe app-data hex string (app-data part of the order struct)
Returns

Promise<string>

The IPFS CID v1 of the content

Defined in

api/index.ts:20


cidToAppDataHex

cidToAppDataHex: (cid: string) => Promise<string> = cidToAppDataHex

Type declaration

▸ (cid): Promise<string>

Convert a CID to an app-data hex string

Parameters
NameTypeDescription
cidstringThe IPFS CID to extract the app-data hex from.
Returns

Promise<string>

The app-data hex string (app-data part of the order struct)

Defined in

api/index.ts:21


fetchDocFromAppDataHex

fetchDocFromAppDataHex: (appDataHex: string, ipfsUri?: string) => Promise<void | AnyAppDataDocVersion> = fetchDocFromAppDataHex

Type declaration

▸ (appDataHex, ipfsUri?): Promise<void | AnyAppDataDocVersion>

Fetches the document from IPFS using the appData hex (app-data part of the order struct).

This method will convert the app-data hex into a CID and fetch the content from IPFS.

Parameters
NameTypeDescription
appDataHexstringApp-data hex part of the order struct
ipfsUri?stringURL of the IPFS gateway to use for the fetch
Returns

Promise<void | AnyAppDataDocVersion>

a parsed AppData document

Defined in

api/index.ts:24


generateAppDataDoc

generateAppDataDoc: (params?: Partial<Omit<AppDataRootSchema, "version">>) => Promise<LatestAppDataDocVersion> = generateAppDataDoc

Type declaration

▸ (params?): Promise<LatestAppDataDocVersion>

Creates an appData document using the latest specification of the format

Without params creates a default minimum appData doc Optionally creates metadata docs

Example of result: { "appCode": "CoW Swap", "environment": "local", "metadata": { "quote": { "slippageBips": 50 }, "orderClass": { "orderClass": "market" } }, "version": "1.2.0" }

Parameters
NameType
params?Partial<Omit<AppDataRootSchema, "version">>
Returns

Promise<LatestAppDataDocVersion>

Defined in

api/index.ts:15


getAppDataInfo

getAppDataInfo: (appData: AnyAppDataDocVersion) => Promise<AppDataInfo>(fullAppData: string) => Promise<AppDataInfo | undefined> = getAppDataInfo

Type declaration

▸ (appData): Promise<AppDataInfo>

Calculate the app-data information (cid, appDataHex, appDataContent).

  • appDataContent is the exact string with the pre-image that gets hashed using keccak to get the appDataHex
  • appDataHex is the hex used for the bytes32 struct field appData in the CoW order
  • cid is the IPFS identifier of the appDataHex. If the document is in IPFS it can be found using this identifier.
Parameters
NameType
appDataAnyAppDataDocVersion
Returns

Promise<AppDataInfo>

▸ (fullAppData): Promise<AppDataInfo | undefined>

Calculate the app-data information (cid, appDataHex, appDataContent).

  • appDataContent is the exact string with the pre-image that gets hashed using keccak to get the appDataHex
  • appDataHex is the hex used for the bytes32 struct field appData in the CoW order
  • cid is the IPFS identifier of the appDataHex. If the document is in IPFS it can be found using this identifier.
Parameters
NameType
fullAppDatastring
Returns

Promise<AppDataInfo | undefined>

Defined in

api/index.ts:19


getAppDataSchema

getAppDataSchema: (version: string) => Promise<AnyAppDataDocVersion> = getAppDataSchema

Type declaration

▸ (version): Promise<AnyAppDataDocVersion>

Wrapper around @cowprotocol/app-data getAppDataSchema

Returns the appData schema for given version, if any Throws CowError when version doesn't exist

Parameters
NameType
versionstring
Returns

Promise<AnyAppDataDocVersion>

Defined in

api/index.ts:14


legacy

legacy: Object

Type declaration

NameType
appDataHexToCid(appDataHex: string) => Promise<string>
appDataToCid(appData: AnyAppDataDocVersion) => Promise<AppDataInfo | undefined>(fullAppData: string) => Promise<AppDataInfo | undefined>
fetchDocFromAppDataHex(appDataHex: string, ipfsUri?: string) => Promise<void | AnyAppDataDocVersion>
fetchDocFromCid(cid: string, ipfsUri: string) => Promise<AnyAppDataDocVersion>
uploadMetadataDocToIpfs(appDataDoc: AnyAppDataDocVersion, ipfsConfig: Ipfs) => Promise<IpfsUploadResult | void>

Defined in

api/index.ts:26


validateAppDataDoc

validateAppDataDoc: (appDataDoc: AnyAppDataDocVersion) => Promise<ValidationResult> = validateAppDataDoc

Type declaration

▸ (appDataDoc): Promise<ValidationResult>

Parameters
NameType
appDataDocAnyAppDataDocVersion
Returns

Promise<ValidationResult>

Defined in

api/index.ts:16