[Prepaid Oracle Scripts]

This directory contains utility scripts for interacting with the Prepaid Oracle service on Canton. The two main scripts are:

## 1. create-request.sh

Creates a new prepaid oracle request by exercising the `CreateRequest` choice on a `RequestFactory` contract.

### Usage

```bash
./create-request.sh [--skip-config] [OPTIONS] [--help]
```

### Required Options
- `--factory-cid CID`            RequestFactory contract ID
- `--rules-cid CID`              AmuletRules contract ID
- `--mining-round-cid CID`       OpenMiningRound contract ID
- `--amulet-cid CID`             Consumer's Amulet contract ID
- `--consumer-party PARTY`       The consumer party (e.g., `Consumer::...`)
- `--oracle-party PARTY`         The oracle party (e.g., `Oracle::...`)
- `--dso-party PARTY`            The DSO party (e.g., `DSO::...`)
- `--catalog ID`                 Catalog ID
- `--locked-amount AMOUNT`       Locked amount in Amulet (e.g., `10.0`)
- `--provider-client-id ID`               Client ID for oracle access
- `--provider-client-secret SECRET`       Client secret for oracle access

### In-script options

Following options have to be updated directly in the script `create-request.sh`:

- `DATA_REQUEST`                 The body to be sent to Bloomberg
- `AMULET_RULES_BLOB`            Amulet rules created event blob
- `OPEN_MINING_ROUND_BLOB`       Open mining round created event blob

### Optional Options
- `--skip-config`                Skip loading config files
- `--help, -h`                   Show help message

### Example

```bash
./create-request.sh \
	--factory-cid "<FACTORY_CID>" \
	--rules-cid "<RULES_CID>" \
	--mining-round-cid "<MINING_ROUND_CID>" \
	--amulet-cid "<AMULET_CID>" \
	--consumer-party "Consumer::..." \
	--oracle-party "Oracle::..." \
	--dso-party "DSO::..." \
	--catalog "<CATALOG_ID>" \
	--locked-amount "10.0" \
	--provider-client-id "demo-client-id-123" \
	--provider-client-secret "demo-client-secret-123"
```

On success, the script will output the new request ID and related information.

---

## 2. read-response.sh

Reads the response for a prepaid oracle request by querying `FilledRequest` contracts and filtering by request ID.

### Usage

```bash
./read-response.sh [--skip-config] [OPTIONS] [--help]
```

### Required Options
- `--request-id ID`              The request ID to search for
- `--consumer-party PARTY`       The consumer party (e.g., `Consumer::...`)

### Optional Options
- `--offset OFFSET`              Active at offset (default: latest)
- `--template-id TEMPLATE_ID`    Custom FilledRequest template ID
- `--skip-config`                Skip loading config files
- `--help, -h`                   Show help message

### Example

```bash
./read-response.sh \
	--request-id "<REQUEST_ID>" \
	--consumer-party "Consumer::..." \
	--offset 681796
```

The script will output the `createArgument` object for the matching `FilledRequest` contract, which contains the oracle response data.

---

**Note:** Both scripts require the environment variables `PARTICIPANT_API_ENDPOINT` and `CANTON_TOKEN` to be set, either via a `.env` file or by sourcing `set_env.sh` in the current directory. Use `--skip-config` to skip loading these files if you set the variables manually.
