From f89947b473e92c92f24b47cbf2fb62aa288d1d71 Mon Sep 17 00:00:00 2001 From: shoom3301 Date: Mon, 30 Sep 2024 16:06:02 +0500 Subject: [PATCH] feat: add dappId to hooks schema --- src/schemas/definitions.json | 7 ++++ src/schemas/hook/v0.2.0.json | 40 ++++++++++++++++++++++ src/schemas/hooks/v0.2.0.json | 35 ++++++++++++++++++++ src/schemas/v0.12.0.json | 62 +++++++++++++++++++++++++++++++++++ 4 files changed, 144 insertions(+) create mode 100644 src/schemas/hook/v0.2.0.json create mode 100644 src/schemas/hooks/v0.2.0.json create mode 100644 src/schemas/v0.12.0.json diff --git a/src/schemas/definitions.json b/src/schemas/definitions.json index bdefabf..06f3165 100644 --- a/src/schemas/definitions.json +++ b/src/schemas/definitions.json @@ -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" } } } diff --git a/src/schemas/hook/v0.2.0.json b/src/schemas/hook/v0.2.0.json new file mode 100644 index 0000000..5e29ea9 --- /dev/null +++ b/src/schemas/hook/v0.2.0.json @@ -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." + } + } +} diff --git a/src/schemas/hooks/v0.2.0.json b/src/schemas/hooks/v0.2.0.json new file mode 100644 index 0000000..53b7ccc --- /dev/null +++ b/src/schemas/hooks/v0.2.0.json @@ -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#" + } + } + } +} diff --git a/src/schemas/v0.12.0.json b/src/schemas/v0.12.0.json new file mode 100644 index 0000000..54c18eb --- /dev/null +++ b/src/schemas/v0.12.0.json @@ -0,0 +1,62 @@ +{ + "$id": "https://cowswap.exchange/schemas/app-data/v0.12.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": "0.12.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/v0.3.0.json#" + }, + "orderClass": { + "$ref": "orderClass/v0.3.0.json#" + }, + "hooks": { + "$ref": "hooks/v0.2.0.json#" + }, + "widget": { + "$ref": "widget/v0.1.0.json#" + } + } + } + } +}