@chainlink/cre-sdk 1.0.8 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -9
- package/dist/generated/capabilities/blockchain/evm/v1alpha/client_pb.js +1 -1
- package/dist/generated/capabilities/internal/actionandtrigger/v1/action_and_trigger_pb.d.ts +135 -0
- package/dist/generated/capabilities/internal/actionandtrigger/v1/action_and_trigger_pb.js +43 -0
- package/dist/generated/capabilities/internal/basicaction/v1/basic_action_pb.d.ts +77 -0
- package/dist/generated/capabilities/internal/basicaction/v1/basic_action_pb.js +33 -0
- package/dist/generated/capabilities/internal/nodeaction/v1/node_action_pb.d.ts +69 -0
- package/dist/generated/capabilities/internal/nodeaction/v1/node_action_pb.js +29 -0
- package/dist/generated/capabilities/networking/confidentialhttp/v1alpha/client_pb.d.ts +199 -100
- package/dist/generated/capabilities/networking/confidentialhttp/v1alpha/client_pb.js +18 -18
- package/dist/generated/capabilities/networking/http/v1alpha/client_pb.d.ts +69 -4
- package/dist/generated/capabilities/networking/http/v1alpha/client_pb.js +10 -3
- package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.d.ts +1 -0
- package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.js +1 -0
- package/dist/generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen.d.ts +4 -18
- package/dist/generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen.js +7 -34
- package/dist/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.js +0 -3
- package/dist/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.js +0 -3
- package/dist/sdk/cre/index.d.ts +1 -1
- package/dist/sdk/cre/index.js +1 -1
- package/dist/sdk/errors.d.ts +2 -2
- package/dist/sdk/errors.js +3 -1
- package/dist/sdk/impl/runtime-impl.js +5 -5
- package/dist/sdk/test/generated/capabilities/blockchain/evm/v1alpha/evm_mock_gen.d.ts +31 -0
- package/dist/sdk/test/generated/capabilities/blockchain/evm/v1alpha/evm_mock_gen.js +158 -0
- package/dist/sdk/test/generated/capabilities/internal/actionandtrigger/v1/basic_test_action_trigger_mock_gen.d.ts +17 -0
- package/dist/sdk/test/generated/capabilities/internal/actionandtrigger/v1/basic_test_action_trigger_mock_gen.js +53 -0
- package/dist/sdk/test/generated/capabilities/internal/basicaction/v1/basic_test_action_mock_gen.d.ts +17 -0
- package/dist/sdk/test/generated/capabilities/internal/basicaction/v1/basic_test_action_mock_gen.js +53 -0
- package/dist/sdk/test/generated/capabilities/internal/consensus/v1alpha/consensus_mock_gen.d.ts +20 -0
- package/dist/sdk/test/generated/capabilities/internal/consensus/v1alpha/consensus_mock_gen.js +67 -0
- package/dist/sdk/test/generated/capabilities/internal/nodeaction/v1/basic_test_node_action_mock_gen.d.ts +17 -0
- package/dist/sdk/test/generated/capabilities/internal/nodeaction/v1/basic_test_node_action_mock_gen.js +53 -0
- package/dist/sdk/test/generated/capabilities/networking/confidentialhttp/v1alpha/confidential_http_mock_gen.d.ts +17 -0
- package/dist/sdk/test/generated/capabilities/networking/confidentialhttp/v1alpha/confidential_http_mock_gen.js +53 -0
- package/dist/sdk/test/generated/capabilities/networking/http/v1alpha/http_actions_mock_gen.d.ts +17 -0
- package/dist/sdk/test/generated/capabilities/networking/http/v1alpha/http_actions_mock_gen.js +53 -0
- package/dist/sdk/test/generated/index.d.ts +8 -0
- package/dist/sdk/test/generated/index.js +8 -0
- package/dist/sdk/test/index.d.ts +7 -0
- package/dist/sdk/test/index.js +7 -0
- package/dist/sdk/testutils/index.d.ts +6 -0
- package/dist/sdk/testutils/index.js +6 -0
- package/dist/sdk/testutils/test-runtime.d.ts +84 -0
- package/dist/sdk/testutils/test-runtime.js +309 -0
- package/dist/sdk/testutils/test-writer.d.ts +13 -0
- package/dist/sdk/testutils/test-writer.js +19 -0
- package/dist/sdk/utils/capabilities/blockchain/blockchain-helpers.d.ts +1 -1
- package/dist/sdk/utils/capabilities/blockchain/blockchain-helpers.js +5 -0
- package/dist/sdk/utils/capabilities/http/http-helpers.d.ts +7 -7
- package/dist/sdk/utils/chain-selectors/network-lookup.js +1 -1
- package/dist/sdk/utils/hex-utils.js +12 -0
- package/dist/sdk/utils/values/value.js +10 -6
- package/dist/sdk/wasm/host-bindings.js +3 -1
- package/dist/sdk/wasm/runner.js +22 -8
- package/dist/sdk/wasm/runtime.js +10 -9
- package/dist/sdk/wasm/send-error-response.js +6 -0
- package/dist/workflows/standard_tests/host_wasm_write_errors_are_respected/test.ts +1 -1
- package/dist/workflows/standard_tests/mode_switch/don_runtime_in_node_mode/test.ts +1 -1
- package/dist/workflows/standard_tests/time_interpretation/test.ts +32 -0
- package/package.json +11 -6
- package/scripts/src/cre-setup.ts +1 -1
- package/scripts/src/generate-sdks.ts +52 -0
|
@@ -54,6 +54,7 @@ export class ClientCapability {
|
|
|
54
54
|
'ethereum-mainnet-arbitrum-1': 4949039107694359620n,
|
|
55
55
|
'ethereum-mainnet-base-1': 15971525489660198786n,
|
|
56
56
|
'ethereum-mainnet-optimism-1': 3734403246176062136n,
|
|
57
|
+
'ethereum-mainnet-worldchain-1': 2049429975587534727n,
|
|
57
58
|
'ethereum-mainnet-zksync-1': 1562403441176082196n,
|
|
58
59
|
'ethereum-testnet-sepolia': 16015286601757825753n,
|
|
59
60
|
'ethereum-testnet-sepolia-arbitrum-1': 3478487238524512106n,
|
package/dist/generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen.d.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type
|
|
3
|
-
import type { ConsensusAggregation, PrimitiveTypes, UnwrapOptions } from '../../../../../sdk/utils';
|
|
4
|
-
export declare class SendRequestser {
|
|
5
|
-
private readonly runtime;
|
|
6
|
-
private readonly client;
|
|
7
|
-
constructor(runtime: NodeRuntime<unknown>, client: ClientCapability);
|
|
8
|
-
sendRequests(input: EnclaveActionInput | EnclaveActionInputJson): {
|
|
9
|
-
result: () => HTTPEnclaveResponseData;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
1
|
+
import { type ConfidentialHTTPRequest, type ConfidentialHTTPRequestJson, type HTTPResponse } from '../../../../../generated/capabilities/networking/confidentialhttp/v1alpha/client_pb';
|
|
2
|
+
import { type Runtime } from '../../../../../sdk';
|
|
12
3
|
/**
|
|
13
4
|
* Client Capability
|
|
14
5
|
*
|
|
@@ -21,12 +12,7 @@ export declare class ClientCapability {
|
|
|
21
12
|
static readonly CAPABILITY_ID = "confidential-http@1.0.0-alpha";
|
|
22
13
|
static readonly CAPABILITY_NAME = "confidential-http";
|
|
23
14
|
static readonly CAPABILITY_VERSION = "1.0.0-alpha";
|
|
24
|
-
|
|
25
|
-
result: () =>
|
|
26
|
-
};
|
|
27
|
-
sendRequests<TArgs extends unknown[], TOutput>(runtime: Runtime<unknown>, fn: (sendRequestser: SendRequestser, ...args: TArgs) => TOutput, consensusAggregation: ConsensusAggregation<TOutput, true>, unwrapOptions?: TOutput extends PrimitiveTypes ? never : UnwrapOptions<TOutput>): (...args: TArgs) => {
|
|
28
|
-
result: () => TOutput;
|
|
15
|
+
sendRequest(runtime: Runtime<unknown>, input: ConfidentialHTTPRequest | ConfidentialHTTPRequestJson): {
|
|
16
|
+
result: () => HTTPResponse;
|
|
29
17
|
};
|
|
30
|
-
private sendRequestsCallHelper;
|
|
31
|
-
private sendRequestsSugarHelper;
|
|
32
18
|
}
|
package/dist/generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen.js
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
import { fromJson } from '@bufbuild/protobuf';
|
|
2
|
-
import {
|
|
2
|
+
import { ConfidentialHTTPRequestSchema, HTTPResponseSchema, } from '../../../../../generated/capabilities/networking/confidentialhttp/v1alpha/client_pb';
|
|
3
3
|
import {} from '../../../../../sdk';
|
|
4
4
|
import { Report } from '../../../../../sdk/report';
|
|
5
|
-
|
|
6
|
-
runtime;
|
|
7
|
-
client;
|
|
8
|
-
constructor(runtime, client) {
|
|
9
|
-
this.runtime = runtime;
|
|
10
|
-
this.client = client;
|
|
11
|
-
}
|
|
12
|
-
sendRequests(input) {
|
|
13
|
-
return this.client.sendRequests(this.runtime, input);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
5
|
+
import { hexToBytes } from '../../../../../sdk/utils/hex-utils';
|
|
16
6
|
/**
|
|
17
7
|
* Client Capability
|
|
18
8
|
*
|
|
@@ -25,17 +15,7 @@ export class ClientCapability {
|
|
|
25
15
|
static CAPABILITY_ID = 'confidential-http@1.0.0-alpha';
|
|
26
16
|
static CAPABILITY_NAME = 'confidential-http';
|
|
27
17
|
static CAPABILITY_VERSION = '1.0.0-alpha';
|
|
28
|
-
|
|
29
|
-
// Check if this is the sugar syntax overload (has function parameter)
|
|
30
|
-
if (typeof args[1] === 'function') {
|
|
31
|
-
const [runtime, fn, consensusAggregation, unwrapOptions] = args;
|
|
32
|
-
return this.sendRequestsSugarHelper(runtime, fn, consensusAggregation, unwrapOptions);
|
|
33
|
-
}
|
|
34
|
-
// Otherwise, this is the basic call overload
|
|
35
|
-
const [runtime, input] = args;
|
|
36
|
-
return this.sendRequestsCallHelper(runtime, input);
|
|
37
|
-
}
|
|
38
|
-
sendRequestsCallHelper(runtime, input) {
|
|
18
|
+
sendRequest(runtime, input) {
|
|
39
19
|
// Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
|
|
40
20
|
let payload;
|
|
41
21
|
if (input.$typeName) {
|
|
@@ -44,15 +24,15 @@ export class ClientCapability {
|
|
|
44
24
|
}
|
|
45
25
|
else {
|
|
46
26
|
// It's regular JSON, convert using fromJson
|
|
47
|
-
payload = fromJson(
|
|
27
|
+
payload = fromJson(ConfidentialHTTPRequestSchema, input);
|
|
48
28
|
}
|
|
49
29
|
const capabilityId = ClientCapability.CAPABILITY_ID;
|
|
50
30
|
const capabilityResponse = runtime.callCapability({
|
|
51
31
|
capabilityId,
|
|
52
|
-
method: '
|
|
32
|
+
method: 'SendRequest',
|
|
53
33
|
payload,
|
|
54
|
-
inputSchema:
|
|
55
|
-
outputSchema:
|
|
34
|
+
inputSchema: ConfidentialHTTPRequestSchema,
|
|
35
|
+
outputSchema: HTTPResponseSchema,
|
|
56
36
|
});
|
|
57
37
|
return {
|
|
58
38
|
result: () => {
|
|
@@ -61,11 +41,4 @@ export class ClientCapability {
|
|
|
61
41
|
},
|
|
62
42
|
};
|
|
63
43
|
}
|
|
64
|
-
sendRequestsSugarHelper(runtime, fn, consensusAggregation, unwrapOptions) {
|
|
65
|
-
const wrappedFn = (runtime, ...args) => {
|
|
66
|
-
const sendRequestser = new SendRequestser(runtime, this);
|
|
67
|
-
return fn(sendRequestser, ...args);
|
|
68
|
-
};
|
|
69
|
-
return runtime.runInNodeMode(wrappedFn, consensusAggregation, unwrapOptions);
|
|
70
|
-
}
|
|
71
44
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { create, fromJson } from '@bufbuild/protobuf';
|
|
2
2
|
import { AnySchema, anyPack } from '@bufbuild/protobuf/wkt';
|
|
3
3
|
import { ConfigSchema, PayloadSchema, } from '../../../../../generated/capabilities/networking/http/v1alpha/trigger_pb';
|
|
4
|
-
import {} from '../../../../../sdk';
|
|
5
|
-
import { Report } from '../../../../../sdk/report';
|
|
6
|
-
import { hexToBytes } from '../../../../../sdk/utils/hex-utils';
|
|
7
4
|
import {} from '../../../../../sdk/utils/triggers/trigger-interface';
|
|
8
5
|
/**
|
|
9
6
|
* HTTP Capability
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { create, fromJson } from '@bufbuild/protobuf';
|
|
2
2
|
import { AnySchema, anyPack } from '@bufbuild/protobuf/wkt';
|
|
3
3
|
import { ConfigSchema, LegacyPayloadSchema, PayloadSchema, } from '../../../../../generated/capabilities/scheduler/cron/v1/trigger_pb';
|
|
4
|
-
import {} from '../../../../../sdk';
|
|
5
|
-
import { Report } from '../../../../../sdk/report';
|
|
6
|
-
import { hexToBytes } from '../../../../../sdk/utils/hex-utils';
|
|
7
4
|
import {} from '../../../../../sdk/utils/triggers/trigger-interface';
|
|
8
5
|
/**
|
|
9
6
|
* Cron Capability
|
package/dist/sdk/cre/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { type Log as EVMLog, TxStatus, } from '../../generated/capabilities/bloc
|
|
|
13
13
|
export type { Payload as HTTPPayload } from '../../generated/capabilities/networking/http/v1alpha/trigger_pb';
|
|
14
14
|
export type { Payload as CronPayload } from '../../generated/capabilities/scheduler/cron/v1/trigger_pb';
|
|
15
15
|
export { ClientCapability as EVMClient, type WriteCreReportRequest, type WriteCreReportRequestJson, } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
|
|
16
|
-
export { ClientCapability as ConfidentialHTTPClient
|
|
16
|
+
export { ClientCapability as ConfidentialHTTPClient } from '../../generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen';
|
|
17
17
|
export { ClientCapability as HTTPClient, type SendRequester as HTTPSendRequester, } from '../../generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen';
|
|
18
18
|
export { HTTPCapability } from '../../generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen';
|
|
19
19
|
export { CronCapability } from '../../generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen';
|
package/dist/sdk/cre/index.js
CHANGED
|
@@ -15,7 +15,7 @@ export { TxStatus, } from '../../generated/capabilities/blockchain/evm/v1alpha/c
|
|
|
15
15
|
// EVM Capability
|
|
16
16
|
export { ClientCapability as EVMClient, } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
|
|
17
17
|
// Confidential HTTP Capability
|
|
18
|
-
export { ClientCapability as ConfidentialHTTPClient
|
|
18
|
+
export { ClientCapability as ConfidentialHTTPClient } from '../../generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen';
|
|
19
19
|
// HTTP Capability
|
|
20
20
|
export { ClientCapability as HTTPClient, } from '../../generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen';
|
|
21
21
|
export { HTTPCapability } from '../../generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen';
|
package/dist/sdk/errors.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ export declare class NodeModeError extends Error {
|
|
|
7
7
|
}
|
|
8
8
|
export declare class SecretsError extends Error {
|
|
9
9
|
secretRequest: SecretRequest;
|
|
10
|
-
error:
|
|
11
|
-
constructor(secretRequest: SecretRequest, error:
|
|
10
|
+
error: string;
|
|
11
|
+
constructor(secretRequest: SecretRequest, error: string);
|
|
12
12
|
}
|
package/dist/sdk/errors.js
CHANGED
|
@@ -2,6 +2,7 @@ import { Mode } from '../generated/sdk/v1alpha/sdk_pb';
|
|
|
2
2
|
export class DonModeError extends Error {
|
|
3
3
|
constructor() {
|
|
4
4
|
super('cannot use Runtime inside RunInNodeMode');
|
|
5
|
+
this.name = 'DonModeError';
|
|
5
6
|
}
|
|
6
7
|
}
|
|
7
8
|
export class NodeModeError extends Error {
|
|
@@ -14,8 +15,9 @@ export class SecretsError extends Error {
|
|
|
14
15
|
secretRequest;
|
|
15
16
|
error;
|
|
16
17
|
constructor(secretRequest, error) {
|
|
17
|
-
super(`
|
|
18
|
+
super(`secret retrieval failed for ${secretRequest.id || 'unknown'} (namespace: ${secretRequest.namespace || 'default'}): ${error}. Verify the secret name is correct and that the secret has been configured for this workflow`);
|
|
18
19
|
this.secretRequest = secretRequest;
|
|
19
20
|
this.error = error;
|
|
21
|
+
this.name = 'SecretsError';
|
|
20
22
|
}
|
|
21
23
|
}
|
|
@@ -58,7 +58,7 @@ export class BaseRuntimeImpl {
|
|
|
58
58
|
if (!this.helpers.call(req)) {
|
|
59
59
|
return {
|
|
60
60
|
result: () => {
|
|
61
|
-
throw new CapabilityError(`Capability not found ${
|
|
61
|
+
throw new CapabilityError(`Capability '${capabilityId}' not found: the host rejected the call to method '${method}'. Verify the capability ID is correct and the capability is available in this CRE environment`, {
|
|
62
62
|
callbackId,
|
|
63
63
|
method,
|
|
64
64
|
capabilityId,
|
|
@@ -95,7 +95,7 @@ export class BaseRuntimeImpl {
|
|
|
95
95
|
const awaitResponse = this.helpers.await(awaitRequest, this.maxResponseSize);
|
|
96
96
|
const capabilityResponse = awaitResponse.responses[callbackId];
|
|
97
97
|
if (!capabilityResponse) {
|
|
98
|
-
throw new CapabilityError(`No response found for callback ID ${callbackId}`, {
|
|
98
|
+
throw new CapabilityError(`No response found for capability '${capabilityId}' method '${method}' (callback ID ${callbackId}): the host returned a response map that does not contain an entry for this call`, {
|
|
99
99
|
capabilityId,
|
|
100
100
|
method,
|
|
101
101
|
callbackId,
|
|
@@ -108,7 +108,7 @@ export class BaseRuntimeImpl {
|
|
|
108
108
|
return anyUnpack(response.value, outputSchema);
|
|
109
109
|
}
|
|
110
110
|
catch {
|
|
111
|
-
throw new CapabilityError(`
|
|
111
|
+
throw new CapabilityError(`Failed to deserialize response payload for capability '${capabilityId}' method '${method}': the response could not be unpacked into the expected output schema`, {
|
|
112
112
|
capabilityId,
|
|
113
113
|
method,
|
|
114
114
|
callbackId,
|
|
@@ -116,13 +116,13 @@ export class BaseRuntimeImpl {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
case 'error':
|
|
119
|
-
throw new CapabilityError(`
|
|
119
|
+
throw new CapabilityError(`Capability '${capabilityId}' method '${method}' returned an error: ${response.value}`, {
|
|
120
120
|
capabilityId,
|
|
121
121
|
method,
|
|
122
122
|
callbackId,
|
|
123
123
|
});
|
|
124
124
|
default:
|
|
125
|
-
throw new CapabilityError(`
|
|
125
|
+
throw new CapabilityError(`Unexpected response type '${response.case}' for capability '${capabilityId}' method '${method}': expected 'payload' or 'error'`, {
|
|
126
126
|
capabilityId,
|
|
127
127
|
method,
|
|
128
128
|
callbackId,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type BalanceAtReply, type BalanceAtReplyJson, type BalanceAtRequest, type CallContractReply, type CallContractReplyJson, type CallContractRequest, type EstimateGasReply, type EstimateGasReplyJson, type EstimateGasRequest, type FilterLogsReply, type FilterLogsReplyJson, type FilterLogsRequest, type GetTransactionByHashReply, type GetTransactionByHashReplyJson, type GetTransactionByHashRequest, type GetTransactionReceiptReply, type GetTransactionReceiptReplyJson, type GetTransactionReceiptRequest, type HeaderByNumberReply, type HeaderByNumberReplyJson, type HeaderByNumberRequest, type WriteReportReply, type WriteReportReplyJson, type WriteReportRequest } from '../../../../../../../generated/capabilities/blockchain/evm/v1alpha/client_pb';
|
|
2
|
+
/**
|
|
3
|
+
* Mock for ClientCapability. Use testInstance() to obtain an instance; do not construct directly.
|
|
4
|
+
* Set per-method properties (e.g. performAction) to define return values. If a method is invoked without a handler set, an error is thrown.
|
|
5
|
+
*/
|
|
6
|
+
export declare class EvmMock {
|
|
7
|
+
static readonly CAPABILITY_ID = "evm@1.0.0";
|
|
8
|
+
/** Set to define the return value for CallContract. May return a plain object (CallContractReplyJson) or the message type. */
|
|
9
|
+
callContract?: (input: CallContractRequest) => CallContractReply | CallContractReplyJson;
|
|
10
|
+
/** Set to define the return value for FilterLogs. May return a plain object (FilterLogsReplyJson) or the message type. */
|
|
11
|
+
filterLogs?: (input: FilterLogsRequest) => FilterLogsReply | FilterLogsReplyJson;
|
|
12
|
+
/** Set to define the return value for BalanceAt. May return a plain object (BalanceAtReplyJson) or the message type. */
|
|
13
|
+
balanceAt?: (input: BalanceAtRequest) => BalanceAtReply | BalanceAtReplyJson;
|
|
14
|
+
/** Set to define the return value for EstimateGas. May return a plain object (EstimateGasReplyJson) or the message type. */
|
|
15
|
+
estimateGas?: (input: EstimateGasRequest) => EstimateGasReply | EstimateGasReplyJson;
|
|
16
|
+
/** Set to define the return value for GetTransactionByHash. May return a plain object (GetTransactionByHashReplyJson) or the message type. */
|
|
17
|
+
getTransactionByHash?: (input: GetTransactionByHashRequest) => GetTransactionByHashReply | GetTransactionByHashReplyJson;
|
|
18
|
+
/** Set to define the return value for GetTransactionReceipt. May return a plain object (GetTransactionReceiptReplyJson) or the message type. */
|
|
19
|
+
getTransactionReceipt?: (input: GetTransactionReceiptRequest) => GetTransactionReceiptReply | GetTransactionReceiptReplyJson;
|
|
20
|
+
/** Set to define the return value for HeaderByNumber. May return a plain object (HeaderByNumberReplyJson) or the message type. */
|
|
21
|
+
headerByNumber?: (input: HeaderByNumberRequest) => HeaderByNumberReply | HeaderByNumberReplyJson;
|
|
22
|
+
/** Set to define the return value for WriteReport. May return a plain object (WriteReportReplyJson) or the message type. */
|
|
23
|
+
writeReport?: (input: WriteReportRequest) => WriteReportReply | WriteReportReplyJson;
|
|
24
|
+
private constructor();
|
|
25
|
+
/**
|
|
26
|
+
* Returns the mock instance for this capability and the specified tags.
|
|
27
|
+
* Multiple calls with the same tag values return the same instance.
|
|
28
|
+
* Must be called within the test framework's test() method.
|
|
29
|
+
*/
|
|
30
|
+
static testInstance(chainSelector: bigint): EvmMock;
|
|
31
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { fromJson } from '@bufbuild/protobuf';
|
|
2
|
+
import { anyPack, anyUnpack } from '@bufbuild/protobuf/wkt';
|
|
3
|
+
import { BalanceAtReplySchema, BalanceAtRequestSchema, CallContractReplySchema, CallContractRequestSchema, EstimateGasReplySchema, EstimateGasRequestSchema, FilterLogsReplySchema, FilterLogsRequestSchema, GetTransactionByHashReplySchema, GetTransactionByHashRequestSchema, GetTransactionReceiptReplySchema, GetTransactionReceiptRequestSchema, HeaderByNumberReplySchema, HeaderByNumberRequestSchema, WriteReportReplySchema, WriteReportRequestSchema, } from '../../../../../../../generated/capabilities/blockchain/evm/v1alpha/client_pb';
|
|
4
|
+
import { __getTestMockInstance, __setTestMockInstance, registerTestCapability, } from '../../../../../../testutils/test-runtime';
|
|
5
|
+
/**
|
|
6
|
+
* Mock for ClientCapability. Use testInstance() to obtain an instance; do not construct directly.
|
|
7
|
+
* Set per-method properties (e.g. performAction) to define return values. If a method is invoked without a handler set, an error is thrown.
|
|
8
|
+
*/
|
|
9
|
+
export class EvmMock {
|
|
10
|
+
static CAPABILITY_ID = 'evm@1.0.0';
|
|
11
|
+
/** Set to define the return value for CallContract. May return a plain object (CallContractReplyJson) or the message type. */
|
|
12
|
+
callContract;
|
|
13
|
+
/** Set to define the return value for FilterLogs. May return a plain object (FilterLogsReplyJson) or the message type. */
|
|
14
|
+
filterLogs;
|
|
15
|
+
/** Set to define the return value for BalanceAt. May return a plain object (BalanceAtReplyJson) or the message type. */
|
|
16
|
+
balanceAt;
|
|
17
|
+
/** Set to define the return value for EstimateGas. May return a plain object (EstimateGasReplyJson) or the message type. */
|
|
18
|
+
estimateGas;
|
|
19
|
+
/** Set to define the return value for GetTransactionByHash. May return a plain object (GetTransactionByHashReplyJson) or the message type. */
|
|
20
|
+
getTransactionByHash;
|
|
21
|
+
/** Set to define the return value for GetTransactionReceipt. May return a plain object (GetTransactionReceiptReplyJson) or the message type. */
|
|
22
|
+
getTransactionReceipt;
|
|
23
|
+
/** Set to define the return value for HeaderByNumber. May return a plain object (HeaderByNumberReplyJson) or the message type. */
|
|
24
|
+
headerByNumber;
|
|
25
|
+
/** Set to define the return value for WriteReport. May return a plain object (WriteReportReplyJson) or the message type. */
|
|
26
|
+
writeReport;
|
|
27
|
+
constructor(chainSelector) {
|
|
28
|
+
const self = this;
|
|
29
|
+
const qualifiedId = `evm:ChainSelector:${chainSelector}@1.0.0`;
|
|
30
|
+
try {
|
|
31
|
+
registerTestCapability(qualifiedId, (req) => {
|
|
32
|
+
switch (req.method) {
|
|
33
|
+
case 'CallContract': {
|
|
34
|
+
const input = anyUnpack(req.payload, CallContractRequestSchema);
|
|
35
|
+
const handler = self.callContract;
|
|
36
|
+
if (typeof handler !== 'function')
|
|
37
|
+
throw new Error("CallContract: no implementation provided; set the mock's callContract property to define the return value.");
|
|
38
|
+
const raw = handler(input);
|
|
39
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
40
|
+
? raw
|
|
41
|
+
: fromJson(CallContractReplySchema, raw);
|
|
42
|
+
return {
|
|
43
|
+
response: { case: 'payload', value: anyPack(CallContractReplySchema, output) },
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
case 'FilterLogs': {
|
|
47
|
+
const input = anyUnpack(req.payload, FilterLogsRequestSchema);
|
|
48
|
+
const handler = self.filterLogs;
|
|
49
|
+
if (typeof handler !== 'function')
|
|
50
|
+
throw new Error("FilterLogs: no implementation provided; set the mock's filterLogs property to define the return value.");
|
|
51
|
+
const raw = handler(input);
|
|
52
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
53
|
+
? raw
|
|
54
|
+
: fromJson(FilterLogsReplySchema, raw);
|
|
55
|
+
return { response: { case: 'payload', value: anyPack(FilterLogsReplySchema, output) } };
|
|
56
|
+
}
|
|
57
|
+
case 'BalanceAt': {
|
|
58
|
+
const input = anyUnpack(req.payload, BalanceAtRequestSchema);
|
|
59
|
+
const handler = self.balanceAt;
|
|
60
|
+
if (typeof handler !== 'function')
|
|
61
|
+
throw new Error("BalanceAt: no implementation provided; set the mock's balanceAt property to define the return value.");
|
|
62
|
+
const raw = handler(input);
|
|
63
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
64
|
+
? raw
|
|
65
|
+
: fromJson(BalanceAtReplySchema, raw);
|
|
66
|
+
return { response: { case: 'payload', value: anyPack(BalanceAtReplySchema, output) } };
|
|
67
|
+
}
|
|
68
|
+
case 'EstimateGas': {
|
|
69
|
+
const input = anyUnpack(req.payload, EstimateGasRequestSchema);
|
|
70
|
+
const handler = self.estimateGas;
|
|
71
|
+
if (typeof handler !== 'function')
|
|
72
|
+
throw new Error("EstimateGas: no implementation provided; set the mock's estimateGas property to define the return value.");
|
|
73
|
+
const raw = handler(input);
|
|
74
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
75
|
+
? raw
|
|
76
|
+
: fromJson(EstimateGasReplySchema, raw);
|
|
77
|
+
return { response: { case: 'payload', value: anyPack(EstimateGasReplySchema, output) } };
|
|
78
|
+
}
|
|
79
|
+
case 'GetTransactionByHash': {
|
|
80
|
+
const input = anyUnpack(req.payload, GetTransactionByHashRequestSchema);
|
|
81
|
+
const handler = self.getTransactionByHash;
|
|
82
|
+
if (typeof handler !== 'function')
|
|
83
|
+
throw new Error("GetTransactionByHash: no implementation provided; set the mock's getTransactionByHash property to define the return value.");
|
|
84
|
+
const raw = handler(input);
|
|
85
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
86
|
+
? raw
|
|
87
|
+
: fromJson(GetTransactionByHashReplySchema, raw);
|
|
88
|
+
return {
|
|
89
|
+
response: {
|
|
90
|
+
case: 'payload',
|
|
91
|
+
value: anyPack(GetTransactionByHashReplySchema, output),
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
case 'GetTransactionReceipt': {
|
|
96
|
+
const input = anyUnpack(req.payload, GetTransactionReceiptRequestSchema);
|
|
97
|
+
const handler = self.getTransactionReceipt;
|
|
98
|
+
if (typeof handler !== 'function')
|
|
99
|
+
throw new Error("GetTransactionReceipt: no implementation provided; set the mock's getTransactionReceipt property to define the return value.");
|
|
100
|
+
const raw = handler(input);
|
|
101
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
102
|
+
? raw
|
|
103
|
+
: fromJson(GetTransactionReceiptReplySchema, raw);
|
|
104
|
+
return {
|
|
105
|
+
response: {
|
|
106
|
+
case: 'payload',
|
|
107
|
+
value: anyPack(GetTransactionReceiptReplySchema, output),
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
case 'HeaderByNumber': {
|
|
112
|
+
const input = anyUnpack(req.payload, HeaderByNumberRequestSchema);
|
|
113
|
+
const handler = self.headerByNumber;
|
|
114
|
+
if (typeof handler !== 'function')
|
|
115
|
+
throw new Error("HeaderByNumber: no implementation provided; set the mock's headerByNumber property to define the return value.");
|
|
116
|
+
const raw = handler(input);
|
|
117
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
118
|
+
? raw
|
|
119
|
+
: fromJson(HeaderByNumberReplySchema, raw);
|
|
120
|
+
return {
|
|
121
|
+
response: { case: 'payload', value: anyPack(HeaderByNumberReplySchema, output) },
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
case 'WriteReport': {
|
|
125
|
+
const input = anyUnpack(req.payload, WriteReportRequestSchema);
|
|
126
|
+
const handler = self.writeReport;
|
|
127
|
+
if (typeof handler !== 'function')
|
|
128
|
+
throw new Error("WriteReport: no implementation provided; set the mock's writeReport property to define the return value.");
|
|
129
|
+
const raw = handler(input);
|
|
130
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
131
|
+
? raw
|
|
132
|
+
: fromJson(WriteReportReplySchema, raw);
|
|
133
|
+
return { response: { case: 'payload', value: anyPack(WriteReportReplySchema, output) } };
|
|
134
|
+
}
|
|
135
|
+
default:
|
|
136
|
+
return { response: { case: 'error', value: `unknown method ${req.method}` } };
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
throw new Error("Capability mocks must be used within the CRE test framework's test() method.");
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Returns the mock instance for this capability and the specified tags.
|
|
146
|
+
* Multiple calls with the same tag values return the same instance.
|
|
147
|
+
* Must be called within the test framework's test() method.
|
|
148
|
+
*/
|
|
149
|
+
static testInstance(chainSelector) {
|
|
150
|
+
const qualifiedId = `evm:ChainSelector:${chainSelector}@1.0.0`;
|
|
151
|
+
let instance = __getTestMockInstance(qualifiedId);
|
|
152
|
+
if (!instance) {
|
|
153
|
+
instance = new EvmMock(chainSelector);
|
|
154
|
+
__setTestMockInstance(qualifiedId, instance);
|
|
155
|
+
}
|
|
156
|
+
return instance;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Input, type Output, type OutputJson } from '../../../../../../../generated/capabilities/internal/actionandtrigger/v1/action_and_trigger_pb';
|
|
2
|
+
/**
|
|
3
|
+
* Mock for BasicCapability. Use testInstance() to obtain an instance; do not construct directly.
|
|
4
|
+
* Set per-method properties (e.g. performAction) to define return values. If a method is invoked without a handler set, an error is thrown.
|
|
5
|
+
*/
|
|
6
|
+
export declare class BasicTestActionTriggerMock {
|
|
7
|
+
static readonly CAPABILITY_ID = "basic-test-action-trigger@1.0.0";
|
|
8
|
+
/** Set to define the return value for Action. May return a plain object (OutputJson) or the message type. */
|
|
9
|
+
action?: (input: Input) => Output | OutputJson;
|
|
10
|
+
private constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Returns the mock instance for this capability.
|
|
13
|
+
* Multiple calls with the same arguments return the same instance.
|
|
14
|
+
* Must be called within the test framework's test() method.
|
|
15
|
+
*/
|
|
16
|
+
static testInstance(): BasicTestActionTriggerMock;
|
|
17
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { fromJson } from '@bufbuild/protobuf';
|
|
2
|
+
import { anyPack, anyUnpack } from '@bufbuild/protobuf/wkt';
|
|
3
|
+
import { InputSchema, OutputSchema, } from '../../../../../../../generated/capabilities/internal/actionandtrigger/v1/action_and_trigger_pb';
|
|
4
|
+
import { __getTestMockInstance, __setTestMockInstance, registerTestCapability, } from '../../../../../../testutils/test-runtime';
|
|
5
|
+
/**
|
|
6
|
+
* Mock for BasicCapability. Use testInstance() to obtain an instance; do not construct directly.
|
|
7
|
+
* Set per-method properties (e.g. performAction) to define return values. If a method is invoked without a handler set, an error is thrown.
|
|
8
|
+
*/
|
|
9
|
+
export class BasicTestActionTriggerMock {
|
|
10
|
+
static CAPABILITY_ID = 'basic-test-action-trigger@1.0.0';
|
|
11
|
+
/** Set to define the return value for Action. May return a plain object (OutputJson) or the message type. */
|
|
12
|
+
action;
|
|
13
|
+
constructor() {
|
|
14
|
+
const self = this;
|
|
15
|
+
const qualifiedId = BasicTestActionTriggerMock.CAPABILITY_ID;
|
|
16
|
+
try {
|
|
17
|
+
registerTestCapability(qualifiedId, (req) => {
|
|
18
|
+
switch (req.method) {
|
|
19
|
+
case 'Action': {
|
|
20
|
+
const input = anyUnpack(req.payload, InputSchema);
|
|
21
|
+
const handler = self.action;
|
|
22
|
+
if (typeof handler !== 'function')
|
|
23
|
+
throw new Error("Action: no implementation provided; set the mock's action property to define the return value.");
|
|
24
|
+
const raw = handler(input);
|
|
25
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
26
|
+
? raw
|
|
27
|
+
: fromJson(OutputSchema, raw);
|
|
28
|
+
return { response: { case: 'payload', value: anyPack(OutputSchema, output) } };
|
|
29
|
+
}
|
|
30
|
+
default:
|
|
31
|
+
return { response: { case: 'error', value: `unknown method ${req.method}` } };
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
throw new Error("Capability mocks must be used within the CRE test framework's test() method.");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Returns the mock instance for this capability.
|
|
41
|
+
* Multiple calls with the same arguments return the same instance.
|
|
42
|
+
* Must be called within the test framework's test() method.
|
|
43
|
+
*/
|
|
44
|
+
static testInstance() {
|
|
45
|
+
const qualifiedId = BasicTestActionTriggerMock.CAPABILITY_ID;
|
|
46
|
+
let instance = __getTestMockInstance(qualifiedId);
|
|
47
|
+
if (!instance) {
|
|
48
|
+
instance = new BasicTestActionTriggerMock();
|
|
49
|
+
__setTestMockInstance(qualifiedId, instance);
|
|
50
|
+
}
|
|
51
|
+
return instance;
|
|
52
|
+
}
|
|
53
|
+
}
|
package/dist/sdk/test/generated/capabilities/internal/basicaction/v1/basic_test_action_mock_gen.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Inputs, type Outputs, type OutputsJson } from '../../../../../../../generated/capabilities/internal/basicaction/v1/basic_action_pb';
|
|
2
|
+
/**
|
|
3
|
+
* Mock for BasicActionCapability. Use testInstance() to obtain an instance; do not construct directly.
|
|
4
|
+
* Set per-method properties (e.g. performAction) to define return values. If a method is invoked without a handler set, an error is thrown.
|
|
5
|
+
*/
|
|
6
|
+
export declare class BasicTestActionMock {
|
|
7
|
+
static readonly CAPABILITY_ID = "basic-test-action@1.0.0";
|
|
8
|
+
/** Set to define the return value for PerformAction. May return a plain object (OutputsJson) or the message type. */
|
|
9
|
+
performAction?: (input: Inputs) => Outputs | OutputsJson;
|
|
10
|
+
private constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Returns the mock instance for this capability.
|
|
13
|
+
* Multiple calls with the same arguments return the same instance.
|
|
14
|
+
* Must be called within the test framework's test() method.
|
|
15
|
+
*/
|
|
16
|
+
static testInstance(): BasicTestActionMock;
|
|
17
|
+
}
|
package/dist/sdk/test/generated/capabilities/internal/basicaction/v1/basic_test_action_mock_gen.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { fromJson } from '@bufbuild/protobuf';
|
|
2
|
+
import { anyPack, anyUnpack } from '@bufbuild/protobuf/wkt';
|
|
3
|
+
import { InputsSchema, OutputsSchema, } from '../../../../../../../generated/capabilities/internal/basicaction/v1/basic_action_pb';
|
|
4
|
+
import { __getTestMockInstance, __setTestMockInstance, registerTestCapability, } from '../../../../../../testutils/test-runtime';
|
|
5
|
+
/**
|
|
6
|
+
* Mock for BasicActionCapability. Use testInstance() to obtain an instance; do not construct directly.
|
|
7
|
+
* Set per-method properties (e.g. performAction) to define return values. If a method is invoked without a handler set, an error is thrown.
|
|
8
|
+
*/
|
|
9
|
+
export class BasicTestActionMock {
|
|
10
|
+
static CAPABILITY_ID = 'basic-test-action@1.0.0';
|
|
11
|
+
/** Set to define the return value for PerformAction. May return a plain object (OutputsJson) or the message type. */
|
|
12
|
+
performAction;
|
|
13
|
+
constructor() {
|
|
14
|
+
const self = this;
|
|
15
|
+
const qualifiedId = BasicTestActionMock.CAPABILITY_ID;
|
|
16
|
+
try {
|
|
17
|
+
registerTestCapability(qualifiedId, (req) => {
|
|
18
|
+
switch (req.method) {
|
|
19
|
+
case 'PerformAction': {
|
|
20
|
+
const input = anyUnpack(req.payload, InputsSchema);
|
|
21
|
+
const handler = self.performAction;
|
|
22
|
+
if (typeof handler !== 'function')
|
|
23
|
+
throw new Error("PerformAction: no implementation provided; set the mock's performAction property to define the return value.");
|
|
24
|
+
const raw = handler(input);
|
|
25
|
+
const output = raw && typeof raw.$typeName === 'string'
|
|
26
|
+
? raw
|
|
27
|
+
: fromJson(OutputsSchema, raw);
|
|
28
|
+
return { response: { case: 'payload', value: anyPack(OutputsSchema, output) } };
|
|
29
|
+
}
|
|
30
|
+
default:
|
|
31
|
+
return { response: { case: 'error', value: `unknown method ${req.method}` } };
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
throw new Error("Capability mocks must be used within the CRE test framework's test() method.");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Returns the mock instance for this capability.
|
|
41
|
+
* Multiple calls with the same arguments return the same instance.
|
|
42
|
+
* Must be called within the test framework's test() method.
|
|
43
|
+
*/
|
|
44
|
+
static testInstance() {
|
|
45
|
+
const qualifiedId = BasicTestActionMock.CAPABILITY_ID;
|
|
46
|
+
let instance = __getTestMockInstance(qualifiedId);
|
|
47
|
+
if (!instance) {
|
|
48
|
+
instance = new BasicTestActionMock();
|
|
49
|
+
__setTestMockInstance(qualifiedId, instance);
|
|
50
|
+
}
|
|
51
|
+
return instance;
|
|
52
|
+
}
|
|
53
|
+
}
|
package/dist/sdk/test/generated/capabilities/internal/consensus/v1alpha/consensus_mock_gen.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ReportRequest, type ReportResponse, type ReportResponseJson, type SimpleConsensusInputs } from '../../../../../../../generated/sdk/v1alpha/sdk_pb';
|
|
2
|
+
import { type Value, type ValueJson } from '../../../../../../../generated/values/v1/values_pb';
|
|
3
|
+
/**
|
|
4
|
+
* Mock for ConsensusCapability. Use testInstance() to obtain an instance; do not construct directly.
|
|
5
|
+
* Set per-method properties (e.g. performAction) to define return values. If a method is invoked without a handler set, an error is thrown.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ConsensusMock {
|
|
8
|
+
static readonly CAPABILITY_ID = "consensus@1.0.0-alpha";
|
|
9
|
+
/** Set to define the return value for Simple. May return a plain object (ValueJson) or the message type. */
|
|
10
|
+
simple?: (input: SimpleConsensusInputs) => Value | ValueJson;
|
|
11
|
+
/** Set to define the return value for Report. May return a plain object (ReportResponseJson) or the message type. */
|
|
12
|
+
report?: (input: ReportRequest) => ReportResponse | ReportResponseJson;
|
|
13
|
+
private constructor();
|
|
14
|
+
/**
|
|
15
|
+
* Returns the mock instance for this capability.
|
|
16
|
+
* Multiple calls with the same arguments return the same instance.
|
|
17
|
+
* Must be called within the test framework's test() method.
|
|
18
|
+
*/
|
|
19
|
+
static testInstance(): ConsensusMock;
|
|
20
|
+
}
|