Skip to content

Commit c2de3d4

Browse files
committed
content/link updates, dynamic buttons
1 parent c3a1962 commit c2de3d4

File tree

12 files changed

+324
-137
lines changed

12 files changed

+324
-137
lines changed

package-lock.json

Lines changed: 39 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@
6464
"@astrojs/prism": "^3.3.0",
6565
"@astrojs/react": "^4.4.2",
6666
"@astrojs/sitemap": "^3.6.0",
67-
"@astrojs/tailwind": "^6.0.2",
68-
"@chainlink/blocks": "^1.3.1",
6967
"@astrojs/vercel": "^8.2.11",
68+
"@chainlink/blocks": "^1.3.1",
7069
"@chainlink/cl-search-frontend": "^0.12.1",
7170
"@chainlink/components": "^0.4.18",
7271
"@chainlink/contracts": "1.5.0",
@@ -118,6 +117,7 @@
118117
},
119118
"devDependencies": {
120119
"@apidevtools/swagger-parser": "^10.1.1",
120+
"@astrojs/tailwind": "^6.0.2",
121121
"@jest/globals": "^29.7.0",
122122
"@project-serum/anchor": "^0.26.0",
123123
"@rollup/plugin-yaml": "^4.1.2",
@@ -132,6 +132,7 @@
132132
"@types/swagger-ui-react": "^5.18.0",
133133
"@typescript-eslint/eslint-plugin": "^5.62.0",
134134
"@typescript-eslint/parser": "^5.62.0",
135+
"autoprefixer": "^10.4.23",
135136
"eslint": "^8.57.0",
136137
"eslint-config-prettier": "^8.10.0",
137138
"eslint-config-standard": "^17.1.0",
@@ -147,16 +148,16 @@
147148
"pino-pretty": "^13.1.2",
148149
"prettier": "^3.5.3",
149150
"prettier-plugin-astro": "^0.14.1",
151+
"prettier-plugin-solidity": "^1.4.3",
150152
"remark-gfm": "^4.0.0",
151153
"remark-mdx": "^3.1.0",
152154
"remark-parse": "^11.0.0",
153155
"remark-stringify": "^11.0.0",
154156
"solhint": "^6.0.1",
155157
"solhint-plugin-chainlink-solidity": "github:smartcontractkit/chainlink-solhint-rules#v1.3.0",
156-
"ts-jest": "^29.4.5",
157-
"prettier-plugin-solidity": "^1.4.3",
158158
"solhint-plugin-prettier": "^0.1.0",
159-
"tailwindcss": "^3.4.18",
159+
"tailwindcss": "^3.4.19",
160+
"ts-jest": "^29.4.5",
160161
"tsconfig-paths": "^4.2.0",
161162
"tsx": "^4.20.6",
162163
"typescript": "^5.9.3",
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { cre } from "@chainlink/cre-sdk"
2+
3+
cre.handler(
4+
cron.trigger({ schedule: "0 */5 * * *" }), // Every 5 minutes
5+
(runtime) => {
6+
// Fetch data from API
7+
const price = httpClient.get(url).result()
8+
9+
// Read from EVM blockchain
10+
const threshold = evmClient.read(contract).result()
11+
12+
// Make any computation
13+
const shouldUpdate = price > threshold
14+
15+
// Write result onchain
16+
return evmClient.write(contract, price).result()
17+
}
18+
)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
2+
3+
contract SVRConsumer {
4+
AggregatorV3Interface internal svrFeed;
5+
6+
constructor(
7+
address _svrFeedAddress
8+
) {
9+
svrFeed = AggregatorV3Interface(_svrFeedAddress);
10+
}
11+
12+
function getLatestPrice() public view returns (int256) {
13+
(, /* uint80 roundID */
14+
int256 price,/* uint256 startedAt */
15+
/* uint256 timeStamp */
16+
/* uint80 answeredInRound */,,
17+
) = svrFeed.latestRoundData();
18+
return price;
19+
}
20+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { createClient, decodeReport, LogLevel, getReportVersion, formatReport } from "@chainlink/data-streams-sdk"
2+
import "dotenv/config"
3+
4+
async function main() {
5+
if (process.argv.length < 3) {
6+
console.error("Please provide a feed ID as an argument")
7+
console.error("Example: npx tsx singleStream.ts 0x000359843a543ee2fe414dc14c7e7920ef10f4372990b79d6361cdc0dd1ba782")
8+
process.exit(1)
9+
}
10+
11+
const feedId = process.argv[2]
12+
const version = getReportVersion(feedId)
13+
14+
try {
15+
const config = {
16+
apiKey: process.env.API_KEY || "YOUR_API_KEY",
17+
userSecret: process.env.USER_SECRET || "YOUR_USER_SECRET",
18+
endpoint: "https://api.testnet-dataengine.chain.link",
19+
wsEndpoint: "wss://ws.testnet-dataengine.chain.link",
20+
// Comment to disable SDK logging:
21+
logging: {
22+
logger: console,
23+
logLevel: LogLevel.INFO,
24+
},
25+
}
26+
27+
const client = createClient(config)
28+
console.log(`\nFetching latest report for feed ${feedId} (${version})...\n`)
29+
30+
// Get raw report data
31+
const report = await client.getLatestReport(feedId)
32+
console.log(`Raw Report Blob: ${report.fullReport}`)
33+
34+
// Decode the report
35+
const decodedData = decodeReport(report.fullReport, report.feedID)
36+
37+
// Combine decoded data with report metadata
38+
const decodedReport = {
39+
...decodedData,
40+
feedID: report.feedID,
41+
validFromTimestamp: report.validFromTimestamp,
42+
observationsTimestamp: report.observationsTimestamp,
43+
}
44+
console.log(formatReport(decodedReport, version))
45+
} catch (error) {
46+
if (error instanceof Error) {
47+
console.error("Error:", error.message)
48+
} else {
49+
console.error("Unknown error:", error)
50+
}
51+
process.exit(1)
52+
}
53+
}
54+
55+
main()

0 commit comments

Comments
 (0)