Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pagination for List, move executions list to its own endpoint #53

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

v9n
Copy link
Member

@v9n v9n commented Dec 8, 2024

Fixes #43 #44 #45

List Task

{
  id: '01JEM9SBND2Y9VS1JRBD0EZG9P',
  owner: '0xe272b72E51a5bF8cB720fc6D6DF164a4D5E321C5',
  smart_wallet_address: '0x5Df343de7d99fd64b2479189692C1dAb8f46184a',
  start_at: '1733700690',
  expired_at: '1736292660',
  memo: 'Montoring large token transfer for 0xC114FB059434563DC65AC8D57e7976e3eaC534F4',
  completed_at: '0',
  max_execution: '0',
  total_execution: '4',
  last_ran_at: '1733701360',
  status: 'Active',
  trigger: {
    name: 'trigger1',
    event: {
      expression: 'trigger1.data.topics[0] == "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" && trigger1.data.topics[2] == "0xc114fb059434563dc65ac8d57e7976e3eac534f4"'
    },
    trigger_type: 'event'
  }
}
{
  id: '01JEM9WYV9ATCP7KD728KWNKTF',
  owner: '0xe272b72E51a5bF8cB720fc6D6DF164a4D5E321C5',
  smart_wallet_address: '0x5Df343de7d99fd64b2479189692C1dAb8f46184a',
  start_at: '1733700808',
  expired_at: '1736292778',
  memo: 'Montoring large token transfer for 0x2A6CEbeDF9e737A9C6188c62A68655919c7314DB',
  completed_at: '0',
  max_execution: '0',
  total_execution: '0',
  last_ran_at: '0',
  status: 'Active',
  trigger: {
    name: 'trigger1',
    event: {
      expression: 'trigger1.data.topics[0] == "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" && trigger1.data.topics[2] == "0x2a6cebedf9e737a9c6188c62a68655919c7314db"'
    },
    trigger_type: 'event'
  }
}
{
  cursor: 'eyJkIjoibmV4dCIsInAiOiIwMUpFTTlXWVY5QVRDUDdLRDcyOEtXTktURiJ9'
}
Note: we are returning only 2 items per page to demonstrate pagination

Then we can oad more by passing the cursor.

 n example tasks '0x5Df343de7d99fd64b2479189692C1dAb8f46184a' 'eyJkIjoibmV4dCIsInAiOiIwMUpFTTlXWVY5QVRDUDdLRDcyOEtXTktURiJ9'

Returns

{
  id: '01JEM9X4X49CJFD6GDAY2Q0XJR',
  owner: '0xe272b72E51a5bF8cB720fc6D6DF164a4D5E321C5',
  smart_wallet_address: '0x5Df343de7d99fd64b2479189692C1dAb8f46184a',
  start_at: '1733700815',
  expired_at: '1736292785',
  memo: 'Montoring large token transfer for 0x2A6CEbeDF9e737A9C6188c62A68655919c7314DB',
  completed_at: '0',
  max_execution: '0',
  total_execution: '0',
  last_ran_at: '0',
  status: 'Active',
  trigger: {
    name: 'trigger1',
    event: {
      expression: 'trigger1.data.topics[0] == "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" && trigger1.data.topics[2] == "0x2a6cebedf9e737a9c6188c62a68655919c7314db"'
    },
    trigger_type: 'event'
  }
}
{
  id: '01JEM9X6Y67EZ7T21QWZJYF2E7',
  owner: '0xe272b72E51a5bF8cB720fc6D6DF164a4D5E321C5',
  smart_wallet_address: '0x5Df343de7d99fd64b2479189692C1dAb8f46184a',
  start_at: '1733700817',
  expired_at: '1736292787',
  memo: 'Montoring large token transfer for 0x2A6CEbeDF9e737A9C6188c62A68655919c7314DB',
  completed_at: '0',
  max_execution: '0',
  total_execution: '0',
  last_ran_at: '0',
  status: 'Active',
  trigger: {
    name: 'trigger1',
    event: {
      expression: 'trigger1.data.topics[0] == "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" && trigger1.data.topics[2] == "0x2a6cebedf9e737a9c6188c62a68655919c7314db"'
    },
    trigger_type: 'event'
  }
}
{
  cursor: 'eyJkIjoibmV4dCIsInAiOiIwMUpFTTlYNlk2N0VaN1QyMVFXWkpZRjJFNyJ9'
}
Note: we are returning only 2 items per page to demonstrate pagination

List Executions

