@chainlink/cre-sdk 1.6.0-alpha.1 → 1.6.0-alpha.3
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/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.d.ts +1023 -0
- package/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.js +290 -0
- package/dist/generated/capabilities/blockchain/solana/v1alpha/client_pb.d.ts +2904 -0
- package/dist/generated/capabilities/blockchain/solana/v1alpha/client_pb.js +506 -0
- package/dist/generated/chain-selectors/mainnet/evm/ab-mainnet.d.ts +3 -0
- package/dist/generated/chain-selectors/mainnet/evm/ab-mainnet.js +12 -0
- package/dist/generated/chain-selectors/mainnet/evm/adi-mainnet.d.ts +3 -0
- package/dist/generated/chain-selectors/mainnet/evm/adi-mainnet.js +12 -0
- package/dist/generated/chain-selectors/mainnet/evm/edge-mainnet.d.ts +3 -0
- package/dist/generated/chain-selectors/mainnet/evm/edge-mainnet.js +12 -0
- package/dist/generated/chain-selectors/mainnet/evm/everclear-mainnet.d.ts +3 -0
- package/dist/generated/chain-selectors/mainnet/evm/everclear-mainnet.js +12 -0
- package/dist/generated/chain-selectors/mainnet/evm/gate-chain-mainnet.d.ts +3 -0
- package/dist/generated/chain-selectors/mainnet/evm/gate-chain-mainnet.js +12 -0
- package/dist/generated/chain-selectors/mainnet/evm/gate-layer-mainnet.d.ts +3 -0
- package/dist/generated/chain-selectors/mainnet/evm/gate-layer-mainnet.js +12 -0
- package/dist/generated/chain-selectors/mainnet/evm/jovay-mainnet.d.ts +3 -0
- package/dist/generated/chain-selectors/mainnet/evm/jovay-mainnet.js +12 -0
- package/dist/generated/chain-selectors/mainnet/evm/megaeth-mainnet.d.ts +3 -0
- package/dist/generated/chain-selectors/mainnet/evm/megaeth-mainnet.js +12 -0
- package/dist/generated/chain-selectors/mainnet/evm/pharos-mainnet.d.ts +3 -0
- package/dist/generated/chain-selectors/mainnet/evm/pharos-mainnet.js +12 -0
- package/dist/generated/chain-selectors/mainnet/evm/stable-mainnet.d.ts +3 -0
- package/dist/generated/chain-selectors/mainnet/evm/stable-mainnet.js +12 -0
- package/dist/generated/chain-selectors/mainnet/evm/tempo-mainnet.d.ts +3 -0
- package/dist/generated/chain-selectors/mainnet/evm/tempo-mainnet.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/0g-testnet-galileo-1.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/0g-testnet-galileo-1.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/ab-testnet.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/ab-testnet.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/adi-testnet.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/adi-testnet.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/arc-testnet.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/arc-testnet.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/celo-sepolia.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/celo-sepolia.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/dogeos-testnet-chikyu.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/dogeos-testnet-chikyu.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/edge-testnet.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/edge-testnet.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/ethereum-testnet-hoodi-morph.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/ethereum-testnet-hoodi-morph.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/ethereum-testnet-hoodi-taiko-1.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/ethereum-testnet-hoodi-taiko-1.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/ethereum-testnet-hoodi-taiko.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/ethereum-testnet-hoodi-taiko.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/ethereum-testnet-hoodi.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/ethereum-testnet-hoodi.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/ethereum-testnet-sepolia-ronin-1.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/ethereum-testnet-sepolia-ronin-1.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/everclear-testnet-sepolia.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/everclear-testnet-sepolia.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/gate-chain-testnet-meteora.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/gate-chain-testnet-meteora.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/gate-layer-testnet.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/gate-layer-testnet.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/megaeth-testnet-2.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/megaeth-testnet-2.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/pharos-atlantic-testnet.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/pharos-atlantic-testnet.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/robinhood-testnet.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/robinhood-testnet.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/sonic-testnet.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/sonic-testnet.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/stable-testnet.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/stable-testnet.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/tempo-testnet-moderato.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/tempo-testnet-moderato.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/tempo-testnet.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/tempo-testnet.js +12 -0
- package/dist/generated/chain-selectors/testnet/evm/xlayer-testnet.d.ts +3 -0
- package/dist/generated/chain-selectors/testnet/evm/xlayer-testnet.js +12 -0
- package/dist/generated/networks.d.ts +2 -2
- package/dist/generated/networks.js +238 -0
- package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.d.ts +52 -0
- package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.js +186 -0
- package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.d.ts +92 -0
- package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.js +343 -0
- package/dist/sdk/cre/index.d.ts +6 -0
- package/dist/sdk/cre/index.js +8 -0
- package/dist/sdk/don-info.d.ts +10 -0
- package/dist/sdk/don-info.js +9 -0
- package/dist/sdk/errors.d.ts +24 -1
- package/dist/sdk/errors.js +46 -1
- package/dist/sdk/index.d.ts +2 -0
- package/dist/sdk/index.js +2 -0
- package/dist/sdk/report-internals.d.ts +6 -0
- package/dist/sdk/report-internals.js +3 -0
- package/dist/sdk/report.d.ts +38 -0
- package/dist/sdk/report.js +474 -2
- package/dist/sdk/test/generated/capabilities/blockchain/aptos/v1alpha/aptos_mock_gen.d.ts +25 -0
- package/dist/sdk/test/generated/capabilities/blockchain/aptos/v1alpha/aptos_mock_gen.js +111 -0
- package/dist/sdk/test/generated/capabilities/blockchain/solana/v1alpha/solana_mock_gen.d.ts +33 -0
- package/dist/sdk/test/generated/capabilities/blockchain/solana/v1alpha/solana_mock_gen.js +178 -0
- package/dist/sdk/test/generated/index.d.ts +2 -0
- package/dist/sdk/test/generated/index.js +2 -0
- package/dist/sdk/testutils/test-runtime.js +4 -0
- package/package.json +3 -3
- package/scripts/run.ts +1 -0
- package/scripts/src/check-determinism.test.ts +64 -0
- package/scripts/src/check-determinism.ts +32 -0
- package/scripts/src/compile-to-js.ts +7 -0
- package/scripts/src/generate-chain-selectors.ts +9 -27
- package/scripts/src/generate-sdks.ts +12 -0
- package/scripts/src/validate-shared.ts +400 -0
- package/scripts/src/validate-workflow-determinism.test.ts +409 -0
- package/scripts/src/validate-workflow-determinism.ts +545 -0
- package/scripts/src/validate-workflow-runtime-compat.ts +25 -377
package/dist/sdk/report.js
CHANGED
|
@@ -1,12 +1,484 @@
|
|
|
1
|
-
import { fromJson } from '@bufbuild/protobuf';
|
|
2
|
-
import {
|
|
1
|
+
import { create, fromJson } from '@bufbuild/protobuf';
|
|
2
|
+
import { BinaryReader, WireType } from '@bufbuild/protobuf/wire';
|
|
3
|
+
import { AnySchema } from '@bufbuild/protobuf/wkt';
|
|
4
|
+
import { AttributedSignatureSchema, AwaitCapabilitiesRequestSchema, CapabilityRequestSchema, ReportResponseSchema, } from '../generated/sdk/v1alpha/sdk_pb';
|
|
5
|
+
import { concatHex, getAddress, hexToBytes, keccak256, recoverAddress, toHex } from 'viem';
|
|
6
|
+
import { productionEnvironment } from './don-info';
|
|
7
|
+
import { DuplicateSignerError, NullReportError, ParseSignatureError, RawReportTooShortError, RecoverSignerError, UnknownSignerError, WrongSignatureCountError, } from './errors';
|
|
8
|
+
import { donInfoCache } from './report-internals';
|
|
9
|
+
const GET_DON_SELECTOR = new Uint8Array([0x23, 0x53, 0x74, 0x05]);
|
|
10
|
+
const GET_NODES_BY_P2P_IDS_SELECTOR = new Uint8Array([0x05, 0xa5, 0x19, 0x66]);
|
|
11
|
+
function cacheKey(env, donID) {
|
|
12
|
+
return `${env.chainSelector.toString()}:${donID}`;
|
|
13
|
+
}
|
|
14
|
+
function normalizeRegistryHex(addr) {
|
|
15
|
+
return addr
|
|
16
|
+
.trim()
|
|
17
|
+
.replace(/^0[xX]/, '')
|
|
18
|
+
.toLowerCase();
|
|
19
|
+
}
|
|
20
|
+
function isProductionEnvironmentForReport(env) {
|
|
21
|
+
const pe = productionEnvironment();
|
|
22
|
+
return (env.chainSelector === pe.chainSelector &&
|
|
23
|
+
normalizeRegistryHex(env.registryAddress) === normalizeRegistryHex(pe.registryAddress));
|
|
24
|
+
}
|
|
25
|
+
function decodeRegistryAddress(registryAddress) {
|
|
26
|
+
const hex = normalizeRegistryHex(registryAddress);
|
|
27
|
+
if (hex.length !== 40) {
|
|
28
|
+
throw new Error(`invalid registry address ${JSON.stringify(registryAddress)}`);
|
|
29
|
+
}
|
|
30
|
+
return hexToBytes(`0x${hex}`);
|
|
31
|
+
}
|
|
32
|
+
function padUint256(v) {
|
|
33
|
+
const n = typeof v === 'bigint' ? v : BigInt(v);
|
|
34
|
+
const b = new Uint8Array(32);
|
|
35
|
+
const view = new DataView(b.buffer);
|
|
36
|
+
view.setBigUint64(24, n, false);
|
|
37
|
+
return b;
|
|
38
|
+
}
|
|
39
|
+
function bytesToBigIntBE(word) {
|
|
40
|
+
let x = 0n;
|
|
41
|
+
for (let i = 0; i < word.length; i++) {
|
|
42
|
+
x = (x << 8n) | BigInt(word[i]);
|
|
43
|
+
}
|
|
44
|
+
return x;
|
|
45
|
+
}
|
|
46
|
+
function readUint256AsInt(word) {
|
|
47
|
+
const b = bytesToBigIntBE(word);
|
|
48
|
+
if (b > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
49
|
+
throw new Error('ABI uint256 value too large for Number');
|
|
50
|
+
}
|
|
51
|
+
return Number(b);
|
|
52
|
+
}
|
|
53
|
+
function protoVarint(v) {
|
|
54
|
+
const out = [];
|
|
55
|
+
let n = typeof v === 'bigint' ? v : BigInt(v);
|
|
56
|
+
while (n >= 128n) {
|
|
57
|
+
out.push(Number(n & 0x7fn) | 0x80);
|
|
58
|
+
n >>= 7n;
|
|
59
|
+
}
|
|
60
|
+
out.push(Number(n));
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
function protoTag(field, wireType) {
|
|
64
|
+
return protoVarint((field << 3) | wireType);
|
|
65
|
+
}
|
|
66
|
+
function protoLenBytes(data) {
|
|
67
|
+
return [...protoVarint(data.length), ...data];
|
|
68
|
+
}
|
|
69
|
+
function buildCallContractRequestBytes(registryAddr, callData) {
|
|
70
|
+
const callMsg = new Uint8Array([
|
|
71
|
+
...protoTag(2, 2),
|
|
72
|
+
...protoLenBytes(registryAddr),
|
|
73
|
+
...protoTag(3, 2),
|
|
74
|
+
...protoLenBytes(callData),
|
|
75
|
+
]);
|
|
76
|
+
const bigInt = new Uint8Array([
|
|
77
|
+
...protoTag(1, 2),
|
|
78
|
+
...protoLenBytes(new Uint8Array([0x03])),
|
|
79
|
+
...protoTag(2, 0),
|
|
80
|
+
...protoVarint(0xffffffffffffffffn),
|
|
81
|
+
]);
|
|
82
|
+
return new Uint8Array([
|
|
83
|
+
...protoTag(2, 2),
|
|
84
|
+
...protoLenBytes(bigInt),
|
|
85
|
+
...protoTag(1, 2),
|
|
86
|
+
...protoLenBytes(callMsg),
|
|
87
|
+
]);
|
|
88
|
+
}
|
|
89
|
+
function decodeCallContractReplyData(bytes) {
|
|
90
|
+
const reader = new BinaryReader(bytes);
|
|
91
|
+
while (reader.pos < reader.len) {
|
|
92
|
+
const [fieldNo, wireType] = reader.tag();
|
|
93
|
+
if (fieldNo === 1 && wireType === WireType.LengthDelimited) {
|
|
94
|
+
return reader.bytes();
|
|
95
|
+
}
|
|
96
|
+
reader.skip(wireType);
|
|
97
|
+
}
|
|
98
|
+
throw new Error('data field not found in CallContractReply');
|
|
99
|
+
}
|
|
100
|
+
const CALL_CONTRACT_REQUEST_TYPE_URL = 'type.googleapis.com/capabilities.blockchain.evm.v1alpha.CallContractRequest';
|
|
101
|
+
function callContract(runtime, capID, registryAddr, callData) {
|
|
102
|
+
const reqBytes = buildCallContractRequestBytes(registryAddr, callData);
|
|
103
|
+
const anyPayload = create(AnySchema, {
|
|
104
|
+
typeUrl: CALL_CONTRACT_REQUEST_TYPE_URL,
|
|
105
|
+
value: reqBytes,
|
|
106
|
+
});
|
|
107
|
+
// biome-ignore lint/suspicious/noExplicitAny: intentional bypass of typed callCapability to avoid EVM schema imports
|
|
108
|
+
const rt = runtime;
|
|
109
|
+
const callbackId = rt.nextCallId++;
|
|
110
|
+
const req = create(CapabilityRequestSchema, {
|
|
111
|
+
id: capID,
|
|
112
|
+
method: 'CallContract',
|
|
113
|
+
payload: anyPayload,
|
|
114
|
+
callbackId,
|
|
115
|
+
});
|
|
116
|
+
if (!rt.helpers.call(req)) {
|
|
117
|
+
throw new Error(`EVM capability '${capID}' not found`);
|
|
118
|
+
}
|
|
119
|
+
// Must use create() — the real WASM bridge serializes this as a protobuf message and
|
|
120
|
+
// requires a proper typed message (with $typeName). A plain { ids: [...] } object works
|
|
121
|
+
// in the test runtime but silently breaks in simulation.
|
|
122
|
+
const awaitResp = rt.helpers.await(create(AwaitCapabilitiesRequestSchema, { ids: [callbackId] }), rt.maxResponseSize);
|
|
123
|
+
const capResp = awaitResp?.responses?.[callbackId];
|
|
124
|
+
if (!capResp) {
|
|
125
|
+
throw new Error(`no response from EVM capability '${capID}'`);
|
|
126
|
+
}
|
|
127
|
+
const response = capResp.response;
|
|
128
|
+
if (response.case === 'error') {
|
|
129
|
+
throw new Error(response.value);
|
|
130
|
+
}
|
|
131
|
+
if (response.case !== 'payload') {
|
|
132
|
+
throw new Error(`unexpected response '${response.case}' from EVM capability '${capID}'`);
|
|
133
|
+
}
|
|
134
|
+
return decodeCallContractReplyData(response.value.value);
|
|
135
|
+
}
|
|
136
|
+
function encodeGetDONCalldata(donID) {
|
|
137
|
+
const padded = new Uint8Array(32);
|
|
138
|
+
const view = new DataView(padded.buffer);
|
|
139
|
+
view.setUint32(28, donID >>> 0, false);
|
|
140
|
+
const out = new Uint8Array(4 + 32);
|
|
141
|
+
out.set(GET_DON_SELECTOR, 0);
|
|
142
|
+
out.set(padded, 4);
|
|
143
|
+
return out;
|
|
144
|
+
}
|
|
145
|
+
function concatBytes(parts) {
|
|
146
|
+
const total = parts.reduce((n, p) => n + p.length, 0);
|
|
147
|
+
const r = new Uint8Array(total);
|
|
148
|
+
let o = 0;
|
|
149
|
+
for (const p of parts) {
|
|
150
|
+
r.set(p, o);
|
|
151
|
+
o += p.length;
|
|
152
|
+
}
|
|
153
|
+
return r;
|
|
154
|
+
}
|
|
155
|
+
function encodeGetNodesByP2PIdsCalldata(p2pIds) {
|
|
156
|
+
const chunks = [
|
|
157
|
+
GET_NODES_BY_P2P_IDS_SELECTOR,
|
|
158
|
+
padUint256(32),
|
|
159
|
+
padUint256(p2pIds.length),
|
|
160
|
+
];
|
|
161
|
+
for (const id of p2pIds) {
|
|
162
|
+
if (id.length !== 32) {
|
|
163
|
+
throw new Error('p2p id must be 32 bytes');
|
|
164
|
+
}
|
|
165
|
+
chunks.push(new Uint8Array(id));
|
|
166
|
+
}
|
|
167
|
+
return concatBytes(chunks);
|
|
168
|
+
}
|
|
169
|
+
const NODE_TUPLE_HEAD_SIZE = 288;
|
|
170
|
+
function fetchDONInfo(runtime, env, donID) {
|
|
171
|
+
const key = cacheKey(env, donID);
|
|
172
|
+
const hit = donInfoCache.get(key);
|
|
173
|
+
if (hit) {
|
|
174
|
+
return hit;
|
|
175
|
+
}
|
|
176
|
+
const registryAddr = decodeRegistryAddress(env.registryAddress);
|
|
177
|
+
const capID = `evm:ChainSelector:${env.chainSelector.toString()}@1.0.0`;
|
|
178
|
+
const getDONABI = callContract(runtime, capID, registryAddr, encodeGetDONCalldata(donID));
|
|
179
|
+
if (getDONABI.length < 224) {
|
|
180
|
+
throw new Error(`getDON ABI response too short: ${getDONABI.length} bytes`);
|
|
181
|
+
}
|
|
182
|
+
const f = readUint256AsInt(getDONABI.subarray(96, 128));
|
|
183
|
+
const tupleStart = 32;
|
|
184
|
+
const nodeP2PIdsPtr = readUint256AsInt(getDONABI.subarray(192, 224));
|
|
185
|
+
const nodeCountOff = tupleStart + nodeP2PIdsPtr;
|
|
186
|
+
if (nodeCountOff + 32 > getDONABI.length) {
|
|
187
|
+
throw new Error('getDON ABI: nodeP2PIds pointer out of range');
|
|
188
|
+
}
|
|
189
|
+
const nodeCount = readUint256AsInt(getDONABI.subarray(nodeCountOff, nodeCountOff + 32));
|
|
190
|
+
if (nodeCountOff + 32 + nodeCount * 32 > getDONABI.length) {
|
|
191
|
+
throw new Error('getDON ABI: nodeP2PIds data out of range');
|
|
192
|
+
}
|
|
193
|
+
const nodeP2PIds = [];
|
|
194
|
+
for (let i = 0; i < nodeCount; i++) {
|
|
195
|
+
const start = nodeCountOff + 32 + i * 32;
|
|
196
|
+
nodeP2PIds.push(getDONABI.subarray(start, start + 32));
|
|
197
|
+
}
|
|
198
|
+
if (nodeCount === 0) {
|
|
199
|
+
const info = { f, signers: new Map() };
|
|
200
|
+
donInfoCache.set(key, info);
|
|
201
|
+
return info;
|
|
202
|
+
}
|
|
203
|
+
const getNodesABI = callContract(runtime, capID, registryAddr, encodeGetNodesByP2PIdsCalldata(nodeP2PIds));
|
|
204
|
+
if (getNodesABI.length < 64) {
|
|
205
|
+
throw new Error(`getNodesByP2PIds ABI response too short: ${getNodesABI.length} bytes`);
|
|
206
|
+
}
|
|
207
|
+
const outerPtr = readUint256AsInt(getNodesABI.subarray(0, 32));
|
|
208
|
+
if (outerPtr + 32 > getNodesABI.length) {
|
|
209
|
+
throw new Error('getNodesByP2PIds ABI: outer pointer out of range');
|
|
210
|
+
}
|
|
211
|
+
const returnedCount = readUint256AsInt(getNodesABI.subarray(outerPtr, outerPtr + 32));
|
|
212
|
+
const signers = new Map();
|
|
213
|
+
for (let i = 0; i < returnedCount; i++) {
|
|
214
|
+
const elemPtrOff = outerPtr + 32 + i * 32;
|
|
215
|
+
if (elemPtrOff + 32 > getNodesABI.length) {
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
const elemPtr = readUint256AsInt(getNodesABI.subarray(elemPtrOff, elemPtrOff + 32));
|
|
219
|
+
const tupleBase = outerPtr + 32 + elemPtr;
|
|
220
|
+
if (tupleBase + NODE_TUPLE_HEAD_SIZE > getNodesABI.length) {
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
const nodeOperatorId = Number(bytesToBigIntBE(getNodesABI.subarray(tupleBase, tupleBase + 32)) & 0xffffffffn);
|
|
224
|
+
const signerSlot = tupleBase + 3 * 32;
|
|
225
|
+
const addrBytes = getNodesABI.subarray(signerSlot, signerSlot + 20);
|
|
226
|
+
const addr = getAddress(toHex(addrBytes));
|
|
227
|
+
signers.set(addr, nodeOperatorId);
|
|
228
|
+
}
|
|
229
|
+
const info = { f, signers };
|
|
230
|
+
donInfoCache.set(key, info);
|
|
231
|
+
return info;
|
|
232
|
+
}
|
|
233
|
+
function computeReportHash(rawReport, reportContext) {
|
|
234
|
+
const innerHash = keccak256(toHex(rawReport));
|
|
235
|
+
return keccak256(concatHex([innerHash, toHex(reportContext)]));
|
|
236
|
+
}
|
|
237
|
+
function addressKeyNo0x(addr) {
|
|
238
|
+
return addr.slice(2).toLowerCase();
|
|
239
|
+
}
|
|
240
|
+
async function verifySigs(report, f, signers) {
|
|
241
|
+
const required = f + 1;
|
|
242
|
+
const sigs = report.sigs;
|
|
243
|
+
if (sigs.length < required) {
|
|
244
|
+
throw new WrongSignatureCountError();
|
|
245
|
+
}
|
|
246
|
+
const reportHash = computeReportHash(report.rawReport, report.reportContext);
|
|
247
|
+
const seen = new Set();
|
|
248
|
+
const accepted = [];
|
|
249
|
+
const skipErrs = [];
|
|
250
|
+
for (let i = 0; i < sigs.length; i++) {
|
|
251
|
+
if (accepted.length === required) {
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
const attrSig = sigs[i];
|
|
255
|
+
const sigBytes = new Uint8Array(attrSig.signature);
|
|
256
|
+
if (sigBytes.length !== 65) {
|
|
257
|
+
skipErrs.push(new ParseSignatureError());
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
const normalized = new Uint8Array(sigBytes);
|
|
261
|
+
if (normalized[64] === 27 || normalized[64] === 28) {
|
|
262
|
+
normalized[64] -= 27;
|
|
263
|
+
}
|
|
264
|
+
let recovered;
|
|
265
|
+
try {
|
|
266
|
+
recovered = await recoverAddress({
|
|
267
|
+
hash: reportHash,
|
|
268
|
+
signature: toHex(normalized),
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
catch {
|
|
272
|
+
skipErrs.push(new RecoverSignerError());
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
const key = addressKeyNo0x(recovered);
|
|
276
|
+
if (seen.has(key)) {
|
|
277
|
+
skipErrs.push(new DuplicateSignerError());
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
seen.add(key);
|
|
281
|
+
const nodeOperatorId = signers.get(key);
|
|
282
|
+
if (nodeOperatorId === undefined) {
|
|
283
|
+
skipErrs.push(new UnknownSignerError());
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
attrSig.signerId = nodeOperatorId;
|
|
287
|
+
accepted.push(attrSig);
|
|
288
|
+
}
|
|
289
|
+
if (accepted.length < required) {
|
|
290
|
+
if (skipErrs.length > 0) {
|
|
291
|
+
throw new AggregateError(skipErrs);
|
|
292
|
+
}
|
|
293
|
+
throw new WrongSignatureCountError();
|
|
294
|
+
}
|
|
295
|
+
report.sigs = accepted;
|
|
296
|
+
}
|
|
297
|
+
function mergeReportParseConfig(overrides) {
|
|
298
|
+
return {
|
|
299
|
+
acceptedZones: overrides?.acceptedZones ?? [],
|
|
300
|
+
acceptedEnvironments: overrides !== undefined ? (overrides.acceptedEnvironments ?? []) : [productionEnvironment()],
|
|
301
|
+
skipSignatureVerification: overrides?.skipSignatureVerification ?? false,
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function normalizeDonSigners(signers) {
|
|
305
|
+
const out = new Map();
|
|
306
|
+
for (const [addr, id] of signers) {
|
|
307
|
+
out.set(addr.slice(2).toLowerCase(), id);
|
|
308
|
+
}
|
|
309
|
+
return out;
|
|
310
|
+
}
|
|
311
|
+
export const REPORT_METADATA_HEADER_LENGTH = 109;
|
|
312
|
+
const REPORT_METADATA_OFFSETS = {
|
|
313
|
+
version: 0,
|
|
314
|
+
versionSize: 1,
|
|
315
|
+
executionId: 1,
|
|
316
|
+
executionIdSize: 32,
|
|
317
|
+
timestamp: 33,
|
|
318
|
+
timestampSize: 4,
|
|
319
|
+
donId: 37,
|
|
320
|
+
donIdSize: 4,
|
|
321
|
+
donConfigVersion: 41,
|
|
322
|
+
donConfigVersionSize: 4,
|
|
323
|
+
workflowId: 45,
|
|
324
|
+
workflowIdSize: 32,
|
|
325
|
+
workflowName: 77,
|
|
326
|
+
workflowNameSize: 10,
|
|
327
|
+
workflowOwner: 87,
|
|
328
|
+
workflowOwnerSize: 20,
|
|
329
|
+
reportId: 107,
|
|
330
|
+
reportIdSize: 2,
|
|
331
|
+
bodyStart: 109,
|
|
332
|
+
};
|
|
333
|
+
function encodeHexLower(bytes) {
|
|
334
|
+
let out = '';
|
|
335
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
336
|
+
out += bytes[i].toString(16).padStart(2, '0');
|
|
337
|
+
}
|
|
338
|
+
return out;
|
|
339
|
+
}
|
|
340
|
+
function readUint32BE(raw, offset) {
|
|
341
|
+
return new DataView(raw.buffer, raw.byteOffset + offset, 4).getUint32(0, false);
|
|
342
|
+
}
|
|
343
|
+
function parseReportMetadataHeader(raw) {
|
|
344
|
+
if (raw === undefined || raw === null) {
|
|
345
|
+
throw new NullReportError();
|
|
346
|
+
}
|
|
347
|
+
if (raw.length < REPORT_METADATA_HEADER_LENGTH) {
|
|
348
|
+
throw new RawReportTooShortError(REPORT_METADATA_HEADER_LENGTH, raw.length);
|
|
349
|
+
}
|
|
350
|
+
const o = REPORT_METADATA_OFFSETS;
|
|
351
|
+
const workflowNameBytes = raw.subarray(o.workflowName, o.workflowName + o.workflowNameSize);
|
|
352
|
+
return {
|
|
353
|
+
version: raw[o.version],
|
|
354
|
+
executionId: encodeHexLower(raw.subarray(o.executionId, o.executionId + o.executionIdSize)),
|
|
355
|
+
timestamp: readUint32BE(raw, o.timestamp),
|
|
356
|
+
donId: readUint32BE(raw, o.donId),
|
|
357
|
+
donConfigVersion: readUint32BE(raw, o.donConfigVersion),
|
|
358
|
+
workflowId: encodeHexLower(raw.subarray(o.workflowId, o.workflowId + o.workflowIdSize)),
|
|
359
|
+
workflowName: new TextDecoder('utf-8', { fatal: false }).decode(workflowNameBytes),
|
|
360
|
+
workflowOwner: encodeHexLower(raw.subarray(o.workflowOwner, o.workflowOwner + o.workflowOwnerSize)),
|
|
361
|
+
reportId: encodeHexLower(raw.subarray(o.reportId, o.reportId + o.reportIdSize)),
|
|
362
|
+
body: raw.subarray(REPORT_METADATA_HEADER_LENGTH),
|
|
363
|
+
};
|
|
364
|
+
}
|
|
3
365
|
export class Report {
|
|
4
366
|
report;
|
|
367
|
+
cachedHeader;
|
|
5
368
|
constructor(report) {
|
|
6
369
|
this.report = report.$typeName
|
|
7
370
|
? report
|
|
8
371
|
: fromJson(ReportResponseSchema, report);
|
|
9
372
|
}
|
|
373
|
+
static async parse(runtime, rawReport, signatures, reportContext, config) {
|
|
374
|
+
const configDigest = reportContext.length >= 32 ? reportContext.slice(0, 32) : new Uint8Array(32);
|
|
375
|
+
const seqNr = reportContext.length >= 40
|
|
376
|
+
? new DataView(reportContext.buffer, reportContext.byteOffset + 32, 8).getBigUint64(0, false)
|
|
377
|
+
: 0n;
|
|
378
|
+
const reportResponse = create(ReportResponseSchema, {
|
|
379
|
+
configDigest,
|
|
380
|
+
seqNr,
|
|
381
|
+
reportContext,
|
|
382
|
+
rawReport,
|
|
383
|
+
sigs: signatures.map((signature) => create(AttributedSignatureSchema, { signature, signerId: 0 })),
|
|
384
|
+
});
|
|
385
|
+
const merged = mergeReportParseConfig(config);
|
|
386
|
+
const report = new Report(reportResponse);
|
|
387
|
+
if (merged.skipSignatureVerification) {
|
|
388
|
+
report.donId();
|
|
389
|
+
return report;
|
|
390
|
+
}
|
|
391
|
+
await report.verifySignaturesWithConfig(runtime, merged);
|
|
392
|
+
return report;
|
|
393
|
+
}
|
|
394
|
+
parseHeader() {
|
|
395
|
+
if (this.cachedHeader !== undefined) {
|
|
396
|
+
return this.cachedHeader;
|
|
397
|
+
}
|
|
398
|
+
this.cachedHeader = parseReportMetadataHeader(this.report.rawReport);
|
|
399
|
+
return this.cachedHeader;
|
|
400
|
+
}
|
|
401
|
+
async verifySignaturesWithConfig(runtime, config) {
|
|
402
|
+
const donId = this.donId();
|
|
403
|
+
const candidates = [];
|
|
404
|
+
for (const z of config.acceptedZones) {
|
|
405
|
+
if (z.donID === donId) {
|
|
406
|
+
candidates.push(z.environment);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
candidates.push(...config.acceptedEnvironments);
|
|
410
|
+
if (candidates.length === 0) {
|
|
411
|
+
throw new Error(`DON ID ${donId} is not in accepted zones`);
|
|
412
|
+
}
|
|
413
|
+
const fetchFailures = [];
|
|
414
|
+
let lastVerifyErr = null;
|
|
415
|
+
for (const env of candidates) {
|
|
416
|
+
let info;
|
|
417
|
+
try {
|
|
418
|
+
info = fetchDONInfo(runtime, env, donId);
|
|
419
|
+
}
|
|
420
|
+
catch (err) {
|
|
421
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
422
|
+
fetchFailures.push(new Error(`could not read from chain ${env.chainSelector} contract ${env.registryAddress}: ${msg}`));
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
try {
|
|
426
|
+
await verifySigs(this.report, info.f, normalizeDonSigners(info.signers));
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
catch (err) {
|
|
430
|
+
lastVerifyErr = err instanceof Error ? err : new Error(String(err));
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
if (fetchFailures.length > 0) {
|
|
434
|
+
throw new AggregateError(fetchFailures, fetchFailures.map((e) => e.message).join('\n'));
|
|
435
|
+
}
|
|
436
|
+
if (lastVerifyErr !== null) {
|
|
437
|
+
throw lastVerifyErr;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
seqNr() {
|
|
441
|
+
return this.report.seqNr;
|
|
442
|
+
}
|
|
443
|
+
configDigest() {
|
|
444
|
+
return this.report.configDigest;
|
|
445
|
+
}
|
|
446
|
+
reportContext() {
|
|
447
|
+
return this.report.reportContext;
|
|
448
|
+
}
|
|
449
|
+
rawReport() {
|
|
450
|
+
return this.report.rawReport;
|
|
451
|
+
}
|
|
452
|
+
version() {
|
|
453
|
+
return this.parseHeader().version;
|
|
454
|
+
}
|
|
455
|
+
executionId() {
|
|
456
|
+
return this.parseHeader().executionId;
|
|
457
|
+
}
|
|
458
|
+
timestamp() {
|
|
459
|
+
return this.parseHeader().timestamp;
|
|
460
|
+
}
|
|
461
|
+
donId() {
|
|
462
|
+
return this.parseHeader().donId;
|
|
463
|
+
}
|
|
464
|
+
donConfigVersion() {
|
|
465
|
+
return this.parseHeader().donConfigVersion;
|
|
466
|
+
}
|
|
467
|
+
workflowId() {
|
|
468
|
+
return this.parseHeader().workflowId;
|
|
469
|
+
}
|
|
470
|
+
workflowName() {
|
|
471
|
+
return this.parseHeader().workflowName;
|
|
472
|
+
}
|
|
473
|
+
workflowOwner() {
|
|
474
|
+
return this.parseHeader().workflowOwner;
|
|
475
|
+
}
|
|
476
|
+
reportId() {
|
|
477
|
+
return this.parseHeader().reportId;
|
|
478
|
+
}
|
|
479
|
+
body() {
|
|
480
|
+
return this.parseHeader().body;
|
|
481
|
+
}
|
|
10
482
|
// x_generatedCodeOnly_unwrap is meant to be used by the code generator only.
|
|
11
483
|
x_generatedCodeOnly_unwrap() {
|
|
12
484
|
return this.report;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type AccountAPTBalanceReply, type AccountAPTBalanceReplyJson, type AccountAPTBalanceRequest, type AccountTransactionsReply, type AccountTransactionsReplyJson, type AccountTransactionsRequest, type TransactionByHashReply, type TransactionByHashReplyJson, type TransactionByHashRequest, type ViewReply, type ViewReplyJson, type ViewRequest, type WriteReportReply, type WriteReportReplyJson, type WriteReportRequest } from '../../../../../../../generated/capabilities/blockchain/aptos/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 AptosMock {
|
|
7
|
+
static readonly CAPABILITY_ID = "aptos@1.0.0";
|
|
8
|
+
/** Set to define the return value for AccountAPTBalance. May return a plain object (AccountAPTBalanceReplyJson) or the message type. */
|
|
9
|
+
accountAPTBalance?: (input: AccountAPTBalanceRequest) => AccountAPTBalanceReply | AccountAPTBalanceReplyJson;
|
|
10
|
+
/** Set to define the return value for View. May return a plain object (ViewReplyJson) or the message type. */
|
|
11
|
+
view?: (input: ViewRequest) => ViewReply | ViewReplyJson;
|
|
12
|
+
/** Set to define the return value for TransactionByHash. May return a plain object (TransactionByHashReplyJson) or the message type. */
|
|
13
|
+
transactionByHash?: (input: TransactionByHashRequest) => TransactionByHashReply | TransactionByHashReplyJson;
|
|
14
|
+
/** Set to define the return value for AccountTransactions. May return a plain object (AccountTransactionsReplyJson) or the message type. */
|
|
15
|
+
accountTransactions?: (input: AccountTransactionsRequest) => AccountTransactionsReply | AccountTransactionsReplyJson;
|
|
16
|
+
/** Set to define the return value for WriteReport. May return a plain object (WriteReportReplyJson) or the message type. */
|
|
17
|
+
writeReport?: (input: WriteReportRequest) => WriteReportReply | WriteReportReplyJson;
|
|
18
|
+
private constructor();
|
|
19
|
+
/**
|
|
20
|
+
* Returns the mock instance for this capability and the specified tags.
|
|
21
|
+
* Multiple calls with the same tag values return the same instance.
|
|
22
|
+
* Must be called within the test framework's test() method.
|
|
23
|
+
*/
|
|
24
|
+
static testInstance(chainSelector: bigint): AptosMock;
|
|
25
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
}
|