Skip to content
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e807511
Initial commit for split
chray-zhang Sep 4, 2025
638bf65
dependencies
chray-zhang Sep 4, 2025
620f1ff
Changeset
chray-zhang Sep 4, 2025
73628d2
comma
chray-zhang Sep 4, 2025
6129575
cleanup
chray-zhang Sep 4, 2025
b631b7f
Revision
chray-zhang Sep 4, 2025
a53b80f
Removed unused imports
chray-zhang Sep 4, 2025
a8cef07
Revision for comments
chray-zhang Sep 5, 2025
7fb0283
Removed unused import
chray-zhang Sep 5, 2025
950ff3b
Revision
chray-zhang Sep 8, 2025
c794c4b
Merge branch 'main' into ftse-utils
chray-zhang Sep 8, 2025
b6eb2e7
Revision #3
chray-zhang Sep 9, 2025
9ee7b6d
Fixed test
chray-zhang Sep 9, 2025
82cce90
Revision and removed this.convertValue
chray-zhang Sep 9, 2025
745e0c3
Fixed build
chray-zhang Sep 9, 2025
176a3bf
Renaming and refactoring
chray-zhang Sep 10, 2025
cfbe2ba
Merge branch 'main' into ftse-utils
chray-zhang Sep 10, 2025
8781e1e
Revision build
chray-zhang Sep 10, 2025
9e98946
Fixed comments
chray-zhang Sep 10, 2025
31feea8
revision
chray-zhang Sep 10, 2025
018a805
Revision
chray-zhang Sep 10, 2025
944984f
removed unnecc check
chray-zhang Sep 10, 2025
9554864
Fixed build
chray-zhang Sep 10, 2025
080cb91
Revision
chray-zhang Sep 10, 2025
1c9ff59
removed anys
chray-zhang Sep 10, 2025
5543807
Fixed test
chray-zhang Sep 10, 2025
4539ffc
Removed test
chray-zhang Sep 10, 2025
64b1f62
Revision
chray-zhang Sep 11, 2025
c2c3739
Revision
chray-zhang Sep 11, 2025
22b53a9
Revision
chray-zhang Sep 11, 2025
4faddaa
Revision
chray-zhang Sep 11, 2025
452c438
Merge branch 'main' into ftse-utils
chray-zhang Sep 11, 2025
d1fb425
Merge branch 'main' into ftse-utils
chray-zhang Sep 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/ninety-lamps-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/ftse-sftp-adapter': minor
---

Added parser utils for FTSE EA
137 changes: 137 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 2 additions & 1 deletion packages/scripts/src/generate-readme/readmeBlacklist.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"xsushi-price",
"coinbase-prime",
"harris-and-trotter",
"nav-consulting"
"nav-consulting",
"ftse-sftp"
]
}
46 changes: 46 additions & 0 deletions packages/sources/ftse-sftp/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "@chainlink/ftse-sftp-adapter",
"version": "0.0.0",
"description": "Chainlink ftse-sftp adapter.",
"keywords": [
"Chainlink",
"LINK",
"blockchain",
"oracle",
"ftse-sftp"
],
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"repository": {
"url": "https://github.com/smartcontractkit/external-adapters-js",
"type": "git"
},
"license": "MIT",
"scripts": {
"clean": "rm -rf dist && rm -f tsconfig.tsbuildinfo",
"prepack": "yarn build",
"build": "tsc -b",
"server": "node -e 'require(\"./index.js\").server()'",
"server:dist": "node -e 'require(\"./dist/index.js\").server()'",
"start": "yarn server:dist"
},
"dependencies": {
"@chainlink/external-adapter-framework": "2.7.0",
"csv-parse": "5.5.6",
"decimal.js": "^10.5.0",
"tslib": "^2.3.1"
},
"devDependencies": {
"@sinonjs/fake-timers": "^14.0.0",
"@types/jest": "^29.5.14",
"@types/node": "22.14.1",
"jest": "^29.7.0",
"jest-util": "^29.7.0",
"nock": "13.5.6",
"ts-jest": "^29.2.5",
"typescript": "5.8.3"
}
}
56 changes: 56 additions & 0 deletions packages/sources/ftse-sftp/src/parsing/base-parser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Options, parse } from 'csv-parse/sync'
import { CSVParser, ParsedData } from './interfaces'

/**
* Abstract base class for CSV parsers
* Uses the csv-parse library for robust CSV parsing
*/
export abstract class BaseCSVParser<T extends ParsedData = ParsedData> implements CSVParser<T> {
protected config: Options

constructor(config: Options = {}) {
this.config = { ...config }
}

/**
* Abstract method that must be implemented by concrete classes
*/
abstract parse(csvContent: string): Promise<T>

/**
* Helper method to parse CSV content as records with column headers
*/
protected parseCSVRecords(csvContent: string, options?: Options): Record<string, string>[] {
const finalConfig: Options = { ...this.config, ...options, columns: true }

try {
return parse(csvContent, finalConfig)
} catch (error) {
throw new Error(`Error parsing CSV as records: ${error}`)
}
}

/**
* Helper method to parse CSV content as arrays
*/
protected parseCSVArrays(csvContent: string, options?: Options): string[][] {
const finalConfig: Options = { ...this.config, ...options, columns: false }

try {
return parse(csvContent, finalConfig)
} catch (error) {
throw new Error(`Error parsing CSV as arrays: ${error}`)
}
}

/**
* Convert a string value to a number and invalid values
*/
protected convertToNumber(value: string): number {
if (!value || value.trim() === '') {
return 0
}
const numValue = parseFloat(value)
return isNaN(numValue) ? 0 : numValue
}
}
33 changes: 33 additions & 0 deletions packages/sources/ftse-sftp/src/parsing/factory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { CSVParser } from './interfaces'
import { FTSE100Parser } from './ftse100'
import { RussellDailyValuesParser } from './russell'

/**
* Supported CSV parser types
*/
export const instrumentToElementMap = {
Russell1000INDEX: 'Russell 1000® Index',
Russell2000INDEX: 'Russell 2000® Index',
Russell3000INDEX: 'Russell 3000® Index',
}

/**
* Factory class for creating CSV parsers
*/
export class CSVParserFactory {
/**
* Auto-detect parser type based on instrument
*/
static detectParserByInstrument(instrument: string): CSVParser | null {
switch (instrument) {
case 'FTSE100INDEX':
return new FTSE100Parser()
case 'Russell1000INDEX':
case 'Russell2000INDEX':
case 'Russell3000INDEX':
return new RussellDailyValuesParser(instrumentToElementMap[instrument])
default:
return null
}
}
}
Loading
Loading