@chainlink/cre-sdk 1.15.0 → 1.17.0-alpha.1
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 +2 -62
- package/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.d.ts +1035 -0
- package/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.js +290 -0
- package/dist/generated/capabilities/blockchain/evm/v1alpha/client_pb.js +1 -1
- package/dist/generated/capabilities/blockchain/solana/v1alpha/client_pb.d.ts +2885 -15
- package/dist/generated/capabilities/blockchain/solana/v1alpha/client_pb.js +459 -7
- package/dist/generated/capabilities/networking/http/v1alpha/client_pb.js +1 -1
- package/dist/generated/sdk/v1alpha/sdk_pb.d.ts +505 -0
- package/dist/generated/sdk/v1alpha/sdk_pb.js +121 -15
- package/dist/generated/tools/generator/v1alpha/cre_metadata_pb.d.ts +30 -1
- package/dist/generated/tools/generator/v1alpha/cre_metadata_pb.js +20 -2
- package/dist/generated/workflows/v2/cre_info_pb.d.ts +123 -0
- package/dist/generated/workflows/v2/cre_info_pb.js +17 -0
- package/dist/generated/workflows/v2/workflow_key_pb.d.ts +55 -0
- package/dist/generated/workflows/v2/workflow_key_pb.js +17 -0
- package/dist/generated/workflows/v2/workflow_user_metric_pb.d.ts +118 -0
- package/dist/generated/workflows/v2/workflow_user_metric_pb.js +41 -0
- package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.d.ts +63 -0
- package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.js +247 -0
- package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.d.ts +14 -0
- package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.js +95 -0
- package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.d.ts +69 -2
- package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.js +403 -1
- package/dist/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.d.ts +5 -1
- package/dist/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.js +22 -0
- package/dist/generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen.d.ts +4 -0
- package/dist/generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen.js +12 -0
- package/dist/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.d.ts +11 -1
- package/dist/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.js +12 -0
- package/dist/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.d.ts +2 -0
- package/dist/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.js +2 -0
- package/dist/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.d.ts +2 -0
- package/dist/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.js +2 -0
- package/dist/sdk/cre/index.d.ts +30 -15
- package/dist/sdk/cre/index.js +29 -14
- package/dist/sdk/impl/runtime-impl.d.ts +28 -1
- package/dist/sdk/impl/runtime-impl.js +52 -1
- package/dist/sdk/runtime.d.ts +23 -1
- package/dist/sdk/tee-constraints.d.ts +68 -0
- package/dist/sdk/tee-constraints.js +59 -0
- package/dist/sdk/test/evm-contract-mock.js +58 -60
- 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 +19 -1
- package/dist/sdk/test/generated/capabilities/blockchain/solana/v1alpha/solana_mock_gen.js +141 -1
- package/dist/sdk/test/generated/index.d.ts +1 -0
- package/dist/sdk/test/generated/index.js +1 -0
- package/dist/sdk/test/index.d.ts +0 -1
- package/dist/sdk/test/index.js +0 -1
- package/dist/sdk/testutils/index.d.ts +1 -1
- package/dist/sdk/testutils/index.js +1 -1
- package/dist/sdk/testutils/test-runtime.d.ts +17 -4
- package/dist/sdk/testutils/test-runtime.js +31 -5
- package/dist/sdk/testutils/test-writer.d.ts +7 -1
- package/dist/sdk/testutils/test-writer.js +13 -1
- package/dist/sdk/types/global.d.ts +8 -0
- package/dist/sdk/utils/capabilities/blockchain/{evm/evm-helpers.d.ts → blockchain-helpers.d.ts} +6 -7
- package/dist/sdk/utils/capabilities/blockchain/{evm/evm-helpers.js → blockchain-helpers.js} +8 -6
- package/dist/sdk/utils/hex-utils.d.ts +0 -6
- package/dist/sdk/utils/hex-utils.js +0 -8
- package/dist/sdk/utils/index.d.ts +1 -3
- package/dist/sdk/utils/index.js +1 -2
- package/dist/sdk/wasm/host-bindings.d.ts +4 -0
- package/dist/sdk/wasm/host-bindings.js +4 -0
- package/dist/sdk/wasm/runner.d.ts +10 -4
- package/dist/sdk/wasm/runner.js +86 -13
- package/dist/sdk/wasm/runtime.d.ts +4 -1
- package/dist/sdk/wasm/runtime.js +9 -1
- package/dist/sdk/workflow.d.ts +16 -7
- package/dist/sdk/workflow.js +10 -2
- package/dist/workflows/standard_tests/restrictions/test.ts +41 -0
- package/dist/workflows/standard_tests/tee_runtime/test.ts +29 -0
- package/package.json +3 -6
- package/scripts/src/generate-sdks.ts +6 -0
- package/dist/sdk/test/contract-mock-core.d.ts +0 -16
- package/dist/sdk/test/contract-mock-core.js +0 -21
- package/dist/sdk/test/solana-contract-mock.d.ts +0 -54
- package/dist/sdk/test/solana-contract-mock.js +0 -63
- package/dist/sdk/utils/capabilities/blockchain/report-helpers.d.ts +0 -19
- package/dist/sdk/utils/capabilities/blockchain/report-helpers.js +0 -16
- package/dist/sdk/utils/capabilities/blockchain/solana/solana-helpers.d.ts +0 -101
- package/dist/sdk/utils/capabilities/blockchain/solana/solana-helpers.js +0 -100
package/README.md
CHANGED
|
@@ -86,10 +86,10 @@ This TypeScript CRE SDK also includes some reference examples - [cre-sdk-example
|
|
|
86
86
|
|
|
87
87
|
You can run and debug your TypeScript workflows locally using [the CRE CLI's](https://github.com/smartcontractkit/cre-cli) simulation functionality.
|
|
88
88
|
|
|
89
|
-
Make sure you `cd` into the directory that contain's your workflow's TypeScript file and the associated config
|
|
89
|
+
Make sure you `cd` into the directory that contain's your workflow's TypeScript file and the associated `config.json`. Then:
|
|
90
90
|
|
|
91
91
|
```bash
|
|
92
|
-
cre workflow simulate --target
|
|
92
|
+
cre workflow simulate --target local-simulation --config config.json index.ts
|
|
93
93
|
```
|
|
94
94
|
|
|
95
95
|
When simulating workflows that write to the blockchain, remember to pass extra flag `--broadcast` to broadcast the transactions to the blockchain.
|
|
@@ -237,66 +237,6 @@ const onCronTrigger = (runtime: Runtime<Config>) => {
|
|
|
237
237
|
};
|
|
238
238
|
```
|
|
239
239
|
|
|
240
|
-
### Solana Write Reports
|
|
241
|
-
|
|
242
|
-
The Solana capability is **write-only**: reports are delivered through the
|
|
243
|
-
keystone-forwarder to a receiver program's `on_report` entrypoint as a bare
|
|
244
|
-
Borsh-encoded struct. The SDK ships the write plumbing under
|
|
245
|
-
`utils/capabilities/blockchain/solana`:
|
|
246
|
-
|
|
247
|
-
- `calculateAccountsHash(accounts)` — sha256 of the concatenated account
|
|
248
|
-
public keys (the forwarder's on-chain account verification),
|
|
249
|
-
- `encodeForwarderReport({ accountHash, payload })` — the
|
|
250
|
-
`[32-byte hash][u32-LE len][payload]` forwarder envelope,
|
|
251
|
-
- `encodeBorshVecU32(elements)` — Borsh `Vec` of pre-encoded elements,
|
|
252
|
-
- `prepareSolanaReportRequest(payload)` — report request with the Solana
|
|
253
|
-
encoder (`solana`/`ecdsa`/`keccak256`),
|
|
254
|
-
- `solanaAccountMeta(publicKey, isWritable)` / `solanaAddressToBytes(base58)`.
|
|
255
|
-
|
|
256
|
-
The wire format is byte-identical to the Go SDK's
|
|
257
|
-
`capabilities/blockchain/solana/bindings` package.
|
|
258
|
-
|
|
259
|
-
Generate typed per-program bindings from an Anchor IDL with the CRE CLI:
|
|
260
|
-
|
|
261
|
-
```bash
|
|
262
|
-
cre generate-bindings solana --language typescript
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
```typescript
|
|
266
|
-
import { cre, type Runtime, solanaAccountMeta, SolanaClient } from "@chainlink/cre-sdk";
|
|
267
|
-
import { DataStorage } from "../contracts/solana/ts/generated";
|
|
268
|
-
|
|
269
|
-
const onTrigger = (runtime: Runtime<Config>) => {
|
|
270
|
-
const client = new SolanaClient(SolanaClient.SUPPORTED_CHAIN_SELECTORS["solana-devnet"]);
|
|
271
|
-
const dataStorage = new DataStorage(client); // program ID baked in from the IDL
|
|
272
|
-
|
|
273
|
-
// remainingAccounts: forwarderState, forwarderAuthority PDA, then receiver accounts
|
|
274
|
-
const remainingAccounts = [
|
|
275
|
-
solanaAccountMeta(forwarderState),
|
|
276
|
-
solanaAccountMeta(forwarderAuthority),
|
|
277
|
-
solanaAccountMeta(receiverDataAccount, true),
|
|
278
|
-
];
|
|
279
|
-
|
|
280
|
-
const reply = dataStorage.writeReportFromUserData(
|
|
281
|
-
runtime,
|
|
282
|
-
{ key: "answer", value: "42" },
|
|
283
|
-
remainingAccounts,
|
|
284
|
-
);
|
|
285
|
-
runtime.log(`tx status: ${reply.txStatus}`);
|
|
286
|
-
};
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
In tests, intercept writes with the generated mock:
|
|
290
|
-
|
|
291
|
-
```typescript
|
|
292
|
-
import { SolanaMock } from "@chainlink/cre-sdk/test";
|
|
293
|
-
import { newDataStorageMock } from "../contracts/solana/ts/generated";
|
|
294
|
-
|
|
295
|
-
const solanaMock = SolanaMock.testInstance(chainSelector);
|
|
296
|
-
const dataStorage = newDataStorageMock(solanaMock);
|
|
297
|
-
dataStorage.writeReport = ({ report }) => ({ txStatus: "TX_STATUS_SUCCESS" });
|
|
298
|
-
```
|
|
299
|
-
|
|
300
240
|
## Configuration & Type Safety
|
|
301
241
|
|
|
302
242
|
You, the developer, must declare config files in config.json files, co-located with your TypeScript workflow definition.
|