n example executions '01JEM9SBND2Y9VS1JRBD0EZG9P'
Current environment is:  development
{
  executions: [
    {
      steps: [
        {
          node_id: '01JEM9SBN39NGQDG89M3M44S3P',
          success: true,
          output_data: '01JEM9SBN39NGQDG89M3M44S3P.01JEM9SBN39NH3Z4973D22BT8W',
          log: 'Execute Branch: 01JEM9SBN39NGQDG89M3M44S3P\n' +
            '2024-12-08 15:31:42.944741 -0800 PST m=+57.323528668 evaluate condition: 01JEM9SBN39NH3Z4973D22BT8W expression: `\n' +
            '                   // usdc\n' +
            '                   ( trigger1.data.address == "0x1c7d4b196cb0c7b01d743fbc6116a902379c7238" &&\n' +
            '                     bigGt(\n' +
            '                       toBigInt(trigger1.data.value),\n' +
            '                       toBigInt("2000000")\n' +
            '                     )\n' +
            '                   ) ||\n' +
            '                   ( trigger1.data.address == lower("0x779877a7b0d9e8603169ddbd7836e478b4624789") &&\n' +
            '                     bigGt(\n' +
            '                       // link token\n' +
            '                       chainlinkPrice("0xc59E3633BAAC79493d908e63626716e204A45EdF"),\n' +
            '                       toBigInt("5000000")\n' +
            '                     )\n' +
            '                   )\n' +
            '                `\n' +
            'expression result to true. follow path 01JEM9SBN39NGQDG89M3M44S3P.01JEM9SBN39NH3Z4973D22BT8W',
          error: '',
          start_at: '0',
          end_at: '0'
        },
        {
          node_id: '01JEM9SBN16N8MWK6EJ93ADTZ1',
          success: true,
          output_data: '{"ok":true,"result":{"message_id":203856,"from":{"id":7346890119,"is_bot":true,"first_name":"cronbot","username":"croncurl_bot"},"chat":{"id":-4609037622,"title":"TelegramTestBotDev","type":"group","all_members_are_administrators":true},"date":1733700703,"text":"Congrat, your walllet 0xC114FB059434563DC65AC8D57e7976e3eaC534F4 received 10 USDC from 0x24c248D19D727080F2A85C444ac5bC600A6c9f2e at 0x45faf5682fa7fe8306cc2ef6af800e7358aef0e015a608bdb7d51d4f7a5444fc","entities":[{"offset":22,"length":42,"type":"text_link","url":"https://sepolia.etherscan.io/address/0xC114FB059434563DC65AC8D57e7976e3eaC534F4"},{"offset":74,"length":2,"type":"code"},{"offset":77,"length":4,"type":"text_link","url":"https://sepolia.etherscan.io/token/0x1c7d4b196cb0c7b01d743fbc6116a902379c7238"},{"offset":133,"length":66,"type":"text_link","url":"http://sepolia.etherscan.io/tx/0x45faf5682fa7fe8306cc2ef6af800e7358aef0e015a608bdb7d51d4f7a5444fc"}],"link_preview_options":{"url":"https://sepolia.etherscan.io/address/0xC114FB059434563DC65AC8D57e7976e3eaC534F4"}}}',
          log: 'Execute POST api.telegram.org at 2024-12-08 15:31:43.577838 -0800 PST m=+57.956623168',
          error: '',
          start_at: '1733700702',
          end_at: '1733700703'
        }
      ],
      id: '01JEM9TNAS5ZQ96E727DT7GZPN',
      start_at: '1733700702',
      end_at: '1733700703',
      success: true,
      error: '',
      trigger_mark: {
        block_number: '7239843',
        log_index: '51',
        tx_hash: '0x45faf5682fa7fe8306cc2ef6af800e7358aef0e015a608bdb7d51d4f7a5444fc'
      },
      result: ''
    },
    {
      steps: [
        {
          node_id: '01JEM9SBN39NGQDG89M3M44S3P',
          success: true,
          output_data: '01JEM9SBN39NGQDG89M3M44S3P.01JEM9SBN39NH3Z4973D22BT8W',
          log: 'Execute Branch: 01JEM9SBN39NGQDG89M3M44S3P\n' +
            '2024-12-08 15:36:19.245838 -0800 PST m=+333.625825376 evaluate condition: 01JEM9SBN39NH3Z4973D22BT8W expression: `\n' +
            '                   // usdc\n' +
            '                   ( trigger1.data.address == "0x1c7d4b196cb0c7b01d743fbc6116a902379c7238" &&\n' +
            '                     bigGt(\n' +
            '                       toBigInt(trigger1.data.value),\n' +
            '                       toBigInt("2000000")\n' +
            '                     )\n' +
            '                   ) ||\n' +
            '                   ( trigger1.data.address == lower("0x779877a7b0d9e8603169ddbd7836e478b4624789") &&\n' +
            '                     bigGt(\n' +
            '                       // link token\n' +
            '                       chainlinkPrice("0xc59E3633BAAC79493d908e63626716e204A45EdF"),\n' +
            '                       toBigInt("5000000")\n' +
            '                     )\n' +
            '                   )\n' +
            '                `\n' +
            'expression result to true. follow path 01JEM9SBN39NGQDG89M3M44S3P.01JEM9SBN39NH3Z4973D22BT8W',
          error: '',
          start_at: '0',
          end_at: '0'
        },
        {
          node_id: '01JEM9SBN16N8MWK6EJ93ADTZ1',
          success: true,
          output_data: '{"ok":true,"result":{"message_id":203859,"from":{"id":7346890119,"is_bot":true,"first_name":"cronbot","username":"croncurl_bot"},"chat":{"id":-4609037622,"title":"TelegramTestBotDev","type":"group","all_members_are_administrators":true},"date":1733700979,"text":"Congrat, your walllet 0xC114FB059434563DC65AC8D57e7976e3eaC534F4 received 3.435 USDC from 0x2A6CEbeDF9e737A9C6188c62A68655919c7314DB at 0x82a36277fa3915eccaa769468e1f4eb8ab2d358678635eeb5b75d67a53cdaa71","entities":[{"offset":22,"length":42,"type":"text_link","url":"https://sepolia.etherscan.io/address/0xC114FB059434563DC65AC8D57e7976e3eaC534F4"},{"offset":74,"length":5,"type":"code"},{"offset":80,"length":4,"type":"text_link","url":"https://sepolia.etherscan.io/token/0x1c7d4b196cb0c7b01d743fbc6116a902379c7238"},{"offset":136,"length":66,"type":"text_link","url":"http://sepolia.etherscan.io/tx/0x82a36277fa3915eccaa769468e1f4eb8ab2d358678635eeb5b75d67a53cdaa71"}],"link_preview_options":{"url":"https://sepolia.etherscan.io/address/0xC114FB059434563DC65AC8D57e7976e3eaC534F4"}}}',
          log: 'Execute POST api.telegram.org at 2024-12-08 15:36:19.956487 -0800 PST m=+334.336479293',
          error: '',
          start_at: '1733700979',
          end_at: '1733700979'
        }
      ],
      id: '01JEMA337MD2X140KY1HA6WNRC',
      start_at: '1733700979',
      end_at: '1733700979',
      success: true,
      error: '',
      trigger_mark: {
        block_number: '7239866',
        log_index: '175',
        tx_hash: '0x82a36277fa3915eccaa769468e1f4eb8ab2d358678635eeb5b75d67a53cdaa71'
      },
      result: ''
    }
  ],
  cursor: 'eyJkIjoibmV4dCIsInAiOiIwMUpFTUEzMzdNRDJYMTQwS1kxSEE2V05SQyJ9'
}

