@chainlink/cre-sdk 1.6.0-alpha.3 → 1.6.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 +9 -0
- package/bin/cre-compile.ts +17 -5
- package/dist/sdk/cre/index.d.ts +0 -6
- package/dist/sdk/cre/index.js +0 -8
- package/dist/sdk/test/generated/index.d.ts +0 -2
- package/dist/sdk/test/generated/index.js +0 -2
- package/package.json +2 -2
- package/scripts/run-standard-tests.sh +3 -3
- package/scripts/src/compile-to-wasm.ts +39 -19
- package/scripts/src/compile-workflow.ts +31 -12
- package/scripts/src/generate-sdks.ts +0 -12
- package/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.d.ts +0 -1023
- package/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.js +0 -290
- package/dist/generated/capabilities/blockchain/solana/v1alpha/client_pb.d.ts +0 -2904
- package/dist/generated/capabilities/blockchain/solana/v1alpha/client_pb.js +0 -506
- package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.d.ts +0 -52
- package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.js +0 -186
- package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.d.ts +0 -92
- package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.js +0 -343
- package/dist/sdk/test/generated/capabilities/blockchain/aptos/v1alpha/aptos_mock_gen.d.ts +0 -25
- package/dist/sdk/test/generated/capabilities/blockchain/aptos/v1alpha/aptos_mock_gen.js +0 -111
- package/dist/sdk/test/generated/capabilities/blockchain/solana/v1alpha/solana_mock_gen.d.ts +0 -33
- package/dist/sdk/test/generated/capabilities/blockchain/solana/v1alpha/solana_mock_gen.js +0 -178
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { fromJson } from '@bufbuild/protobuf';
|
|
2
|
-
import { anyPack, anyUnpack } from '@bufbuild/protobuf/wkt';
|
|
3
|
-
import { AccountAPTBalanceReplySchema, AccountAPTBalanceRequestSchema, AccountTransactionsReplySchema, AccountTransactionsRequestSchema, TransactionByHashReplySchema, TransactionByHashRequestSchema, ViewReplySchema, ViewRequestSchema, WriteReportReplySchema, WriteReportRequestSchema, } from '../../../../../../../generated/capabilities/blockchain/aptos/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 AptosMock {
|
|
10
|
-
static CAPABILITY_ID = 'aptos@1.0.0';
|
|
11
|
-
/** Set to define the return value for AccountAPTBalance. May return a plain object (AccountAPTBalanceReplyJson) or the message type. */
|
|
12
|
-
accountAPTBalance;
|
|
13
|
-
/** Set to define the return value for View. May return a plain object (ViewReplyJson) or the message type. */
|
|
14
|
-
view;
|
|
15
|
-
/** Set to define the return value for TransactionByHash. May return a plain object (TransactionByHashReplyJson) or the message type. */
|
|
16
|
-
transactionByHash;
|
|
17
|
-
/** Set to define the return value for AccountTransactions. May return a plain object (AccountTransactionsReplyJson) or the message type. */
|
|
18
|
-
accountTransactions;
|
|
19
|
-
/** Set to define the return value for WriteReport. May return a plain object (WriteReportReplyJson) or the message type. */
|
|
20
|
-
writeReport;
|
|
21
|
-
constructor(chainSelector) {
|
|
22
|
-
const self = this;
|
|
23
|
-
const qualifiedId = `aptos:ChainSelector:${chainSelector}@1.0.0`;
|
|
24
|
-
try {
|
|
25
|
-
registerTestCapability(qualifiedId, (req) => {
|
|
26
|
-
switch (req.method) {
|
|
27
|
-
case 'AccountAPTBalance': {
|
|
28
|
-
const input = anyUnpack(req.payload, AccountAPTBalanceRequestSchema);
|
|
29
|
-
const handler = self.accountAPTBalance;
|
|
30
|
-
if (typeof handler !== 'function')
|
|
31
|
-
throw new Error("AccountAPTBalance: no implementation provided; set the mock's accountAPTBalance property to define the return value.");
|
|
32
|
-
const raw = handler(input);
|
|
33
|
-
const output = raw && typeof raw.$typeName === 'string'
|
|
34
|
-
? raw
|
|
35
|
-
: fromJson(AccountAPTBalanceReplySchema, raw);
|
|
36
|
-
return {
|
|
37
|
-
response: { case: 'payload', value: anyPack(AccountAPTBalanceReplySchema, output) },
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
case 'View': {
|
|
41
|
-
const input = anyUnpack(req.payload, ViewRequestSchema);
|
|
42
|
-
const handler = self.view;
|
|
43
|
-
if (typeof handler !== 'function')
|
|
44
|
-
throw new Error("View: no implementation provided; set the mock's view property to define the return value.");
|
|
45
|
-
const raw = handler(input);
|
|
46
|
-
const output = raw && typeof raw.$typeName === 'string'
|
|
47
|
-
? raw
|
|
48
|
-
: fromJson(ViewReplySchema, raw);
|
|
49
|
-
return { response: { case: 'payload', value: anyPack(ViewReplySchema, output) } };
|
|
50
|
-
}
|
|
51
|
-
case 'TransactionByHash': {
|
|
52
|
-
const input = anyUnpack(req.payload, TransactionByHashRequestSchema);
|
|
53
|
-
const handler = self.transactionByHash;
|
|
54
|
-
if (typeof handler !== 'function')
|
|
55
|
-
throw new Error("TransactionByHash: no implementation provided; set the mock's transactionByHash property to define the return value.");
|
|
56
|
-
const raw = handler(input);
|
|
57
|
-
const output = raw && typeof raw.$typeName === 'string'
|
|
58
|
-
? raw
|
|
59
|
-
: fromJson(TransactionByHashReplySchema, raw);
|
|
60
|
-
return {
|
|
61
|
-
response: { case: 'payload', value: anyPack(TransactionByHashReplySchema, output) },
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
case 'AccountTransactions': {
|
|
65
|
-
const input = anyUnpack(req.payload, AccountTransactionsRequestSchema);
|
|
66
|
-
const handler = self.accountTransactions;
|
|
67
|
-
if (typeof handler !== 'function')
|
|
68
|
-
throw new Error("AccountTransactions: no implementation provided; set the mock's accountTransactions property to define the return value.");
|
|
69
|
-
const raw = handler(input);
|
|
70
|
-
const output = raw && typeof raw.$typeName === 'string'
|
|
71
|
-
? raw
|
|
72
|
-
: fromJson(AccountTransactionsReplySchema, raw);
|
|
73
|
-
return {
|
|
74
|
-
response: { case: 'payload', value: anyPack(AccountTransactionsReplySchema, output) },
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
case 'WriteReport': {
|
|
78
|
-
const input = anyUnpack(req.payload, WriteReportRequestSchema);
|
|
79
|
-
const handler = self.writeReport;
|
|
80
|
-
if (typeof handler !== 'function')
|
|
81
|
-
throw new Error("WriteReport: no implementation provided; set the mock's writeReport property to define the return value.");
|
|
82
|
-
const raw = handler(input);
|
|
83
|
-
const output = raw && typeof raw.$typeName === 'string'
|
|
84
|
-
? raw
|
|
85
|
-
: fromJson(WriteReportReplySchema, raw);
|
|
86
|
-
return { response: { case: 'payload', value: anyPack(WriteReportReplySchema, output) } };
|
|
87
|
-
}
|
|
88
|
-
default:
|
|
89
|
-
return { response: { case: 'error', value: `unknown method ${req.method}` } };
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
catch {
|
|
94
|
-
throw new Error("Capability mocks must be used within the CRE test framework's test() method.");
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Returns the mock instance for this capability and the specified tags.
|
|
99
|
-
* Multiple calls with the same tag values return the same instance.
|
|
100
|
-
* Must be called within the test framework's test() method.
|
|
101
|
-
*/
|
|
102
|
-
static testInstance(chainSelector) {
|
|
103
|
-
const qualifiedId = `aptos:ChainSelector:${chainSelector}@1.0.0`;
|
|
104
|
-
let instance = __getTestMockInstance(qualifiedId);
|
|
105
|
-
if (!instance) {
|
|
106
|
-
instance = new AptosMock(chainSelector);
|
|
107
|
-
__setTestMockInstance(qualifiedId, instance);
|
|
108
|
-
}
|
|
109
|
-
return instance;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { type GetAccountInfoWithOptsReply, type GetAccountInfoWithOptsReplyJson, type GetAccountInfoWithOptsRequest, type GetBalanceReply, type GetBalanceReplyJson, type GetBalanceRequest, type GetBlockReply, type GetBlockReplyJson, type GetBlockRequest, type GetFeeForMessageReply, type GetFeeForMessageReplyJson, type GetFeeForMessageRequest, type GetMultipleAccountsWithOptsReply, type GetMultipleAccountsWithOptsReplyJson, type GetMultipleAccountsWithOptsRequest, type GetSignatureStatusesReply, type GetSignatureStatusesReplyJson, type GetSignatureStatusesRequest, type GetSlotHeightReply, type GetSlotHeightReplyJson, type GetSlotHeightRequest, type GetTransactionReply, type GetTransactionReplyJson, type GetTransactionRequest, type WriteReportReply, type WriteReportReplyJson, type WriteReportRequest } from '../../../../../../../generated/capabilities/blockchain/solana/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 SolanaMock {
|
|
7
|
-
static readonly CAPABILITY_ID = "solana@1.0.0";
|
|
8
|
-
/** Set to define the return value for GetAccountInfoWithOpts. May return a plain object (GetAccountInfoWithOptsReplyJson) or the message type. */
|
|
9
|
-
getAccountInfoWithOpts?: (input: GetAccountInfoWithOptsRequest) => GetAccountInfoWithOptsReply | GetAccountInfoWithOptsReplyJson;
|
|
10
|
-
/** Set to define the return value for GetBalance. May return a plain object (GetBalanceReplyJson) or the message type. */
|
|
11
|
-
getBalance?: (input: GetBalanceRequest) => GetBalanceReply | GetBalanceReplyJson;
|
|
12
|
-
/** Set to define the return value for GetBlock. May return a plain object (GetBlockReplyJson) or the message type. */
|
|
13
|
-
getBlock?: (input: GetBlockRequest) => GetBlockReply | GetBlockReplyJson;
|
|
14
|
-
/** Set to define the return value for GetFeeForMessage. May return a plain object (GetFeeForMessageReplyJson) or the message type. */
|
|
15
|
-
getFeeForMessage?: (input: GetFeeForMessageRequest) => GetFeeForMessageReply | GetFeeForMessageReplyJson;
|
|
16
|
-
/** Set to define the return value for GetMultipleAccountsWithOpts. May return a plain object (GetMultipleAccountsWithOptsReplyJson) or the message type. */
|
|
17
|
-
getMultipleAccountsWithOpts?: (input: GetMultipleAccountsWithOptsRequest) => GetMultipleAccountsWithOptsReply | GetMultipleAccountsWithOptsReplyJson;
|
|
18
|
-
/** Set to define the return value for GetSignatureStatuses. May return a plain object (GetSignatureStatusesReplyJson) or the message type. */
|
|
19
|
-
getSignatureStatuses?: (input: GetSignatureStatusesRequest) => GetSignatureStatusesReply | GetSignatureStatusesReplyJson;
|
|
20
|
-
/** Set to define the return value for GetSlotHeight. May return a plain object (GetSlotHeightReplyJson) or the message type. */
|
|
21
|
-
getSlotHeight?: (input: GetSlotHeightRequest) => GetSlotHeightReply | GetSlotHeightReplyJson;
|
|
22
|
-
/** Set to define the return value for GetTransaction. May return a plain object (GetTransactionReplyJson) or the message type. */
|
|
23
|
-
getTransaction?: (input: GetTransactionRequest) => GetTransactionReply | GetTransactionReplyJson;
|
|
24
|
-
/** Set to define the return value for WriteReport. May return a plain object (WriteReportReplyJson) or the message type. */
|
|
25
|
-
writeReport?: (input: WriteReportRequest) => WriteReportReply | WriteReportReplyJson;
|
|
26
|
-
private constructor();
|
|
27
|
-
/**
|
|
28
|
-
* Returns the mock instance for this capability and the specified tags.
|
|
29
|
-
* Multiple calls with the same tag values return the same instance.
|
|
30
|
-
* Must be called within the test framework's test() method.
|
|
31
|
-
*/
|
|
32
|
-
static testInstance(chainSelector: bigint): SolanaMock;
|
|
33
|
-
}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { fromJson } from '@bufbuild/protobuf';
|
|
2
|
-
import { anyPack, anyUnpack } from '@bufbuild/protobuf/wkt';
|
|
3
|
-
import { GetAccountInfoWithOptsReplySchema, GetAccountInfoWithOptsRequestSchema, GetBalanceReplySchema, GetBalanceRequestSchema, GetBlockReplySchema, GetBlockRequestSchema, GetFeeForMessageReplySchema, GetFeeForMessageRequestSchema, GetMultipleAccountsWithOptsReplySchema, GetMultipleAccountsWithOptsRequestSchema, GetSignatureStatusesReplySchema, GetSignatureStatusesRequestSchema, GetSlotHeightReplySchema, GetSlotHeightRequestSchema, GetTransactionReplySchema, GetTransactionRequestSchema, WriteReportReplySchema, WriteReportRequestSchema, } from '../../../../../../../generated/capabilities/blockchain/solana/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 SolanaMock {
|
|
10
|
-
static CAPABILITY_ID = 'solana@1.0.0';
|
|
11
|
-
/** Set to define the return value for GetAccountInfoWithOpts. May return a plain object (GetAccountInfoWithOptsReplyJson) or the message type. */
|
|
12
|
-
getAccountInfoWithOpts;
|
|
13
|
-
/** Set to define the return value for GetBalance. May return a plain object (GetBalanceReplyJson) or the message type. */
|
|
14
|
-
getBalance;
|
|
15
|
-
/** Set to define the return value for GetBlock. May return a plain object (GetBlockReplyJson) or the message type. */
|
|
16
|
-
getBlock;
|
|
17
|
-
/** Set to define the return value for GetFeeForMessage. May return a plain object (GetFeeForMessageReplyJson) or the message type. */
|
|
18
|
-
getFeeForMessage;
|
|
19
|
-
/** Set to define the return value for GetMultipleAccountsWithOpts. May return a plain object (GetMultipleAccountsWithOptsReplyJson) or the message type. */
|
|
20
|
-
getMultipleAccountsWithOpts;
|
|
21
|
-
/** Set to define the return value for GetSignatureStatuses. May return a plain object (GetSignatureStatusesReplyJson) or the message type. */
|
|
22
|
-
getSignatureStatuses;
|
|
23
|
-
/** Set to define the return value for GetSlotHeight. May return a plain object (GetSlotHeightReplyJson) or the message type. */
|
|
24
|
-
getSlotHeight;
|
|
25
|
-
/** Set to define the return value for GetTransaction. May return a plain object (GetTransactionReplyJson) or the message type. */
|
|
26
|
-
getTransaction;
|
|
27
|
-
/** Set to define the return value for WriteReport. May return a plain object (WriteReportReplyJson) or the message type. */
|
|
28
|
-
writeReport;
|
|
29
|
-
constructor(chainSelector) {
|
|
30
|
-
const self = this;
|
|
31
|
-
const qualifiedId = `solana:ChainSelector:${chainSelector}@1.0.0`;
|
|
32
|
-
try {
|
|
33
|
-
registerTestCapability(qualifiedId, (req) => {
|
|
34
|
-
switch (req.method) {
|
|
35
|
-
case 'GetAccountInfoWithOpts': {
|
|
36
|
-
const input = anyUnpack(req.payload, GetAccountInfoWithOptsRequestSchema);
|
|
37
|
-
const handler = self.getAccountInfoWithOpts;
|
|
38
|
-
if (typeof handler !== 'function')
|
|
39
|
-
throw new Error("GetAccountInfoWithOpts: no implementation provided; set the mock's getAccountInfoWithOpts property to define the return value.");
|
|
40
|
-
const raw = handler(input);
|
|
41
|
-
const output = raw && typeof raw.$typeName === 'string'
|
|
42
|
-
? raw
|
|
43
|
-
: fromJson(GetAccountInfoWithOptsReplySchema, raw);
|
|
44
|
-
return {
|
|
45
|
-
response: {
|
|
46
|
-
case: 'payload',
|
|
47
|
-
value: anyPack(GetAccountInfoWithOptsReplySchema, output),
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
case 'GetBalance': {
|
|
52
|
-
const input = anyUnpack(req.payload, GetBalanceRequestSchema);
|
|
53
|
-
const handler = self.getBalance;
|
|
54
|
-
if (typeof handler !== 'function')
|
|
55
|
-
throw new Error("GetBalance: no implementation provided; set the mock's getBalance property to define the return value.");
|
|
56
|
-
const raw = handler(input);
|
|
57
|
-
const output = raw && typeof raw.$typeName === 'string'
|
|
58
|
-
? raw
|
|
59
|
-
: fromJson(GetBalanceReplySchema, raw);
|
|
60
|
-
return { response: { case: 'payload', value: anyPack(GetBalanceReplySchema, output) } };
|
|
61
|
-
}
|
|
62
|
-
case 'GetBlock': {
|
|
63
|
-
const input = anyUnpack(req.payload, GetBlockRequestSchema);
|
|
64
|
-
const handler = self.getBlock;
|
|
65
|
-
if (typeof handler !== 'function')
|
|
66
|
-
throw new Error("GetBlock: no implementation provided; set the mock's getBlock property to define the return value.");
|
|
67
|
-
const raw = handler(input);
|
|
68
|
-
const output = raw && typeof raw.$typeName === 'string'
|
|
69
|
-
? raw
|
|
70
|
-
: fromJson(GetBlockReplySchema, raw);
|
|
71
|
-
return { response: { case: 'payload', value: anyPack(GetBlockReplySchema, output) } };
|
|
72
|
-
}
|
|
73
|
-
case 'GetFeeForMessage': {
|
|
74
|
-
const input = anyUnpack(req.payload, GetFeeForMessageRequestSchema);
|
|
75
|
-
const handler = self.getFeeForMessage;
|
|
76
|
-
if (typeof handler !== 'function')
|
|
77
|
-
throw new Error("GetFeeForMessage: no implementation provided; set the mock's getFeeForMessage property to define the return value.");
|
|
78
|
-
const raw = handler(input);
|
|
79
|
-
const output = raw && typeof raw.$typeName === 'string'
|
|
80
|
-
? raw
|
|
81
|
-
: fromJson(GetFeeForMessageReplySchema, raw);
|
|
82
|
-
return {
|
|
83
|
-
response: { case: 'payload', value: anyPack(GetFeeForMessageReplySchema, output) },
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
case 'GetMultipleAccountsWithOpts': {
|
|
87
|
-
const input = anyUnpack(req.payload, GetMultipleAccountsWithOptsRequestSchema);
|
|
88
|
-
const handler = self.getMultipleAccountsWithOpts;
|
|
89
|
-
if (typeof handler !== 'function')
|
|
90
|
-
throw new Error("GetMultipleAccountsWithOpts: no implementation provided; set the mock's getMultipleAccountsWithOpts property to define the return value.");
|
|
91
|
-
const raw = handler(input);
|
|
92
|
-
const output = raw && typeof raw.$typeName === 'string'
|
|
93
|
-
? raw
|
|
94
|
-
: fromJson(GetMultipleAccountsWithOptsReplySchema, raw);
|
|
95
|
-
return {
|
|
96
|
-
response: {
|
|
97
|
-
case: 'payload',
|
|
98
|
-
value: anyPack(GetMultipleAccountsWithOptsReplySchema, output),
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
case 'GetSignatureStatuses': {
|
|
103
|
-
const input = anyUnpack(req.payload, GetSignatureStatusesRequestSchema);
|
|
104
|
-
const handler = self.getSignatureStatuses;
|
|
105
|
-
if (typeof handler !== 'function')
|
|
106
|
-
throw new Error("GetSignatureStatuses: no implementation provided; set the mock's getSignatureStatuses property to define the return value.");
|
|
107
|
-
const raw = handler(input);
|
|
108
|
-
const output = raw && typeof raw.$typeName === 'string'
|
|
109
|
-
? raw
|
|
110
|
-
: fromJson(GetSignatureStatusesReplySchema, raw);
|
|
111
|
-
return {
|
|
112
|
-
response: {
|
|
113
|
-
case: 'payload',
|
|
114
|
-
value: anyPack(GetSignatureStatusesReplySchema, output),
|
|
115
|
-
},
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
case 'GetSlotHeight': {
|
|
119
|
-
const input = anyUnpack(req.payload, GetSlotHeightRequestSchema);
|
|
120
|
-
const handler = self.getSlotHeight;
|
|
121
|
-
if (typeof handler !== 'function')
|
|
122
|
-
throw new Error("GetSlotHeight: no implementation provided; set the mock's getSlotHeight property to define the return value.");
|
|
123
|
-
const raw = handler(input);
|
|
124
|
-
const output = raw && typeof raw.$typeName === 'string'
|
|
125
|
-
? raw
|
|
126
|
-
: fromJson(GetSlotHeightReplySchema, raw);
|
|
127
|
-
return {
|
|
128
|
-
response: { case: 'payload', value: anyPack(GetSlotHeightReplySchema, output) },
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
case 'GetTransaction': {
|
|
132
|
-
const input = anyUnpack(req.payload, GetTransactionRequestSchema);
|
|
133
|
-
const handler = self.getTransaction;
|
|
134
|
-
if (typeof handler !== 'function')
|
|
135
|
-
throw new Error("GetTransaction: no implementation provided; set the mock's getTransaction property to define the return value.");
|
|
136
|
-
const raw = handler(input);
|
|
137
|
-
const output = raw && typeof raw.$typeName === 'string'
|
|
138
|
-
? raw
|
|
139
|
-
: fromJson(GetTransactionReplySchema, raw);
|
|
140
|
-
return {
|
|
141
|
-
response: { case: 'payload', value: anyPack(GetTransactionReplySchema, output) },
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
case 'WriteReport': {
|
|
145
|
-
const input = anyUnpack(req.payload, WriteReportRequestSchema);
|
|
146
|
-
const handler = self.writeReport;
|
|
147
|
-
if (typeof handler !== 'function')
|
|
148
|
-
throw new Error("WriteReport: no implementation provided; set the mock's writeReport property to define the return value.");
|
|
149
|
-
const raw = handler(input);
|
|
150
|
-
const output = raw && typeof raw.$typeName === 'string'
|
|
151
|
-
? raw
|
|
152
|
-
: fromJson(WriteReportReplySchema, raw);
|
|
153
|
-
return { response: { case: 'payload', value: anyPack(WriteReportReplySchema, output) } };
|
|
154
|
-
}
|
|
155
|
-
default:
|
|
156
|
-
return { response: { case: 'error', value: `unknown method ${req.method}` } };
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
catch {
|
|
161
|
-
throw new Error("Capability mocks must be used within the CRE test framework's test() method.");
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Returns the mock instance for this capability and the specified tags.
|
|
166
|
-
* Multiple calls with the same tag values return the same instance.
|
|
167
|
-
* Must be called within the test framework's test() method.
|
|
168
|
-
*/
|
|
169
|
-
static testInstance(chainSelector) {
|
|
170
|
-
const qualifiedId = `solana:ChainSelector:${chainSelector}@1.0.0`;
|
|
171
|
-
let instance = __getTestMockInstance(qualifiedId);
|
|
172
|
-
if (!instance) {
|
|
173
|
-
instance = new SolanaMock(chainSelector);
|
|
174
|
-
__setTestMockInstance(qualifiedId, instance);
|
|
175
|
-
}
|
|
176
|
-
return instance;
|
|
177
|
-
}
|
|
178
|
-
}
|