Skip to content

Commit e8929d8

Browse files
Merge branch 'main' of github.com:smartcontractkit/cre-sdk-typescript into rtinianov_multi_javy_2
2 parents 9e258e7 + f6edcee commit e8929d8

19 files changed

Lines changed: 1526 additions & 2201 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,13 @@ jobs:
129129
CRE_API_KEY: ${{ secrets.CRE_CLI_API_KEY }}
130130
run: ./scripts/e2e/simulate-hello-world.sh
131131

132-
- name: E2E - Simulate star-wars workflow
133-
env:
134-
CRE_API_KEY: ${{ secrets.CRE_CLI_API_KEY }}
135-
run: ./scripts/e2e/simulate-star-wars.sh
132+
# Disabled: depends on external swapi.info which causes consensus
133+
# aggregator failures. Re-enable once we set up an HTTP service we
134+
# control for this workflow.
135+
# - name: E2E - Simulate star-wars workflow
136+
# env:
137+
# CRE_API_KEY: ${{ secrets.CRE_CLI_API_KEY }}
138+
# run: ./scripts/e2e/simulate-star-wars.sh
136139

137140
- name: E2E - Simulate log-trigger workflow
138141
env:

.github/workflows/validate-submodule.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ permissions: {}
33

44
on:
55
pull_request:
6-
types: [opened, synchronize, reopened]
6+
branches:
7+
- capabilities-development
78
push:
8-
branches: [capabilities-development]
9+
branches:
10+
- capabilities-development
911

1012
jobs:
1113
validate-submodule:
12-
if: github.event_name == 'push' || github.base_ref == 'capabilities-development'
1314
permissions:
1415
contents: read
1516
runs-on: ubuntu-latest

packages/cre-sdk-examples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@chainlink/cre-sdk-examples",
33
"private": true,
4-
"version": "1.4.0",
4+
"version": "1.6.0",
55
"type": "module",
66
"author": "Ernest Nowacki",
77
"license": "BUSL-1.1",

