otomato-sdk 2.0.310 → 2.0.312

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6830,7 +6830,7 @@ export const TRIGGERS = {
6830
6830
  "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/blur.jpg",
6831
6831
  "LISTING": {
6832
6832
  "name": "NFT Listing",
6833
- "dynamicName": "async (env, { otomatoSDK }) => {\n const { getDynamicNameWrapperHTML, shortenAddress } = otomatoSDK;\n return getDynamicNameWrapperHTML(\n `On ${shortenAddress(env.parameters.contract)} listing`,\n `rarity ${getComparisonString(env.parameters.rarityCondition, env.parameters.rarity)}`,\n `${env.parameters.price ? `price > ${env.parameters.price}` : ''}`,\n );\n }",
6833
+ "dynamicName": "async (env, { otomatoSDK }) => {\n const { getDynamicNameWrapperHTML, shortenAddress, getComparisonString } = otomatoSDK;\n return getDynamicNameWrapperHTML(\n `On ${shortenAddress(env.parameters.contract)} listing`,\n `rarity ${getComparisonString(env.parameters.rarityCondition, env.parameters.rarity)}`,\n `${env.parameters.price ? `price > ${env.parameters.price}` : ''}`,\n );\n }",
6834
6834
  "description": "Subscribe to live NFT listing events based on filters.",
6835
6835
  "type": 5,
6836
6836
  "blockData": "\n async (env) => {\n const { parameters, fieldFunctionName, contract } = env;\n\n const PARAMETERS_TYPE = {\"BOOLEAN\":\"boolean\",\"INTEGER\":\"integer\",\"INT8\":\"int8\",\"INT16\":\"int16\",\"INT32\":\"int32\",\"INT64\":\"int64\",\"INT128\":\"int128\",\"INT256\":\"int256\",\"UINT8\":\"uint8\",\"UINT16\":\"uint16\",\"UINT32\":\"uint32\",\"UINT64\":\"uint64\",\"UINT128\":\"uint128\",\"UINT256\":\"uint256\",\"FLOAT\":\"float\",\"PERCENTAGE\":\"percentage\",\"FIXED\":\"fixed\",\"UFIXED\":\"ufixed\",\"ERC20\":\"erc20\",\"NFT_COLLECTION\":\"nftCollection\",\"ADDRESS\":\"address\",\"STRING\":\"string\",\"URL\":\"url\",\"PHONE_NUMBER\":\"phone_number\",\"EMAIL\":\"email\",\"PARAGRAPH\":\"paragraph\",\"ARRAY_OF_ADDRESSES\":\"addresses_array\",\"ARRAY_OF_STRINGS\":\"string_array\",\"ARRAY_OF_ARRAYS\":\"arrays_array\",\"RENDER_ENUM\":\"render_enum\",\"RENDER_JSON\":\"render_json\",\"CHAIN_ID\":\"chainId\",\"LOGIC_OPERATOR\":\"logic_operator\",\"AND_OR\":\"and_or\",\"CONDITION_GROUPS\":\"condition_groups\",\"MATH_OPERATORS\":\"string\",\"ANY\":\"any\",\"POLYMARKET\":\"polymarket\"};\n \n if (fieldFunctionName === 'renderJSONData') {\n try {\n const response = await fetch(`https://api.reservoir.tools/collections/${contract}/attributes/all/v1`);\n\n if (!response.ok) {\n console.error('Failed to fetch Blur traits');\n return [];\n }\n\n const data = await response.json();\n\n if (!data.attributes) {\n throw new Error('Invalid response from Blur API');\n }\n const traits = data.attributes;\n const traitJSONData = [];\n\n for (const trait of traits) {\n const traitValues = trait.values.map(value => value.value);\n traitJSONData.push({\n key: trait.key,\n type: PARAMETERS_TYPE.STRING,\n description: `The ${trait.key.toLowerCase()} of the NFT.`,\n enum: traitValues\n });\n }\n\n return {\n renderJSONData: {\n traits: traitJSONData,\n },\n };\n } catch (error) {\n throw new Error('Error fetching Blur traits: ' + error);\n }\n } else if (fieldFunctionName === 'totalSupply') {\n try {\n const response = await fetch(`https://api.reservoir.tools/collections/v7?id=${contract}`);\n const data = await response.json();\n return {\n totalSupply: data.collections[0].supply,\n };\n } catch (error) {\n throw new Error('Error fetching Blur total supply: ' + error);\n }\n }\n\n return null;\n }",
@@ -7608,7 +7608,7 @@ export const ACTIONS = {
7608
7608
  "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/if.png",
7609
7609
  "IF": {
7610
7610
  "name": "Condition",
7611
- "dynamicName": "async (env) => {\n /**\n * Renders a conditional logic structure into readable HTML\n * @param params - The condition parameters with logic, groups, and checks\n * @returns HTML string representation of the condition\n */\n function renderConditionDescription(params) {\n const { logic, groups } = params;\n if (!groups || groups.length === 0) {\n return 'If';\n }\n const groupDescriptions = groups.map((group) => renderGroup(group));\n const logicWord = logic === 'or' ? 'OR' : 'AND';\n if (groupDescriptions.length === 1) {\n return `<div class=\"flex items-center space-x-1\">\n <span>If ${groupDescriptions[0]}</span>\n </div>`;\n }\n return `<div class=\"flex items-center space-x-1\">\n <span>If (${groupDescriptions.join(` <span class=\"px-1 font-bold\">${logicWord}</span> `)})</span>\n </div>`;\n }\n \n /**\n * Renders a single group of checks\n * @param group - Group with logic and checks\n * @returns HTML string for the group\n */\n function renderGroup(group) {\n const { logic, checks } = group;\n if (!checks || checks.length === 0) {\n return '';\n }\n const checkDescriptions = checks.map((check) => renderCheck(check));\n const logicWord = logic === 'or' ? 'OR' : 'AND';\n if (checkDescriptions.length === 1) {\n return checkDescriptions[0];\n }\n return `(${checkDescriptions.join(`<span class=\"px-1 font-bold\">${logicWord}</span>`)})`;\n }\n \n /**\n * Renders a single check comparison\n * @param check - Check with value1, condition, and value2\n * @returns HTML string for the check\n */\n function renderCheck(check) {\n const { value1, condition, value2 } = check;\n const formattedValue1 = formatValue(value1);\n const formattedValue2 = formatValue(value2);\n const operator = OperatorToSymbol[condition] || condition;\n return `${formattedValue1} ${operator} ${formattedValue2}`;\n }\n \n /**\n * Formats a value, converting nodeMap references to HTML links\n * @param value - The value to format (can be nodeMap reference or literal)\n * @returns Formatted HTML string\n */\n /**\n * Formats a value, converting nodeMap references to HTML links and coloring booleans.\n * @param value - The value to format (can be nodeMap reference, boolean, or literal)\n * @returns Formatted HTML string\n */\n function formatValue(value) {\n if (typeof value === 'string' && value.includes('{{nodeMap.')) {\n const nodeMapMatch = value.match(/\\{\\{nodeMap\\.(\\d+)\\.output\\.(\\w+)\\}\\}/);\n if (nodeMapMatch) {\n const nodeRef = nodeMapMatch[1];\n const outputProperty = nodeMapMatch[2];\n return `<a href=\"#\" title=\"Node ${nodeRef} output\">${nodeRef}.${outputProperty}</a>`;\n }\n }\n // Handle boolean string values \"True\" and \"False\" (case-insensitive)\n if (typeof value === 'string') {\n if (value.toLowerCase() === 'true') {\n return `<span style=\"color: #1560F5;\">\"True\"</span>`;\n }\n if (value.toLowerCase() === 'false') {\n return `<span style=\"color: #FF3D00;\">\"False\"</span>`;\n }\n return `\"${value}\"`;\n }\n // Handle boolean values true and false\n if (typeof value === 'boolean') {\n if (value === true) {\n return `<span style=\"color: #1560F5;\">True</span>`;\n }\n if (value === false) {\n return `<span style=\"color: #FF3D00;\">False</span>`;\n }\n }\n return String(value);\n }\n \n // Operator symbol mapping (should match backend EOperator/OperatorToSymbol)\n const OperatorToSymbol = {\n eq: '==',\n neq: '!=',\n gt: '>',\n gte: '>=',\n lt: '<',\n lte: '<=',\n contains: 'contains',\n not_contains: 'not contains',\n starts_with: 'starts with',\n ends_with: 'ends with',\n in: 'in',\n not_in: 'not in'\n };\n \n return renderConditionDescription(env.parameters);\n }",
7611
+ "dynamicName": "async (env) => {\n /**\n * Renders a conditional logic structure into readable HTML\n * @param params - The condition parameters with logic, groups, and checks\n * @returns HTML string representation of the condition\n */\n function renderConditionDescription(params) {\n const { logic, groups } = params;\n if (!groups || groups.length === 0) {\n return 'If';\n }\n const groupDescriptions = groups.map((group) => renderGroup(group));\n const logicWord = logic === 'or' ? 'OR' : 'AND';\n if (groupDescriptions.length === 1) {\n return `<div class=\"flex items-center space-x-1\">\n If ${groupDescriptions[0]}\n </div>`;\n }\n return `<div class=\"flex items-center space-x-1\">\n If (${groupDescriptions.join(` <span class=\"px-1 font-bold\">${logicWord}</span> `)})\n </div>`;\n }\n \n /**\n * Renders a single group of checks\n * @param group - Group with logic and checks\n * @returns HTML string for the group\n */\n function renderGroup(group) {\n const { logic, checks } = group;\n if (!checks || checks.length === 0) {\n return '';\n }\n const checkDescriptions = checks.map((check) => renderCheck(check));\n const logicWord = logic === 'or' ? 'OR' : 'AND';\n if (checkDescriptions.length === 1) {\n return checkDescriptions[0];\n }\n return `(${checkDescriptions.join(`<span class=\"px-1 font-bold\">${logicWord}</span>`)})`;\n }\n \n /**\n * Renders a single check comparison\n * @param check - Check with value1, condition, and value2\n * @returns HTML string for the check\n */\n function renderCheck(check) {\n const { value1, condition, value2 } = check;\n const formattedValue1 = formatValue(value1);\n const formattedValue2 = formatValue(value2);\n const operator = OperatorToSymbol[condition] || condition;\n return `${formattedValue1} ${operator} ${formattedValue2}`;\n }\n \n /**\n * Formats a value, converting nodeMap references to HTML links\n * @param value - The value to format (can be nodeMap reference or literal)\n * @returns Formatted HTML string\n */\n /**\n * Formats a value, converting nodeMap references to HTML links and coloring booleans.\n * @param value - The value to format (can be nodeMap reference, boolean, or literal)\n * @returns Formatted HTML string\n */\n function formatValue(value) {\n if (typeof value === 'string' && value.includes('{{nodeMap.')) {\n const nodeMapMatch = value.match(/\\{\\{nodeMap\\.(\\d+)\\.output\\.(\\w+)\\}\\}/);\n if (nodeMapMatch) {\n const nodeRef = nodeMapMatch[1];\n const outputProperty = nodeMapMatch[2];\n return `<a href=\"#\" title=\"Node ${nodeRef} output\">${nodeRef}.${outputProperty}</a>`;\n }\n }\n // Handle boolean string values \"True\" and \"False\" (case-insensitive)\n if (typeof value === 'string') {\n if (value.toLowerCase() === 'true') {\n return `<span style=\"color: #1560F5;\">\"True\"</span>`;\n }\n if (value.toLowerCase() === 'false') {\n return `<span style=\"color: #FF3D00;\">\"False\"</span>`;\n }\n return `\"${value}\"`;\n }\n // Handle boolean values true and false\n if (typeof value === 'boolean') {\n if (value === true) {\n return `<span style=\"color: #1560F5;\">True</span>`;\n }\n if (value === false) {\n return `<span style=\"color: #FF3D00;\">False</span>`;\n }\n }\n return String(value);\n }\n \n // Operator symbol mapping (should match backend EOperator/OperatorToSymbol)\n const OperatorToSymbol = {\n eq: '==',\n neq: '!=',\n gt: '>',\n gte: '>=',\n lt: '<',\n lte: '<=',\n contains: 'contains',\n not_contains: 'not contains',\n starts_with: 'starts with',\n ends_with: 'ends with',\n in: 'in',\n not_in: 'not in'\n };\n \n return renderConditionDescription(env.parameters);\n }",
7612
7612
  "type": 5,
7613
7613
  "description": "Checks for a condition before proceeding",
7614
7614
  "parameters": [
@@ -1,4 +1,4 @@
1
- export const SDK_VERSION = '2.0.310';
1
+ export const SDK_VERSION = '2.0.312';
2
2
  export function compareVersions(v1, v2) {
3
3
  // Split the version strings into parts
4
4
  const v1Parts = v1.split('.').map(Number);
@@ -265,15 +265,13 @@ export const getChainHTML = (chainId) => {
265
265
  const chain = getChainById(chainId);
266
266
  return `
267
267
  <span style="display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; line-height: 20px; color: #fff;">
268
- <span>
269
- <img
270
- src="${chain.chainIcon}"
271
- alt="${chain.name}"
272
- width="14"
273
- height="14"
274
- style="border-radius: 50%;"
275
- />
276
- </span>
268
+ <img
269
+ src="${chain.chainIcon}"
270
+ alt="${chain.name}"
271
+ width="14"
272
+ height="14"
273
+ style="border-radius: 50%;"
274
+ />
277
275
  </span>
278
276
  `;
279
277
  };
@@ -294,22 +292,22 @@ export const getDynamicNameWrapperHTML = (...elements) => {
294
292
  * @param value - The value to format (can be nodeMap reference or literal)
295
293
  * @returns Formatted HTML string
296
294
  */
297
- const formatValue = (value) => {
298
- if (typeof value === 'string' && value.includes('{{nodeMap.')) {
299
- // Replace only the value inside {{...}} with the HTML link, keep the rest of the string
300
- return value.replace(/\{\{nodeMap\.(\d+)\.output\.(\w+)\}\}/g, (_match, nodeRef, outputProperty) => {
301
- return `<a href="#" title="Node ${nodeRef} output">${nodeRef}.${outputProperty}</a>`;
302
- });
303
- }
304
- if (typeof value === 'string' && value.length > 0 && !value.includes('<') && !value.includes('>')) {
305
- return `<div>${value}</div>`;
306
- }
307
- return value;
308
- };
309
- const formattedElements = elements.map(formatValue);
295
+ // const formatValue = (value: string): string => {
296
+ // // if (typeof value === 'string' && value.includes('{{nodeMap.')) {
297
+ // // // Replace only the value inside {{...}} with the HTML link, keep the rest of the string
298
+ // // return value.replace(/\{\{nodeMap\.(\d+)\.output\.(\w+)\}\}/g, (_match, nodeRef, outputProperty) => {
299
+ // // return `<a href="#" title="Node ${nodeRef} output">${nodeRef}.${outputProperty}</a>`;
300
+ // // });
301
+ // // }
302
+ // if (typeof value === 'string' && value.length > 0 && !value.includes('<') && !value.includes('>')) {
303
+ // return `<div>${value}</div>`;
304
+ // }
305
+ // return value;
306
+ // };
307
+ // const formattedElements = elements.map(formatValue);
310
308
  return `
311
309
  <div style="display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; line-height: 20px; color: #fff;">
312
- ${formattedElements.join('')}
310
+ ${elements.join('')}
313
311
  </div>
314
312
  `;
315
313
  };
@@ -1,2 +1,2 @@
1
- export declare const SDK_VERSION = "2.0.310";
1
+ export declare const SDK_VERSION = "2.0.312";
2
2
  export declare function compareVersions(v1: string, v2: string): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "otomato-sdk",
3
- "version": "2.0.310",
3
+ "version": "2.0.312",
4
4
  "description": "An SDK for building and managing automations on Otomato",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/types/src/index.d.ts",