Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,9 @@ jobs:
env:
CRE_API_KEY: ${{ secrets.CRE_CLI_API_KEY }}
run: ./scripts/e2e/simulate-log-trigger.sh

# Rust extension examples: build cre-rust-inject-alpha, compile workflows, simulate.
- name: E2E - Simulate rust-inject workflows
env:
CRE_API_KEY: ${{ secrets.CRE_CLI_API_KEY }}
run: ./scripts/e2e/simulate-rust-inject.sh
63 changes: 57 additions & 6 deletions bun.lock

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

3 changes: 3 additions & 0 deletions packages/cre-rust-inject-alpha/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
target/
Cargo.lock
11 changes: 11 additions & 0 deletions packages/cre-rust-inject-alpha/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "alpha"
version = "0.1.0"
edition = "2024"

[lib]
crate-type = ["lib"]

[dependencies]
cre_wasm_exports = { path = "../cre-sdk-javy-plugin/src/cre_wasm_exports" }
javy-plugin-api = "6.0.0"
15 changes: 15 additions & 0 deletions packages/cre-rust-inject-alpha/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Build alpha.plugin.wasm using the workspace @chainlink/cre-sdk-javy-plugin.
JAVY_PLUGIN := $(abspath ../cre-sdk-javy-plugin)

.PHONY: build clean

build: dist/alpha.plugin.wasm

dist/alpha.plugin.wasm: Cargo.toml src/lib.rs
mkdir -p dist
CRE_SDK_JAVY_PLUGIN_HOME="$(JAVY_PLUGIN)" bun "$(JAVY_PLUGIN)/scripts/build-plugin.ts" \
--cre-exports . \
-o ./dist/alpha.plugin.wasm

clean:
rm -rf dist
41 changes: 41 additions & 0 deletions packages/cre-rust-inject-alpha/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "https://biomejs.dev/schemas/2.3.14/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": false,
"includes": ["**/*.ts", "**/*.json"]
},
"formatter": {
"enabled": true,
"indentStyle": "tab",
"lineWidth": 100
},
"assist": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"correctness": {
"noUnusedVariables": "error"
},
"suspicious": {
"noExplicitAny": "warn"
},
"style": {
"useConst": "error"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"semicolons": "asNeeded"
}
}
}
15 changes: 15 additions & 0 deletions packages/cre-rust-inject-alpha/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { createExtensionAccessor } from '@chainlink/cre-sdk-javy-plugin/runtime/validate-extension'
import { z } from 'zod'

const rustAlphaSchema = z.object({
greet: z.function().args().returns(z.string()),
})

export type RustAlpha = z.infer<typeof rustAlphaSchema>

declare global {
var rustAlpha: RustAlpha
}

// biome-ignore lint/suspicious/noRedeclare: global augmentation declares rustAlpha; this export is the validated accessor
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see

"Shouldn't redeclare 'rustAlpha'. Consider to delete it or rename it.biomelint/suspicious/noRedeclare" if I remove this one.

export const rustAlpha = createExtensionAccessor('rustAlpha', rustAlphaSchema)
24 changes: 24 additions & 0 deletions packages/cre-rust-inject-alpha/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@chainlink/cre-rust-inject-alpha",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Note: this probably doesn't matter for the purpose of this demo, but monorepo would only be able to resolve the path @chainlink/cre-rust-inject-alpha if it lives under /packages.

Copy link
Copy Markdown
Contributor Author

@nolag nolag Apr 10, 2026

Choose a reason for hiding this comment

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

I'm a bit confused by that, I have this library packed and imported in the test and it works.

I'll tell cursor your comment and see what it does with it.

"version": "0.1.0",
"private": true,
"type": "module",
"description": "Example Rust extension (alpha) for CRE rust-inject demos — packaged plugin wasm + crate source.",
"scripts": {
"check": "biome check --write ${BIOME_PATHS:-.}",
"check:ci": "biome ci .",
"typecheck": "tsc"
},
"files": [
"dist",
"src",
"Cargo.toml",
"index.ts"
],
"keywords": [],
"license": "BUSL-1.1",
"peerDependencies": {
"@chainlink/cre-sdk-javy-plugin": ">=1.0.0",
"zod": ">=3.0.0"
}
}
13 changes: 13 additions & 0 deletions packages/cre-rust-inject-alpha/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use cre_wasm_exports::extend_wasm_exports;
use javy_plugin_api::javy::quickjs::prelude::*;
use javy_plugin_api::javy::quickjs::{Ctx, Object};

