Skip to content
This repository was archived by the owner on Jun 16, 2026. It is now read-only.

Commit 1955ff4

Browse files
authored
feat: add bridging metadata (#87)
* feat: add bridging metadata * chore: bump version to 3.2.0 * chore: relax types for bridging * chore: update regex * chore: fix test
1 parent 27f4810 commit 1955ff4

10 files changed

Lines changed: 540 additions & 97 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cowprotocol/app-data",
3-
"version": "3.1.0",
3+
"version": "3.2.0",
44
"description": "CoW Protocol AppData schema definitions",
55
"type": "module",
66
"source": "src/index.ts",
@@ -91,4 +91,4 @@
9191
"@babel/preset-typescript"
9292
]
9393
}
94-
}
94+
}

src/generatedTypes/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ import * as v1_1_0 from './v1.1.0'
1616
import * as v1_2_0 from './v1.2.0'
1717
import * as v1_3_0 from './v1.3.0'
1818
import * as v1_4_0 from './v1.4.0'
19+
import * as v1_5_0 from './v1.5.0'
1920

2021
export * from './latest'
2122

22-
export const LATEST_APP_DATA_VERSION = '1.4.0'
23+
export const LATEST_APP_DATA_VERSION = '1.5.0'
2324
export const LATEST_QUOTE_METADATA_VERSION = '1.1.0'
2425
export const LATEST_REFERRER_METADATA_VERSION = '0.2.0'
2526
export const LATEST_ORDER_CLASS_METADATA_VERSION = '0.3.0'
@@ -30,8 +31,9 @@ export const LATEST_WIDGET_METADATA_VERSION = '0.1.0'
3031
export const LATEST_PARTNER_FEE_METADATA_VERSION = '1.0.0'
3132
export const LATEST_REPLACED_ORDER_METADATA_VERSION = '0.1.0'
3233

33-
export type LatestAppDataDocVersion = v1_4_0.AppDataRootSchema
34+
export type LatestAppDataDocVersion = v1_5_0.AppDataRootSchema
3435
export type AnyAppDataDocVersion =
36+
| v1_5_0.AppDataRootSchema
3537
| v1_4_0.AppDataRootSchema
3638
| v1_3_0.AppDataRootSchema
3739
| v1_2_0.AppDataRootSchema
@@ -50,6 +52,7 @@ export type AnyAppDataDocVersion =
5052
| v0_1_0.AppDataRootSchema
5153