packages/cre-sdk-javy-plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@chainlink/cre-sdk-javy-plugin",
3-
"version": "1.2.0",
3+
"version": "1.5.0",
44
"type": "module",
55
"bin": {
66
"cre-setup": "bin/setup.ts",

packages/cre-sdk/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,15 @@ This SDK uses [@bufbuild/protobuf](https://www.npmjs.com/package/@bufbuild/proto
516516
- `buf.gen.yaml` - Code generation configuration using ts-proto
517517
- Generated files are placed in `src/generated/`
518518

519+
**Opt-in proto allowlist:**
520+
521+
[`buf.gen.yaml`](./buf.gen.yaml) uses an explicit `paths:` allowlist under its `inputs`. Protos added to the `chainlink-protos` submodule are **not** picked up automatically — a new capability must be added to both:
522+
523+
1. [`packages/cre-sdk/buf.gen.yaml`](./buf.gen.yaml) — to generate the raw `*_pb.ts` types.
524+
2. [`packages/cre-sdk/scripts/src/generate-sdks.ts`](./scripts/src/generate-sdks.ts) — to generate the SDK wrapper classes and mocks.
525+
526+
This prevents leaking in-progress or internal capabilities into the public SDK surface before they are ready.
527+
519528
### Chain Selectors Generation
520529

521530
Auto-generated TypeScript files for 200+ blockchain networks from the official [Chainlink chain-selectors repository](https://github.com/smartcontractkit/chain-selectors).

packages/cre-sdk/buf.gen.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,26 @@ managed:
1010

1111
inputs:
1212
- directory: ../../submodules/chainlink-protos/cre
13+
# Allowlist: only generate for protos we explicitly opt into.
14+
# New protos added to chainlink-protos/cre will NOT be picked up
15+
# until listed here. Keep in sync with generate-sdks.ts.
16+
paths:
17+
- ../../submodules/chainlink-protos/cre/capabilities/blockchain/aptos/v1alpha
18+
- ../../submodules/chainlink-protos/cre/capabilities/blockchain/evm/v1alpha
19+
- ../../submodules/chainlink-protos/cre/capabilities/internal/actionandtrigger/v1
20+
- ../../submodules/chainlink-protos/cre/capabilities/internal/basicaction/v1
21+
- ../../submodules/chainlink-protos/cre/capabilities/internal/basictrigger/v1
22+
- ../../submodules/chainlink-protos/cre/capabilities/internal/consensus/v1alpha
23+
- ../../submodules/chainlink-protos/cre/capabilities/internal/importclash/p1/v1
24+
- ../../submodules/chainlink-protos/cre/capabilities/internal/importclash/p2/v1
25+
- ../../submodules/chainlink-protos/cre/capabilities/internal/importclash/v1
26+
- ../../submodules/chainlink-protos/cre/capabilities/internal/nodeaction/v1
27+
- ../../submodules/chainlink-protos/cre/capabilities/networking/confidentialhttp/v1alpha
28+
- ../../submodules/chainlink-protos/cre/capabilities/networking/http/v1alpha
29+
- ../../submodules/chainlink-protos/cre/capabilities/scheduler/cron/v1
30+
- ../../submodules/chainlink-protos/cre/sdk/v1alpha
31+
- ../../submodules/chainlink-protos/cre/tools/generator/v1alpha
32+
- ../../submodules/chainlink-protos/cre/values/v1
1333

1434
plugins:
1535
# Modern @bufbuild/protoc-gen-es plugin

packages/cre-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@chainlink/cre-sdk",
3-
"version": "1.4.0",
3+
"version": "1.6.0",
44
"type": "module",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

packages/cre-sdk/scripts/run.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { WorkflowRuntimeCompatibilityError } from './src/validate-workflow-runti
55

66
const availableScripts = [
77
'build-types',
8+
'check-determinism', // Check for non-deterministic patterns in workflow source
89
'compile-to-js',
910
'compile-to-wasm',
1011
'compile-workflow', // TS -> JS -> WASM compilation in single script
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test'
2+
import { spawnSync } from 'node:child_process'
3+
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'
4+
import { tmpdir } from 'node:os'
5+
import path from 'node:path'
6+
7+
let tempDir: string
8+
9+
const scriptsDir = path.resolve(import.meta.dir, '..')
10+
const runScript = path.join(scriptsDir, 'run.ts')
11+
12+
beforeEach(() => {
13+
tempDir = mkdtempSync(path.join(tmpdir(), 'cre-check-determinism-test-'))
14+
})
15+
16+
afterEach(() => {
17+
rmSync(tempDir, { recursive: true, force: true })
18+
})
19+
20+
const runCheckDeterminism = (filePath: string) =>
21+
spawnSync(process.execPath, [runScript, 'check-determinism', filePath], {
22+
cwd: scriptsDir,
23+
encoding: 'utf-8',
24+
})
25+
26+
describe('check-determinism CLI', () => {
27+
test('fails when the input file does not exist', () => {
28+
const missingFile = path.join(tempDir, 'does-not-exist.ts')
29+
const result = runCheckDeterminism(missingFile)
30+
31+
expect(result.status).toBe(1)
32+
expect(result.stdout).not.toContain('No non-determinism warnings found.')
33+
expect(result.stderr).toContain(`❌ File not found: ${missingFile}`)
34+
})
35+
36+
test('prints warnings for non-deterministic patterns and exits 0', () => {
37+
const filePath = path.join(tempDir, 'workflow.ts')
38+
writeFileSync(filePath, `const result = await Promise.race([]);\n`, 'utf-8')
39+
const result = runCheckDeterminism(filePath)
40+
41+
expect(result.status).toBe(0)
42+
expect(result.stderr).toContain('Non-determinism warnings')
43+
expect(result.stderr).toContain('Promise.race()')
44+
})
45+
46+
test('prints success message for clean workflow and exits 0', () => {
47+
const filePath = path.join(tempDir, 'workflow.ts')
48+
writeFileSync(filePath, `const x = 1;\n`, 'utf-8')
49+
const result = runCheckDeterminism(filePath)
50+
51+
expect(result.status).toBe(0)
52+
expect(result.stdout).toContain('No non-determinism warnings found.')
53+
})
54+
55+
test('fails when no input file is provided', () => {
56+
const result = spawnSync(process.execPath, [runScript, 'check-determinism'], {
57+
cwd: scriptsDir,
58+
encoding: 'utf-8',
59+
})
60+
61+
expect(result.status).toBe(1)
62+
expect(result.stderr).toContain('Usage:')
63+
})
64+
})
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { existsSync } from 'node:fs'
2+
import path from 'node:path'
3+
import { checkWorkflowDeterminism, printDeterminismWarnings } from './validate-workflow-determinism'
4+
5+
const printUsage = () => {
6+
console.error('Usage: bun scripts/run.ts check-determinism <path/to/workflow.ts>')
7+
console.error('Example:')
8+
console.error(' bun scripts/run.ts check-determinism src/workflows/my-workflow/index.ts')
9+
}
10+
11+
export const main = () => {
12+
const inputPath = process.argv[3]
13+
14+
if (!inputPath) {
15+
printUsage()
16+
process.exit(1)
17+
}
18+
19+
const resolvedInput = path.resolve(inputPath)
20+
if (!existsSync(resolvedInput)) {
21+
console.error(`❌ File not found: ${resolvedInput}`)
22+
process.exit(1)
23+
}
24+
25+
const warnings = checkWorkflowDeterminism(resolvedInput)
26+
27+
if (warnings.length > 0) {
28+
printDeterminismWarnings(warnings)
29+
} else {
30+
console.info('No non-determinism warnings found.')
31+
}
32+
}

0 commit comments

Comments
 (0)