pub fn register(ctx: &Ctx<'_>) {
let obj = Object::new(ctx.clone()).unwrap();
obj.set(
"greet",
Func::from(|| -> String { "Hello from alpha".to_string() }),
)
.unwrap();
extend_wasm_exports(ctx, "rustAlpha", obj);
}
17 changes: 17 additions & 0 deletions packages/cre-rust-inject-alpha/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"target": "ESNext",
"module": "ESNext",
"moduleDetection": "force",
"allowJs": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,
"strict": true,
"skipLibCheck": true,
"types": []
},
"include": ["index.ts"]
}
2 changes: 2 additions & 0 deletions packages/cre-rust-inject-beta/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
Cargo.lock
11 changes: 11 additions & 0 deletions packages/cre-rust-inject-beta/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "lib_beta"
version = "0.1.0"
edition = "2024"

[lib]
crate-type = ["lib"]

[dependencies]
cre_wasm_exports = { path = "../cre-sdk-javy-plugin/src/cre_wasm_exports" }
javy-plugin-api = "6.0.0"
41 changes: 41 additions & 0 deletions packages/cre-rust-inject-beta/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "https://biomejs.dev/schemas/2.3.14/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": false,
"includes": ["**/*.ts", "**/*.json"]
},
"formatter": {
"enabled": true,
"indentStyle": "tab",
"lineWidth": 100
},
"assist": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"correctness": {
"noUnusedVariables": "error"
},
"suspicious": {
"noExplicitAny": "warn"
},
"style": {
"useConst": "error"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"semicolons": "asNeeded"
}
}
}
15 changes: 15 additions & 0 deletions packages/cre-rust-inject-beta/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { createExtensionAccessor } from '@chainlink/cre-sdk-javy-plugin/runtime/validate-extension'
import { z } from 'zod'

const rustBetaSchema = z.object({
greet: z.function().args().returns(z.string()),
})

export type RustBeta = z.infer<typeof rustBetaSchema>

declare global {
var rustBeta: RustBeta
}

// biome-ignore lint/suspicious/noRedeclare: global augmentation declares rustBeta; this export is the validated accessor
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// biome-ignore lint/suspicious/noRedeclare: global augmentation declares rustBeta; this export is the validated accessor
// global augmentation declares rustBeta; this export is the validated accessor

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same as above, I see an error in Cursor without it.

export const rustBeta = createExtensionAccessor('rustBeta', rustBetaSchema)
23 changes: 23 additions & 0 deletions packages/cre-rust-inject-beta/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "@chainlink/cre-rust-inject-beta",
"version": "0.1.0",
"private": true,
"type": "module",
"description": "Example Rust extension (beta) for CRE rust-inject demos — crate source.",
"scripts": {
"check": "biome check --write ${BIOME_PATHS:-.}",
"check:ci": "biome ci .",
"typecheck": "tsc"
},
"files": [
"src",
"Cargo.toml",
"index.ts"
],
"keywords": [],
"license": "BUSL-1.1",
"peerDependencies": {
"@chainlink/cre-sdk-javy-plugin": ">=1.0.0",
"zod": ">=3.0.0"
}
}
13 changes: 13 additions & 0 deletions packages/cre-rust-inject-beta/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use cre_wasm_exports::extend_wasm_exports;
use javy_plugin_api::javy::quickjs::prelude::*;
use javy_plugin_api::javy::quickjs::{Ctx, Object};

pub fn register(ctx: &Ctx<'_>) {
let obj = Object::new(ctx.clone()).unwrap();
obj.set(
"greet",
Func::from(|| -> String { "Hello from beta".to_string() }),
)
.unwrap();
extend_wasm_exports(ctx, "rustBeta", obj);
}
Loading
Loading