@v9n v9n marked this pull request as draft December 8, 2024 11:00
@v9n v9n changed the title extract exection log out add pagination for List, move executions list to its own endpoint Dec 8, 2024
@v9n v9n marked this pull request as ready for review December 8, 2024 23:57
@v9n v9n force-pushed the update-list-task-and-execution-endpoint branch from 3d4ed39 to dfb40e4 Compare December 9, 2024 00:03
@v9n v9n force-pushed the update-list-task-and-execution-endpoint branch from dfb40e4 to 851636e Compare December 9, 2024 00:52
@v9n v9n requested a review from chrisli30 December 9, 2024 00:56
@@ -0,0 +1,85 @@
syntax = "proto3";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split node defininiton into its own proto file . This way for node update there won't be any change to the SDK

Copy link
Member

@chrisli30 chrisli30 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

One question is that, how should we generate executions data in sdk tests? We can set the block interval to 1 and wait for a few blocks to get the executions result?

@chrisli30
Copy link
Member

Hi @v9n, is it possible to get the total number of ListTasks? The cursor is a new trend of getting list items, but we do have the requirement to get and display the total number directly.

@chrisli30
Copy link
Member

Another thought: I think it would be better to standardize the response format of both calls. Personally, I prefer the format of getExecutions, which is:

{
    executions: [], // this is the result
    cursor: string
}

@v9n
Copy link
Member Author

v9n commented Dec 11, 2024

Hi @v9n, is it possible to get the total number of ListTasks? The cursor is a new trend of getting list items, but we do have the requirement to get and display the total number directly.

yes, we can return the total in this as well.

Another thought: I think it would be better to standardize the response format of both calls. Personally, I prefer the format of getExecutions, which is:

did you check the protocolbuf, they had standarize to the same

protobuf/avs.proto Show resolved Hide resolved
@v9n v9n merged commit 97c45a4 into main Dec 11, 2024
4 checks passed
@v9n v9n deleted the update-list-task-and-execution-endpoint branch December 11, 2024 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ListTasks should return only minimum amount of data instead the full details.
2 participants