From 19a974959f5a26996655dcec60e90c06aacc8ba4 Mon Sep 17 00:00:00 2001 From: ty4g1 Date: Thu, 11 Jul 2024 14:31:09 +0800 Subject: [PATCH 1/9] added typeform survey widget config --- config.schema.json | 20 ++++++++++++++++++++ configs/mainnet.json | 10 +++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/config.schema.json b/config.schema.json index 61e0aa3..3f7ccc9 100644 --- a/config.schema.json +++ b/config.schema.json @@ -167,6 +167,21 @@ } } }, + "typeform_widget_config": { + "type": "object", + "description": "Config for typeform survey widget", + "properties": { + "surveyLink": { + "type": "string" + }, + "endTime": { + "$ref": "#/$defs/survey_end" + }, + "pages": { + "type": "array" + } + } + }, "$defs": { "prelaunch_market": { "type": "string", @@ -237,6 +252,11 @@ "cross_selling_source_token": { "type": "string", "description": "Cross selling source token denom" + }, + "survey_end": { + "type": "string", + "description": "The end time of the tyepform survey", + "pattern": "^\\d{4}(-\\d\\d(-\\d\\d(T\\d\\d:\\d\\d(:\\d\\d)?(\\.\\d+)?(([+-]\\d\\d:\\d\\d)|Z)?)?)?)?$" } } } \ No newline at end of file diff --git a/configs/mainnet.json b/configs/mainnet.json index d70839f..2d8904e 100644 --- a/configs/mainnet.json +++ b/configs/mainnet.json @@ -218,5 +218,13 @@ "perpTradingBoost": 3 } }, - "cross_selling_source_tokens": ["swth"] + "cross_selling_source_tokens": ["swth"], + "typeform_widget_config": { + "surveyLink": "https://switcheonetwork.typeform.com/to/C1rheplK", + "endTime": "2024-07-26T23:00:00Z", + "pages": [ + "/account/overview", + "/account/balance" + ] + } } From 54cc0059f0ade59efe07c885c4f87901881dc91e Mon Sep 17 00:00:00 2001 From: ty4g1 Date: Thu, 11 Jul 2024 16:53:18 +0800 Subject: [PATCH 2/9] updated pr_template and README --- .github/markets/pr_template.md | 11 +++++++++-- README.md | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/markets/pr_template.md b/.github/markets/pr_template.md index ed4bd64..d6d383f 100644 --- a/.github/markets/pr_template.md +++ b/.github/markets/pr_template.md @@ -17,7 +17,7 @@ Each json file under the [configs](../../configs) folder correspond to their res |`demex_points_config` |`DemexPointsConfig` |false |Object that contains the parameters to earn demex points. |This object **must be included** for mainnet.json as demex points is already live on mainnet. | |`perp_pool_promo` |`PerpPoolPromo` |false |Map of Objects that contains perp pool promo parameters for each pool |If the `perp_pool_promo` property is omitted, no promo will be shown. The key of each entry is the ids of the perp pools with existing promo. | |`cross_selling_source_tokens` |`string[]` |true |The array of cross selling source tokens. Acquiring these tokens on the spot market will trigger a help wizard, prompting users to borrow USDG and trade perps on Demex. |The token denoms listed here **MUST** match the token denoms listed under the Carbon [Tokens API](https://api.carbon.network/carbon/coin/v1/tokens?pagination.limit=10000). | - +|`typeform_widget_config` |`TypeformWidgetConfig` |false |Object that contains the parameters for ongoing surveys. | ## Maintenance Data Structure |Field |Type |Required |Description |Notes | |---|---|---|---|---| @@ -47,4 +47,11 @@ Each json file under the [configs](../../configs) folder correspond to their res |`start` |`string` |true |Start time of the promo. | |`end` |`string` |true |End time of the promo. | |`perpPoolDepositBoost` |`integer` |true |Boost to perp pool deposits required to earn 1 demex point spin. | -|`perpTradingBoost` |`integer` |true |Boost to trading volume required to earn 1 demex point spin. | \ No newline at end of file +|`perpTradingBoost` |`integer` |true |Boost to trading volume required to earn 1 demex point spin. | + +## TypeformWidgetConfig +|Field |Type |Required |Description |Notes | +|---|---|---|---|---| +|`surveyLink` |`string` |true |The link to the survey that will be shown when user clicks ont he widget. | +|`endTime` |`string` |true |End time of the survey | +|`pages` |`string[]` | true |The paths to the pages on which the typeform widget must be shown. \ No newline at end of file diff --git a/README.md b/README.md index b29a604..97fd52d 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Currently, each JSON file contain the following data on its corresponding networ Additionally, the JSON file for mainnet contains the following data to support ongoing campaigns/promotions: - demex points config - perp pool promotion parameters +- typeform survey parameters More metadata will be added in the future if required by the Demex frontend. Please see below the structure of the JSON file: From c06495a1901424b6efcff978db46b7457e0b0663 Mon Sep 17 00:00:00 2001 From: ty4g1 Date: Thu, 11 Jul 2024 17:02:39 +0800 Subject: [PATCH 3/9] Updated schema to support multiple surveys --- .github/markets/pr_template.md | 2 +- config.schema.json | 30 +++++++++++++++++++----------- configs/mainnet.json | 18 ++++++++++-------- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/.github/markets/pr_template.md b/.github/markets/pr_template.md index d6d383f..30053f4 100644 --- a/.github/markets/pr_template.md +++ b/.github/markets/pr_template.md @@ -52,6 +52,6 @@ Each json file under the [configs](../../configs) folder correspond to their res ## TypeformWidgetConfig |Field |Type |Required |Description |Notes | |---|---|---|---|---| -|`surveyLink` |`string` |true |The link to the survey that will be shown when user clicks ont he widget. | +|`surveyLink` |`string` |true |The link to the survey that will be shown when user clicks on the widget. | |`endTime` |`string` |true |End time of the survey | |`pages` |`string[]` | true |The paths to the pages on which the typeform widget must be shown. \ No newline at end of file diff --git a/config.schema.json b/config.schema.json index 3f7ccc9..47acd2d 100644 --- a/config.schema.json +++ b/config.schema.json @@ -168,17 +168,25 @@ } }, "typeform_widget_config": { - "type": "object", - "description": "Config for typeform survey widget", - "properties": { - "surveyLink": { - "type": "string" - }, - "endTime": { - "$ref": "#/$defs/survey_end" - }, - "pages": { - "type": "array" + "type": "array", + "description": "Ongoing survey configs for typeform survey widget", + "items": { + "type": "object", + "required": [ + "surveyLink", + "endTime", + "pages" + ], + "properties": { + "surveyLink": { + "type": "string" + }, + "endTime": { + "$ref": "#/$defs/survey_end" + }, + "pages": { + "type": "array" + } } } }, diff --git a/configs/mainnet.json b/configs/mainnet.json index 2d8904e..607e25c 100644 --- a/configs/mainnet.json +++ b/configs/mainnet.json @@ -219,12 +219,14 @@ } }, "cross_selling_source_tokens": ["swth"], - "typeform_widget_config": { - "surveyLink": "https://switcheonetwork.typeform.com/to/C1rheplK", - "endTime": "2024-07-26T23:00:00Z", - "pages": [ - "/account/overview", - "/account/balance" - ] - } + "typeform_widget_config": [ + { + "surveyLink": "https://switcheonetwork.typeform.com/to/C1rheplK", + "endTime": "2024-07-26T23:00:00Z", + "pages": [ + "/account/overview", + "/account/balance" + ] + } + ] } From 4a9a7ceb4ca1e51d8caa2e4c5e1b6d3324535be6 Mon Sep 17 00:00:00 2001 From: ty4g1 Date: Thu, 11 Jul 2024 17:27:55 +0800 Subject: [PATCH 4/9] added checks and message property --- .github/markets/pr_template.md | 3 ++- config.schema.json | 3 +++ scripts/check_configs.ts | 29 +++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/.github/markets/pr_template.md b/.github/markets/pr_template.md index 30053f4..9f5b9c2 100644 --- a/.github/markets/pr_template.md +++ b/.github/markets/pr_template.md @@ -17,7 +17,7 @@ Each json file under the [configs](../../configs) folder correspond to their res |`demex_points_config` |`DemexPointsConfig` |false |Object that contains the parameters to earn demex points. |This object **must be included** for mainnet.json as demex points is already live on mainnet. | |`perp_pool_promo` |`PerpPoolPromo` |false |Map of Objects that contains perp pool promo parameters for each pool |If the `perp_pool_promo` property is omitted, no promo will be shown. The key of each entry is the ids of the perp pools with existing promo. | |`cross_selling_source_tokens` |`string[]` |true |The array of cross selling source tokens. Acquiring these tokens on the spot market will trigger a help wizard, prompting users to borrow USDG and trade perps on Demex. |The token denoms listed here **MUST** match the token denoms listed under the Carbon [Tokens API](https://api.carbon.network/carbon/coin/v1/tokens?pagination.limit=10000). | -|`typeform_widget_config` |`TypeformWidgetConfig` |false |Object that contains the parameters for ongoing surveys. | +|`typeform_widget_config` |`TypeformWidgetConfig` |false |Object that contains the parameters for ongoing surveys. | If the `message` property is omitted, default message is shown: "We want to hear from you!" | ## Maintenance Data Structure |Field |Type |Required |Description |Notes | |---|---|---|---|---| @@ -52,6 +52,7 @@ Each json file under the [configs](../../configs) folder correspond to their res ## TypeformWidgetConfig |Field |Type |Required |Description |Notes | |---|---|---|---|---| +|`message` |`string` |false |The message shown to the user on the widget. | |`surveyLink` |`string` |true |The link to the survey that will be shown when user clicks on the widget. | |`endTime` |`string` |true |End time of the survey | |`pages` |`string[]` | true |The paths to the pages on which the typeform widget must be shown. \ No newline at end of file diff --git a/config.schema.json b/config.schema.json index 47acd2d..be7609e 100644 --- a/config.schema.json +++ b/config.schema.json @@ -178,6 +178,9 @@ "pages" ], "properties": { + "message": { + "type": "string" + }, "surveyLink": { "type": "string" }, diff --git a/scripts/check_configs.ts b/scripts/check_configs.ts index b915aaa..5883cfe 100644 --- a/scripts/check_configs.ts +++ b/scripts/check_configs.ts @@ -23,6 +23,7 @@ interface ConfigJSON { [perpPoolId: string]: PerpPoolPromo, }, cross_selling_source_tokens: string[]; + typeform_widget_config: TypeFormWidgetConfig[] } interface InvalidEntry { @@ -58,6 +59,12 @@ interface PerpPoolPromo { perpTradingBoost: string; } +interface TypeFormWidgetConfig { + surveyLink: string + endTime: string + pages: string[] +} + type OutcomeMap = { [key in CarbonSDK.Network]: boolean }; // true = success, false = failure const outcomeMap: OutcomeMap = { @@ -384,6 +391,28 @@ async function main() { } } } + if (jsonData.typeform_widget_config) { + const typeFormWidgetConfigs = jsonData.typeform_widget_config + for (const config of typeFormWidgetConfigs) { + const startTime = new Date() + const endTime = new Date(config.endTime) + // Check if end time is before start time + if (endTime < startTime) { + console.error(`ERROR: ${network}.json has invalid end time (${endTime}) is before start time (${startTime.toString()}) for a typeform survey config.`); + outcomeMap[network] = false; + break; // Exit the loop early upon encountering an error + } + // look for duplicate pages + const hasDuplicatePages = checkDuplicateEntries(config.pages); + if (hasDuplicatePages.status && hasDuplicatePages.entry) { + let listOfDuplicates: string = hasDuplicatePages.entry.join(", "); + console.error(`ERROR: ${network}.json has the following duplicated pages in a typeform survey config: ${listOfDuplicates}. Please make sure to only input each page once in ${network}`); + outcomeMap[network] = false; + } + } + + } + } } const outcomeArr = Object.values(outcomeMap); From 7df87ce7e42beb6d0dc9e59b4a04b424a94425c0 Mon Sep 17 00:00:00 2001 From: ty4g1 Date: Thu, 11 Jul 2024 17:29:49 +0800 Subject: [PATCH 5/9] removed redundant conversion --- scripts/check_configs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_configs.ts b/scripts/check_configs.ts index 5883cfe..e4844d2 100644 --- a/scripts/check_configs.ts +++ b/scripts/check_configs.ts @@ -398,7 +398,7 @@ async function main() { const endTime = new Date(config.endTime) // Check if end time is before start time if (endTime < startTime) { - console.error(`ERROR: ${network}.json has invalid end time (${endTime}) is before start time (${startTime.toString()}) for a typeform survey config.`); + console.error(`ERROR: ${network}.json has invalid end time (${endTime}) is before start time (${startTime}) for a typeform survey config.`); outcomeMap[network] = false; break; // Exit the loop early upon encountering an error } From 1865a9c39ea6b27401fec76245f76d1d34c0bcc7 Mon Sep 17 00:00:00 2001 From: ty4g1 Date: Thu, 11 Jul 2024 17:40:54 +0800 Subject: [PATCH 6/9] added check for duplicate survey links --- scripts/check_configs.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/check_configs.ts b/scripts/check_configs.ts index e4844d2..596e9fe 100644 --- a/scripts/check_configs.ts +++ b/scripts/check_configs.ts @@ -393,6 +393,7 @@ async function main() { } if (jsonData.typeform_widget_config) { const typeFormWidgetConfigs = jsonData.typeform_widget_config + const links: string[] = [] for (const config of typeFormWidgetConfigs) { const startTime = new Date() const endTime = new Date(config.endTime) @@ -409,8 +410,15 @@ async function main() { console.error(`ERROR: ${network}.json has the following duplicated pages in a typeform survey config: ${listOfDuplicates}. Please make sure to only input each page once in ${network}`); outcomeMap[network] = false; } + links.push(config.surveyLink) + } + // look for duplicate links + const hasDuplicateLinks = checkDuplicateEntries(links); + if (hasDuplicateLinks.status && hasDuplicateLinks.entry) { + let listOfDuplicates: string = hasDuplicateLinks.entry.join(", "); + console.error(`ERROR: ${network}.json has the following duplicated links in the typeform survey configs: ${listOfDuplicates}. Please make sure to only input each link once in ${network}`); + outcomeMap[network] = false; } - } } From 1edefe097ee3ee18132ba3a6eb1c4d9248a8db00 Mon Sep 17 00:00:00 2001 From: ty4g1 Date: Thu, 11 Jul 2024 17:44:40 +0800 Subject: [PATCH 7/9] testing multiple surveys --- configs/mainnet.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/configs/mainnet.json b/configs/mainnet.json index 607e25c..85313c4 100644 --- a/configs/mainnet.json +++ b/configs/mainnet.json @@ -227,6 +227,15 @@ "/account/overview", "/account/balance" ] + }, + { + "message": "testing", + "surveyLink": "www.google.com", + "endTime": "2024-07-26T23:00:00Z", + "pages": [ + "/account/overview", + "/account/balance" + ] } ] } From 0bcd851a31c9606f938dabd453028683da248845 Mon Sep 17 00:00:00 2001 From: ty4g1 Date: Thu, 11 Jul 2024 18:32:44 +0800 Subject: [PATCH 8/9] Updated config to only allow one widget on each page --- .github/markets/pr_template.md | 2 +- configs/mainnet.json | 9 --------- scripts/check_configs.ts | 18 ++++++++++-------- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/.github/markets/pr_template.md b/.github/markets/pr_template.md index 9f5b9c2..c39e969 100644 --- a/.github/markets/pr_template.md +++ b/.github/markets/pr_template.md @@ -17,7 +17,7 @@ Each json file under the [configs](../../configs) folder correspond to their res |`demex_points_config` |`DemexPointsConfig` |false |Object that contains the parameters to earn demex points. |This object **must be included** for mainnet.json as demex points is already live on mainnet. | |`perp_pool_promo` |`PerpPoolPromo` |false |Map of Objects that contains perp pool promo parameters for each pool |If the `perp_pool_promo` property is omitted, no promo will be shown. The key of each entry is the ids of the perp pools with existing promo. | |`cross_selling_source_tokens` |`string[]` |true |The array of cross selling source tokens. Acquiring these tokens on the spot market will trigger a help wizard, prompting users to borrow USDG and trade perps on Demex. |The token denoms listed here **MUST** match the token denoms listed under the Carbon [Tokens API](https://api.carbon.network/carbon/coin/v1/tokens?pagination.limit=10000). | -|`typeform_widget_config` |`TypeformWidgetConfig` |false |Object that contains the parameters for ongoing surveys. | If the `message` property is omitted, default message is shown: "We want to hear from you!" | +|`typeform_widget_config` |`TypeformWidgetConfig` |false |Object that contains the parameters for ongoing surveys. | If the `message` property is omitted, default message is shown: "We want to hear from you!". Multiple widgets being displayed on the same page is not supported. Ensure pages don't overlap between configs. | ## Maintenance Data Structure |Field |Type |Required |Description |Notes | |---|---|---|---|---| diff --git a/configs/mainnet.json b/configs/mainnet.json index 85313c4..607e25c 100644 --- a/configs/mainnet.json +++ b/configs/mainnet.json @@ -227,15 +227,6 @@ "/account/overview", "/account/balance" ] - }, - { - "message": "testing", - "surveyLink": "www.google.com", - "endTime": "2024-07-26T23:00:00Z", - "pages": [ - "/account/overview", - "/account/balance" - ] } ] } diff --git a/scripts/check_configs.ts b/scripts/check_configs.ts index 596e9fe..06f70cf 100644 --- a/scripts/check_configs.ts +++ b/scripts/check_configs.ts @@ -394,6 +394,7 @@ async function main() { if (jsonData.typeform_widget_config) { const typeFormWidgetConfigs = jsonData.typeform_widget_config const links: string[] = [] + let pages: string[] = [] for (const config of typeFormWidgetConfigs) { const startTime = new Date() const endTime = new Date(config.endTime) @@ -402,14 +403,8 @@ async function main() { console.error(`ERROR: ${network}.json has invalid end time (${endTime}) is before start time (${startTime}) for a typeform survey config.`); outcomeMap[network] = false; break; // Exit the loop early upon encountering an error - } - // look for duplicate pages - const hasDuplicatePages = checkDuplicateEntries(config.pages); - if (hasDuplicatePages.status && hasDuplicatePages.entry) { - let listOfDuplicates: string = hasDuplicatePages.entry.join(", "); - console.error(`ERROR: ${network}.json has the following duplicated pages in a typeform survey config: ${listOfDuplicates}. Please make sure to only input each page once in ${network}`); - outcomeMap[network] = false; - } + } + pages = pages.concat(config.pages) links.push(config.surveyLink) } // look for duplicate links @@ -419,6 +414,13 @@ async function main() { console.error(`ERROR: ${network}.json has the following duplicated links in the typeform survey configs: ${listOfDuplicates}. Please make sure to only input each link once in ${network}`); outcomeMap[network] = false; } + // look for duplicate pages + const hasDuplicatePages = checkDuplicateEntries(pages); + if (hasDuplicatePages.status && hasDuplicatePages.entry) { + let listOfDuplicates: string = hasDuplicatePages.entry.join(", "); + console.error(`ERROR: ${network}.json has the following duplicated pages in the typeform survey configs: ${listOfDuplicates}. Please make sure to only input each page once in ${network}`); + outcomeMap[network] = false; + } } } From 53fc1a5fcbea9ca03f3ca56ddc4e42a7191a1e59 Mon Sep 17 00:00:00 2001 From: ty4g1 Date: Fri, 12 Jul 2024 15:41:01 +0800 Subject: [PATCH 9/9] fixed incorrect type --- .github/markets/pr_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/markets/pr_template.md b/.github/markets/pr_template.md index c39e969..83dea19 100644 --- a/.github/markets/pr_template.md +++ b/.github/markets/pr_template.md @@ -17,7 +17,7 @@ Each json file under the [configs](../../configs) folder correspond to their res |`demex_points_config` |`DemexPointsConfig` |false |Object that contains the parameters to earn demex points. |This object **must be included** for mainnet.json as demex points is already live on mainnet. | |`perp_pool_promo` |`PerpPoolPromo` |false |Map of Objects that contains perp pool promo parameters for each pool |If the `perp_pool_promo` property is omitted, no promo will be shown. The key of each entry is the ids of the perp pools with existing promo. | |`cross_selling_source_tokens` |`string[]` |true |The array of cross selling source tokens. Acquiring these tokens on the spot market will trigger a help wizard, prompting users to borrow USDG and trade perps on Demex. |The token denoms listed here **MUST** match the token denoms listed under the Carbon [Tokens API](https://api.carbon.network/carbon/coin/v1/tokens?pagination.limit=10000). | -|`typeform_widget_config` |`TypeformWidgetConfig` |false |Object that contains the parameters for ongoing surveys. | If the `message` property is omitted, default message is shown: "We want to hear from you!". Multiple widgets being displayed on the same page is not supported. Ensure pages don't overlap between configs. | +|`typeform_widget_config` |`TypeformWidgetConfig[]` |false |Object that contains the parameters for ongoing surveys. | If the `message` property is omitted, default message is shown: "We want to hear from you!". Multiple widgets being displayed on the same page is not supported. Ensure pages don't overlap between configs. | ## Maintenance Data Structure |Field |Type |Required |Description |Notes | |---|---|---|---|---|