web3go-xyz / web3go.xyz

Discovery data value of Web3
Apache License 2.0
10 stars 4 forks source link

MoonPush: support user to customize the message content for pre-defined variables #69

Closed happyJ2024 closed 2 years ago

happyJ2024 commented 2 years ago

image

current: the message is formatted by JSON, and send like this: image image

this is more like a program message from internal system. user will need a more readable message content.

requirement: we could build a message formatter to

some codes: notify-service/src/notify-process/notify-worker/notify.formater.ts

rachaelyychen commented 2 years ago

New Interfaces of Trigger Script Template Manage

1. create or update trigger script template

POST {HOST}/api/v1/script-template-manage/createScriptTemplate

{
  "id": 0,
  "trigger_type": "wallet_monitor",
  "script_template": "THIS IS SCRIPT",
  "variables": [
    {
      "variable_name": "chain",
      "variable_desc": "chain name"
    }
  ]
}

id equaled 0 means create, otherwise update. trigger_type is wallet_monitor/ gas/ anyswap/ dex. script_template is the script code. variables is a collection of result variables returned by trigger script execution.

2. get trigger script templates with variables

POST {HOST}/api/v1/script-template-manage/getScriptTemplates

{
  "trigger_type": "wallet_monitor"
}

trigger_type is wallet_monitor/ gas/ anyswap/ dex.

rachaelyychen commented 2 years ago

sql query for update table smart_trigger_script column script_template_id according to table script_template :

update smart_trigger_script set script_template_id = e.script_template_id from (select d.id as script_template_id, c.trigger_script_id as trigger_script_id from script_template d left join (select a.trigger_type as trigger_type, b.id as trigger_script_id from smart_trigger a left join smart_trigger_script b on a.id = b.trigger_id) c on d.trigger_type = c.trigger_type) e where id = e.trigger_script_id