Skip to content

Commit dbc0a6b

Browse files
authored
Merge pull request #150 from smartcontractkit/rtinianov_cre_1613
2 parents af5a545 + f9b2c37 commit dbc0a6b

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed
-11.2 KB
Binary file not shown.

packages/cre-sdk-javy-plugin/src/javy_chainlink_sdk/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ pub unsafe extern "C" fn initialize_runtime() {
124124
)
125125
};
126126
if n < 0 {
127-
return Err(Error::new_into_js("Error", "await_capabilities failed"));
127+
let error_len = (-n) as usize;
128+
let error_msg = String::from_utf8_lossy(&buf[..error_len.min(max_len as usize)]).into_owned();
129+
let error_msg_static: &'static str = Box::leak(error_msg.into_boxed_str());
130+
return Err(Error::new_into_js("Error", error_msg_static));
128131
}
129132

130133
let out = &buf[..n as usize];

packages/cre-sdk/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
COMMON_VERSION ?= [email protected].0
1+
COMMON_VERSION ?= [email protected].1
22
MODULE := github.com/smartcontractkit/chainlink-common
33
TEST_PATTERN ?= ^TestStandard
44

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { BasicActionCapability } from '@cre/generated-sdk/capabilities/internal/basicaction/v1/basicaction_sdk_gen'
2+
import { BasicCapability as BasicTriggerCapability } from '@cre/generated-sdk/capabilities/internal/basictrigger/v1/basic_sdk_gen'
3+
import { cre, type Runtime } from '@cre/sdk/cre'
4+
import { Runner } from '@cre/sdk/wasm'
5+
6+
const asyncCalls = (runtime: Runtime<Uint8Array>) => {
7+
const basicAction = new BasicActionCapability()
8+
const input = { inputThing: true }
9+
const p = basicAction.performAction(runtime, input)
10+
11+
p.result()
12+
13+
return `We should not get here, result should throw an error`
14+
}
15+
16+
const initWorkflow = () => {
17+
const basicTrigger = new BasicTriggerCapability()
18+
return [cre.handler(basicTrigger.trigger({}), asyncCalls)]
19+
}
20+
21+
export async function main() {
22+
console.log(
23+
`TS workflow: standard test: capability calls are async [${new Date().toISOString()}]`,
24+
)
25+
26+
const runner = await Runner.newRunner<Uint8Array>({
27+
configParser: (c) => c,
28+
})
29+
runner.run(initWorkflow)
30+
}
31+
32+
await main()

0 commit comments

Comments
 (0)