Skip to content

Commit

Permalink
feat: add dappId to hooks schema
Browse files Browse the repository at this point in the history
  • Loading branch information
shoom3301 committed Oct 2, 2024
1 parent bc6444c commit ccd0a67
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/schemas/definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
"title": "Order UID",
"examples": ["0xff2e2e54d178997f173266817c1e9ed6fee1a1aae4b43971c53b543cffcc2969845c6f5599fbb25dbdd1b9b013daf85c03f3c63763e4bc4a"],
"type": "string"
},
"dappId": {
"$id": "#/definitions/dappId",
"pattern": "^[a-fA-F0-9]{64}$",
"title": "A hex string representing a dApp ID",
"examples": ["75716a3cb48fdbb43ebdff58ce6c541f6a2c269be690513131355800367f2da2"],
"type": "string"
}
}
}
40 changes: 40 additions & 0 deletions src/schemas/hook/v0.2.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"$id": "#hook/v0.2.0.json",
"$schema": "http://json-schema.org/draft-07/schema",
"required": [
"target",
"callData",
"gasLimit"
],
"title": "CoW Hook",
"type": "object",
"additionalProperties": false,
"properties": {
"target": {
"$ref": "../definitions.json#/definitions/ethereumAddress",
"title": "Hook Target",
"description": "The contract to call for the hook"
},
"callData": {
"$id": "#/properties/callData",
"title": "Hook CallData",
"description": "The calldata to use when calling the hook",
"type": "string",
"pattern": "^0x[a-fA-F0-9]*$",
"examples": [
"0x",
"0x01020304"
]
},
"gasLimit": {
"$ref": "../definitions.json#/definitions/bigNumber",
"title": "Hook Gas Limit",
"description": "The gas limit (in gas units) for the hook"
},
"dappId": {
"$ref": "../definitions.json#/definitions/dappId",
"title": "Id of the dApp which has built the hook",
"description": "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."
}
}
}
35 changes: 35 additions & 0 deletions src/schemas/hooks/v0.2.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$id": "#hooks/v0.2.0.json",
"$schema": "http://json-schema.org/draft-07/schema",
"default": {},
"required": [],
"title": "Order interaction hooks",
"description": "Optional Pre and Post order interaction hooks attached to a single order",
"type": "object",
"additionalProperties": false,
"properties": {
"version": {
"$ref": "../definitions.json#/definitions/version",
"readOnly": true,
"default": "0.1.0"
},
"pre": {
"$id": "#/properties/hooks/pre",
"title": "Pre-Hooks",
"description": "CoW Hooks to call before an order executes",
"type": "array",
"items": {
"$ref": "../hook/v0.2.0.json#"
}
},
"post": {
"$id": "#/properties/hooks/post",
"title": "Post-Hooks",
"description": "CoW Hooks to call after an order executes",
"type": "array",
"items": {
"$ref": "../hook/v0.2.0.json#"
}
}
}
}
78 changes: 78 additions & 0 deletions src/schemas/v1.3.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"$id": "https://cowswap.exchange/schemas/app-data/v1.3.0.json",
"$schema": "http://json-schema.org/draft-07/schema",
"description": "Metadata JSON document for adding information to orders.",
"required": [
"version",
"metadata"
],
"title": "AppData Root Schema",
"type": "object",
"additionalProperties": false,
"properties": {
"version": {
"$ref": "definitions.json#/definitions/version",
"readOnly": true,
"default": "1.3.0"
},
"appCode": {
"$id": "#/properties/appCode",
"description": "The code identifying the CLI, UI, service generating the order.",
"examples": [
"CoW Swap"
],
"title": "App Code",
"type": "string"
},
"environment": {
"$id": "#/properties/environment",
"description": "Environment from which the order came from.",
"title": "Environment",
"type": "string",
"examples": [
"production",
"development",
"staging",
"ens"
]
},
"metadata": {
"$id": "#/properties/metadata",
"default": {},
"description": "Each metadata will specify one aspect of the order.",
"required": [],
"title": "Metadata",
"type": "object",
"additionalProperties": false,
"properties": {
"signer": {
"$ref": "signer/v0.1.0.json#"
},
"referrer": {
"$ref": "referrer/v0.2.0.json#"
},
"utm": {
"$ref": "utm/v0.2.0.json#"
},
"quote": {
"$ref": "quote/v1.1.0.json#"
},
"orderClass": {
"$ref": "orderClass/v0.3.0.json#"
},
"hooks": {
"$ref": "hooks/v0.2.0.json#"
},
"widget": {
"$ref": "widget/v0.1.0.json#"
},
"partnerFee": {
"$ref": "partnerFee/v0.1.0.json#"
},
"replacedOrder": {
"$ref": "replacedOrder/v0.1.0.json#"
}
}
}
}
}

0 comments on commit ccd0a67

Please sign in to comment.