Skip to content

Conversation

chray-zhang
Copy link
Collaborator

@chray-zhang chray-zhang commented Sep 17, 2025

Closes https://smartcontract-it.atlassian.net/browse/OPDATA-3889

Description

  • Added transport with sftp connection
  • Added downloading file logic
  • Adding parsing and response of EA

Steps to Test

curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{
    "id": "1",
    "data": {
      "endpoint": "ftse_sftp",
      "instrument": "FTSE100INDEX"
    }
  }' | jq
chrayzhang@MB-C3H04RT9WT ~ % curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{
    "id": "1",
    "data": {
      "endpoint": "ftse_sftp",
      "instrument": "FTSE100INDEX"
    }
  }' | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   492  100   386  100   106  83931  23048 --:--:-- --:--:-- --:--:--  120k
{
  "data": {
    "result": {
      "indexCode": "UKX",
      "indexSectorName": "FTSE 100 Index",
      "numberOfConstituents": 100,
      "indexBaseCurrency": "GBP",
      "gbpIndex": 9195.66227592
    }
  },
  "statusCode": 200,
  "result": 9195.66227592,
  "timestamps": {
    "providerDataRequestedUnixMs": 1758082923233,
    "providerDataReceivedUnixMs": 1758082954116
  },
  "meta": {
    "adapterName": "FTSE_SFTP",
    "metrics": {
      "feedId": "{\"instrument\":\"ftse100index\"}"
    }
  }
}
chrayzhang@MB-C3H04RT9WT ~ % curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{
    "id": "1",
    "data": {
      "endpoint": "ftse_sftp",
      "instrument": "Russell3000INDEX"
    }
  }' | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   453  100   343  100   110  99190  31810 --:--:-- --:--:-- --:--:--  147k
{
  "data": {
    "result": {
      "indexName": "Russell 3000® Index",
      "close": 3762
    }
  },
  "statusCode": 200,
  "result": {
    "indexName": "Russell 3000® Index",
    "close": 3762
  },
  "timestamps": {
    "providerDataRequestedUnixMs": 1758081524053,
    "providerDataReceivedUnixMs": 1758081538672
  },
  "meta": {
    "adapterName": "FTSE_SFTP",
    "metrics": {
      "feedId": "{\"instrument\":\"russell3000index\"}"
    }
  }
}
chrayzhang@MB-C3H04RT9WT ~ % curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{
    "id": "1",
    "data": {
      "endpoint": "ftse_sftp",
      "instrument": "Russell2000INDEX"
    }
  }' | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   459  100   349  100   110   117k  37774 --:--:-- --:--:-- --:--:--  224k
{
  "data": {
    "result": {
      "indexName": "Russell 2000® Index",
      "close": 2403.03
    }
  },
  "statusCode": 200,
  "result": {
    "indexName": "Russell 2000® Index",
    "close": 2403.03
  },
  "timestamps": {
    "providerDataRequestedUnixMs": 1758081454432,
    "providerDataReceivedUnixMs": 1758081468618
  },
  "meta": {
    "adapterName": "FTSE_SFTP",
    "metrics": {
      "feedId": "{\"instrument\":\"russell2000index\"}"
    }
  }
}
chrayzhang@MB-C3H04RT9WT ~ % curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{
    "id": "1",
    "data": {
      "endpoint": "ftse_sftp",
      "instrument": "Russell1000INDEX"
    }
  }' | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   459  100   349  100   110  81427  25664 --:--:-- --:--:-- --:--:--  112k
{
  "data": {
    "result": {
      "indexName": "Russell 1000® Index",
      "close": 3616.83
    }
  },
  "statusCode": 200,
  "result": {
    "indexName": "Russell 1000® Index",
    "close": 3616.83
  },
  "timestamps": {
    "providerDataRequestedUnixMs": 1758081384501,
    "providerDataReceivedUnixMs": 1758081401216
  },
  "meta": {
    "adapterName": "FTSE_SFTP",
    "metrics": {
      "feedId": "{\"instrument\":\"russell1000index\"}"
    }
  }
}

Quality Assurance

  • [ x] If a new adapter was made, or an existing one was modified so that its environment variables have changed, update the relevant infra-k8s configuration file.
  • [x ] If a new adapter was made, or an existing one was modified so that its environment variables have changed, update the relevant adapter-secrets configuration file or update the soak testing blacklist.
  • [x ] If a new adapter was made, or a new endpoint was added, update the test-payload.json file with relevant requests.
  • [x ] The branch naming follows git flow (feature/x, chore/x, release/x, hotfix/x, fix/x) or is created from Jira.
  • [ x] This is related to a maximum of one Jira story or GitHub issue.
  • [x ] Types are safe (avoid TypeScript/TSLint features like any and disable, instead use more specific types).
  • [ x] All code changes have 100% unit and integration test coverage. If testing is not applicable or too difficult to justify doing, the reasoning should be documented explicitly in the PR.

Copy link

changeset-bot bot commented Sep 17, 2025

🦋 Changeset detected

Latest commit: 9a8ca73

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@chainlink/ftse-sftp-adapter Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

const parsedData = await this.tryDownloadAndParseFile(param.instrument)

// Extract the numeric result based on the data type
let result: number
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

According to ResponseGeneric we need some sort of result

}
} finally {
try {
await this.sftpClient.end()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We need to close the client when we're done or else we'll run into end Event raised for a hanging sftp connection
Screenshot 2025-09-16 at 11 45 18 PM


private async tryDownloadAndParseFile(instrument: string): Promise<IndexResponseData> {
// Validate that the instrument is supported
if (!isInstrumentSupported(instrument)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe I should move this validation up to handleRequest?

@chray-zhang chray-zhang marked this pull request as ready for review September 17, 2025 04:59
Base automatically changed from ftse-transport-endpoint-v2 to main September 17, 2025 07:01
@dskloetc dskloetc mentioned this pull request Sep 19, 2025
7 tasks
@dskloetc
Copy link
Contributor

This is replaced by #4036

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.

2 participants