Skip to content

Commit eed181d

Browse files
Merge pull request #231 from smartcontractkit/DF-23782
add emitMetric global fn
2 parents 0a16c19 + b81d060 commit eed181d

16 files changed

Lines changed: 496 additions & 4 deletions

File tree

Binary file not shown.

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ unsafe extern "C" {
5151
fn random_seed(mode: i32) -> i64;
5252

5353
fn now(result_timestamp: *mut u8) -> i32;
54+
55+
fn emit_metric(data_ptr: *const u8, data_len: i32) -> i32;
5456
}
5557

5658
import_namespace!("javy_chainlink_sdk");
@@ -226,6 +228,16 @@ pub fn modify_runtime(runtime: Runtime) -> Runtime {
226228
}),
227229
);
228230

231+
extend_wasm_exports(
232+
&ctx,
233+
"emitMetric",
234+
Func::from(|_ctx: Ctx<'_>, data: ArgBytes| {
235+
let bytes = data.0;
236+
let rc = unsafe { emit_metric(bytes.as_ptr(), bytes.len() as i32) };
237+
Ok::<i32, Error>(rc)
238+
}),
239+
);
240+
229241
extend_wasm_exports(
230242
&ctx,
231243
"sendResponse",

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 ?= cre-std-tests@0.6.0
1+
COMMON_VERSION ?= 8c592883ed580efbf21afd2c15bc0b40727fb071
22
MODULE := github.com/smartcontractkit/chainlink-common
33
TEST_PATTERN ?= ^TestStandard
44

packages/cre-sdk/buf.gen.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ inputs:
3030
- ../../submodules/chainlink-protos/cre/sdk/v1alpha
3131
- ../../submodules/chainlink-protos/cre/tools/generator/v1alpha
3232
- ../../submodules/chainlink-protos/cre/values/v1
33+
- directory: ../../submodules/chainlink-protos/workflows
34+
# Allowlist of workflow protos exposed in the SDK (e.g. user metrics).
35+
paths:
36+
- ../../submodules/chainlink-protos/workflows/workflows/v2/workflow_user_metric.proto
37+
- ../../submodules/chainlink-protos/workflows/workflows/v2/cre_info.proto
38+
- ../../submodules/chainlink-protos/workflows/workflows/v2/workflow_key.proto
3339

3440
plugins:
3541
# Modern @bufbuild/protoc-gen-es plugin
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
// @generated by protoc-gen-es v2.6.3 with parameter "target=ts,import_extension=none,json_types=true,keep_empty_files=false"
2+
// @generated from file workflows/v2/cre_info.proto (package workflows.v2, syntax proto3)
3+
/* eslint-disable */
4+
5+
import type { Message } from '@bufbuild/protobuf'
6+
import type { GenFile, GenMessage } from '@bufbuild/protobuf/codegenv2'
7+
import { fileDesc, messageDesc } from '@bufbuild/protobuf/codegenv2'
8+
9+
/**
10+
* Describes the file workflows/v2/cre_info.proto.
11+
*/
12+
export const file_workflows_v2_cre_info: GenFile =
13+
/*@__PURE__*/
14+
fileDesc(
15+
'Cht3b3JrZmxvd3MvdjIvY3JlX2luZm8ucHJvdG8SDHdvcmtmbG93cy52MiKMAgoHQ3JlSW5mbxINCgVkb25JRBgBIAEoBRIMCgRkb25GGAIgASgFEgwKBGRvbk4YAyABKAUSDQoFcDJwSUQYBCABKAkSHwoXd29ya2Zsb3dSZWdpc3RyeUFkZHJlc3MYBSABKAkSHwoXd29ya2Zsb3dSZWdpc3RyeVZlcnNpb24YBiABKAkSHQoVd29ya2Zsb3dSZWdpc3RyeUNoYWluGAcgASgJEhUKDWVuZ2luZVZlcnNpb24YCCABKAkSIwobY2FwYWJpbGl0aWVzUmVnaXN0cnlWZXJzaW9uGAkgASgJEhIKCmRvblZlcnNpb24YCiABKAkSFgoOd29ya2Zsb3dTb3VyY2UYCyABKAlCrwEKEGNvbS53b3JrZmxvd3MudjJCDENyZUluZm9Qcm90b1ABWjxnaXRodWIuY29tL3NtYXJ0Y29udHJhY3RraXQvY2hhaW5saW5rLXByb3Rvcy93b3JrZmxvd3MvZ28vdjKiAgNXWFiqAgxXb3JrZmxvd3MuVjLKAgxXb3JrZmxvd3NcVjLiAhhXb3JrZmxvd3NcVjJcR1BCTWV0YWRhdGHqAg1Xb3JrZmxvd3M6OlYyYgZwcm90bzM',
16+
)
17+
18+
/**
19+
* @generated from message workflows.v2.CreInfo
20+
*/
21+
export type CreInfo = Message<'workflows.v2.CreInfo'> & {
22+
/**
23+
* @generated from field: int32 donID = 1;
24+
*/
25+
donID: number
26+
27+
/**
28+
* @generated from field: int32 donF = 2;
29+
*/
30+
donF: number
31+
32+
/**
33+
* @generated from field: int32 donN = 3;
34+
*/
35+
donN: number
36+
37+
/**
38+
* @generated from field: string p2pID = 4;
39+
*/
40+
p2pID: string
41+
42+
/**
43+
* @generated from field: string workflowRegistryAddress = 5;
44+
*/
45+
workflowRegistryAddress: string
46+
47+
/**
48+
* @generated from field: string workflowRegistryVersion = 6;
49+
*/
50+
workflowRegistryVersion: string
51+
52+
/**
53+
* @generated from field: string workflowRegistryChain = 7;
54+
*/
55+
workflowRegistryChain: string
56+
57+
/**
58+
* @generated from field: string engineVersion = 8;
59+
*/
60+
engineVersion: string
61+
62+
/**
63+
* @generated from field: string capabilitiesRegistryVersion = 9;
64+
*/
65+
capabilitiesRegistryVersion: string
66+
67+
/**
68+
* @generated from field: string donVersion = 10;
69+
*/
70+
donVersion: string
71+
72+
/**
73+
* workflowSource identifies where the workflow was deployed from.
74+
* Format varies by source type:
75+
* - Onchain contract: "contract:{chain_selector}:{contract_address}"
76+
* - GRPC source: "grpc:{source_name}:v1"
77+
* - File source: "file:{source_name}:v1"
78+
*
79+
* @generated from field: string workflowSource = 11;
80+
*/
81+
workflowSource: string
82+
}
83+
84+
/**
85+
* @generated from message workflows.v2.CreInfo
86+
*/
87+
export type CreInfoJson = {
88+
/**
89+
* @generated from field: int32 donID = 1;
90+
*/
91+
donID?: number
92+
93+
/**
94+
* @generated from field: int32 donF = 2;
95+
*/
96+
donF?: number
97+
98+
/**
99+
* @generated from field: int32 donN = 3;
100+
*/
101+
donN?: number
102+
103+
/**
104+
* @generated from field: string p2pID = 4;
105+
*/
106+
p2pID?: string
107+
108+
/**
109+
* @generated from field: string workflowRegistryAddress = 5;
110+
*/
111+
workflowRegistryAddress?: string
112+
113+
/**
114+
* @generated from field: string workflowRegistryVersion = 6;
115+
*/
116+
workflowRegistryVersion?: string
117+
118+
/**
119+
* @generated from field: string workflowRegistryChain = 7;
120+
*/
121+
workflowRegistryChain?: string
122+
123+
/**
124+
* @generated from field: string engineVersion = 8;
125+
*/
126+
engineVersion?: string
127+
128+
/**
129+
* @generated from field: string capabilitiesRegistryVersion = 9;
130+
*/
131+
capabilitiesRegistryVersion?: string
132+
133+
/**
134+
* @generated from field: string donVersion = 10;
135+
*/
136+
donVersion?: string
137+
138+
/**
139+
* workflowSource identifies where the workflow was deployed from.
140+
* Format varies by source type:
141+
* - Onchain contract: "contract:{chain_selector}:{contract_address}"
142+
* - GRPC source: "grpc:{source_name}:v1"
143+
* - File source: "file:{source_name}:v1"
144+
*
145+
* @generated from field: string workflowSource = 11;
146+
*/
147+
workflowSource?: string
148+
}
149+
150+
/**
151+
* Describes the message workflows.v2.CreInfo.
152+
* Use `create(CreInfoSchema)` to create a new message.
153+
*/
154+
export const CreInfoSchema: GenMessage<CreInfo, { jsonType: CreInfoJson }> =
155+
/*@__PURE__*/
156+
messageDesc(file_workflows_v2_cre_info, 0)
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// @generated by protoc-gen-es v2.6.3 with parameter "target=ts,import_extension=none,json_types=true,keep_empty_files=false"
2+
// @generated from file workflows/v2/workflow_key.proto (package workflows.v2, syntax proto3)
3+
/* eslint-disable */
4+
5+
import type { Message } from '@bufbuild/protobuf'
6+
import type { GenFile, GenMessage } from '@bufbuild/protobuf/codegenv2'
7+
import { fileDesc, messageDesc } from '@bufbuild/protobuf/codegenv2'
8+
9+
/**
10+
* Describes the file workflows/v2/workflow_key.proto.
11+
*/
12+
export const file_workflows_v2_workflow_key: GenFile =
13+
/*@__PURE__*/
14+
fileDesc(
15+
'Ch93b3JrZmxvd3MvdjIvd29ya2Zsb3dfa2V5LnByb3RvEgx3b3JrZmxvd3MudjIiZgoLV29ya2Zsb3dLZXkSFQoNd29ya2Zsb3dPd25lchgBIAEoCRIUCgx3b3JrZmxvd05hbWUYAiABKAkSEgoKd29ya2Zsb3dJRBgDIAEoCRIWCg5vcmdhbml6YXRpb25JRBgEIAEoCUKzAQoQY29tLndvcmtmbG93cy52MkIQV29ya2Zsb3dLZXlQcm90b1ABWjxnaXRodWIuY29tL3NtYXJ0Y29udHJhY3RraXQvY2hhaW5saW5rLXByb3Rvcy93b3JrZmxvd3MvZ28vdjKiAgNXWFiqAgxXb3JrZmxvd3MuVjLKAgxXb3JrZmxvd3NcVjLiAhhXb3JrZmxvd3NcVjJcR1BCTWV0YWRhdGHqAg1Xb3JrZmxvd3M6OlYyYgZwcm90bzM',
16+
)
17+
18+
/**
19+
* @generated from message workflows.v2.WorkflowKey
20+
*/
21+
export type WorkflowKey = Message<'workflows.v2.WorkflowKey'> & {
22+
/**
23+
* @generated from field: string workflowOwner = 1;
24+
*/
25+
workflowOwner: string
26+
27+
/**
28+
* @generated from field: string workflowName = 2;
29+
*/
30+
workflowName: string
31+
32+
/**
33+
* @generated from field: string workflowID = 3;
34+
*/
35+
workflowID: string
36+
37+
/**
38+
* @generated from field: string organizationID = 4;
39+
*/
40+
organizationID: string
41+
}
42+
43+
/**
44+
* @generated from message workflows.v2.WorkflowKey
45+
*/
46+
export type WorkflowKeyJson = {
47+
/**
48+
* @generated from field: string workflowOwner = 1;
49+
*/
50+
workflowOwner?: string
51+
52+
/**
53+
* @generated from field: string workflowName = 2;
54+
*/
55+
workflowName?: string
56+
57+
/**
58+
* @generated from field: string workflowID = 3;
59+
*/
60+
workflowID?: string
61+
62+
/**
63+
* @generated from field: string organizationID = 4;
64+
*/
65+
organizationID?: string
66+
}
67+
68+
/**
69+
* Describes the message workflows.v2.WorkflowKey.
70+
* Use `create(WorkflowKeySchema)` to create a new message.
71+
*/
72+
export const WorkflowKeySchema: GenMessage<WorkflowKey, { jsonType: WorkflowKeyJson }> =
73+
/*@__PURE__*/
74+
messageDesc(file_workflows_v2_workflow_key, 0)

0 commit comments

Comments
 (0)