5254
export {
55+
v1_5_0,
5356
v1_4_0,
5457
v1_3_0,
5558
v1_2_0,

src/generatedTypes/latest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// generated file, do not edit manually
22

3-
export * as latest from './v1.4.0'
3+
export * as latest from './v1.5.0'

src/generatedTypes/v1.5.0.ts

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
/* tslint:disable */
2+
/**
3+
* This file was automatically generated by json-schema-to-typescript.
4+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
5+
* and run json-schema-to-typescript to regenerate this file.
6+
*/
7+
8+
/**
9+
* Semantic versioning of document.
10+
*/
11+
export type Version = string;
12+
/**
13+
* The code identifying the CLI, UI, service generating the order.
14+
*/
15+
export type AppCode = string;
16+
/**
17+
* Environment from which the order came from.
18+
*/
19+
export type Environment = string;
20+
/**
21+
* The address of the trader who signs the CoW Swap order. This field should normally be omitted; it is recommended to use it if the signer is a smart-contract wallet using EIP-1271 signatures.
22+
*/
23+
export type Signer = string;
24+
export type ReferrerAddress = string;
25+
/**
26+
* Tracks in which medium the traffic originated from (twitter, facebook, etc.)
27+
*/
28+
export type UTMSource = string;
29+
/**
30+
* Tracks in which medium the traffic originated from (mail, CPC, social, etc.)
31+
*/
32+
export type UTMMedium = string;
33+
/**
34+
* Track the performance of a specific campaign
35+
*/
36+
export type UTMCampaign = string;
37+
/**
38+
* Track which link was clicked
39+
*/
40+
export type UTMContent = string;
41+
/**
42+
* Track which keyword term a website visitor came from
43+
*/
44+
export type UTMKeywordTerm = string;
45+
/**
46+
* Slippage tolerance that was applied to the order to get the limit price. Expressed in Basis Points (BPS). One basis point is equivalent to 0.01% (1/100th of a percent)
47+
*/
48+
export type SlippageBips = number;
49+
/**
50+
* Whether the given slippageBips used is originated from a Smart slippage suggestion
51+
*/
52+
export type SmartSlippage = boolean;
53+
/**
54+
* Indicator of the order class.
55+
*/
56+
export type OrderClass1 = "market" | "limit" | "liquidity" | "twap";
57+
/**
58+
* Semantic versioning of document.
59+
*/
60+
export type Version1 = string;
61+
/**
62+
* The contract to call for the hook
63+
*/
64+
export type HookTarget = string;
65+
/**
66+
* The calldata to use when calling the hook
67+
*/
68+
export type HookCallData = string;
69+
/**
70+
* The gas limit (in gas units) for the hook
71+
*/
72+
export type HookGasLimit = string;
73+
/**
74+
* CoW Swap has an interface that allows dApps to build hooks for orders. This field is used to identify the dApp that has built the hook.
75+
*/
76+
export type IdOfTheDAppWhichHasBuiltTheHook = string;
77+
/**
78+
* CoW Hooks to call before an order executes
79+
*/
80+
export type PreHooks = CoWHook[];
81+
/**
82+
* CoW Hooks to call after an order executes
83+
*/
84+
export type PostHooks = CoWHook[];
85+
/**
86+
* The code identifying the UI powering the widget
87+
*/
88+
export type AppCode1 = string;
89+
/**
90+
* Environment from which the order came from.
91+
*/
92+
export type Environment1 = string;
93+
export type PartnerFee =
94+
| (
95+
| {
96+
volumeBps: VolumeBasisPointBPS;
97+
recipient: PartnerAccount;
98+
}
99+
| {
100+
surplusBps: SurplusBasisPointBPS;
101+
maxVolumeBps: MaxVolumeBasisPointBPS;
102+
recipient: PartnerAccount;
103+
}
104+
| {
105+
priceImprovementBps: PriceImprovementBasisPointBPS;
106+
maxVolumeBps: MaxVolumeBasisPointBPS;
107+
recipient: PartnerAccount;
108+
}
109+
)[]
110+
| (
111+
| {
112+
volumeBps: VolumeBasisPointBPS;
113+
recipient: PartnerAccount;
114+
}
115+
| {
116+
surplusBps: SurplusBasisPointBPS;
117+
maxVolumeBps: MaxVolumeBasisPointBPS;
118+
recipient: PartnerAccount;
119+
}
120+
| {
121+
priceImprovementBps: PriceImprovementBasisPointBPS;
122+
maxVolumeBps: MaxVolumeBasisPointBPS;
123+
recipient: PartnerAccount;
124+
}
125+
);
126+
/**
127+
* The fee in basis points (BPS) to be paid to the partner based on volume. Capped at protocol level to 100 BPS (1%)
128+
*/
129+
export type VolumeBasisPointBPS = number;
130+
/**
131+
* The Ethereum address of the partner to receive the fee.
132+
*/
133+
export type PartnerAccount = string;
134+
/**
135+
* The fee in basis points (BPS) to be paid to the partner based on surplus
136+
*/
137+
export type SurplusBasisPointBPS = number;
138+
/**
139+
* The maximum volume in basis points (BPS) to be paid to the partner. Capped at protocol level to 100 BPS (1%). You can chose to go lower but not higher
140+
*/
141+
export type MaxVolumeBasisPointBPS = number;
142+
/**
143+
* The fee in basis points (BPS) to be paid to the partner based on price improvement
144+
*/
145+
export type PriceImprovementBasisPointBPS = number;
146+
/**
147+
* The replaced order UID.
148+
*/
149+
export type ReplacedOrderUID = string;
150+
/**
151+
* Id of a blockchain where funds will be received
152+
*/
153+
export type BridgingDestinationChainId = string;
154+
/**
155+
* Address of a token that will be received at destination chain. The chain might be EVM or non-EVM. Some chains might even not have a token address. E.g.: Bitcoin
156+
*/
157+
export type BridgingDestinationTokenAddress = string;
158+
159+
/**
160+
* Metadata JSON document for adding information to orders.
161+
*/
162+
export interface AppDataRootSchema {
163+
version: Version;
164+
appCode?: AppCode;
165+
environment?: Environment;
166+
metadata: Metadata;
167+
}
168+
/**
169+
* Each metadata will specify one aspect of the order.
170+
*/
171+
export interface Metadata {
172+
signer?: Signer;
173+
referrer?: Referrer;
174+
utm?: UTMCodes;
175+
quote?: Quote;
176+
orderClass?: OrderClass;
177+
hooks?: OrderInteractionHooks;
178+
widget?: Widget;
179+
partnerFee?: PartnerFee;
180+
replacedOrder?: ReplacedOrder;
181+
bridging?: Bridging;
182+
}
183+
export interface Referrer {
184+
address: ReferrerAddress;
185+
}
186+
export interface UTMCodes {
187+
utmSource?: UTMSource;
188+
utmMedium?: UTMMedium;
189+
utmCampaign?: UTMCampaign;
190+
utmContent?: UTMContent;
191+
utmTerm?: UTMKeywordTerm;
192+
}
193+
export interface Quote {
194+
slippageBips: SlippageBips;
195+
smartSlippage?: SmartSlippage;
196+
}
197+
export interface OrderClass {
198+
orderClass: OrderClass1;
199+
}
200+
/**
201+
* Optional Pre and Post order interaction hooks attached to a single order
202+
*/
203+
export interface OrderInteractionHooks {
204+
version?: Version1;
205+
pre?: PreHooks;
206+
post?: PostHooks;
207+
}
208+
export interface CoWHook {
209+
target: HookTarget;
210+
callData: HookCallData;
211+
gasLimit: HookGasLimit;
212+
dappId?: IdOfTheDAppWhichHasBuiltTheHook;
213+
}
214+
export interface Widget {
215+
appCode: AppCode1;
216+
environment?: Environment1;
217+
}
218+
export interface ReplacedOrder {
219+
uid: ReplacedOrderUID;
220+
}
221+
export interface Bridging {
222+
destinationChainId: BridgingDestinationChainId;
223+
destinationTokenAddress: BridgingDestinationTokenAddress;
224+
}

src/schemas/bridging/v0.1.0.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"$id": "#bridging/v0.1.0.json",
3+
"$schema": "http://json-schema.org/draft-07/schema",
4+
"required": [
5+
"destinationChainId",
6+
"destinationTokenAddress"
7+
],
8+
"title": "Bridging",
9+
"type": "object",
10+
"additionalProperties": false,
11+
"properties": {
12+
"destinationChainId": {
13+
"$ref": "../definitions.json#/definitions/chainId",
14+
"title": "Bridging destination chainId",
15+
"description": "Id of a blockchain where funds will be received"
16+
},
17+
"destinationTokenAddress": {
18+
"title": "Bridging destination token address",
19+
"description": "Address of a token that will be received at destination chain. The chain might be EVM or non-EVM. Some chains might even not have a token address. E.g.: Bitcoin",
20+
"type": "string",
21+
"pattern": "^[a-zA-Z0-9\\-.]{1,64}$",
22+
"examples": [
23+
"0x00E989b87700514118Fa55326CD1cCE82faebEF6",
24+
"A.b19436aae4d94622.FiatToken",
25+
"0.0.456858",
26+
"1337"
27+
]
28+
}
29+
}
30+
}

src/schemas/definitions.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@
4747
"title": "A hex string representing a dApp ID",
4848
"examples": ["75716a3cb48fdbb43ebdff58ce6c541f6a2c269be690513131355800367f2da2"],
4949
"type": "string"
50+
},
51+
"chainId": {
52+
"$id": "#/definitions/chainId",
53+
"pattern": "^[a-zA-Z0-9\\-_]{1,32}$",
54+
"title": "Blockchain id",
55+
"examples": [
56+
"1",
57+
"100",
58+
"hedera-hashgraph"
59+
],
60+
"type": "string"
5061
}
5162
}
5263
}

0 commit comments

Comments
 (0)