Skip to content

add Blockchain Applied (BCA) provider - #453

Open
CodiePP wants to merge 4 commits into
IntersectMBO:mainfrom
Blockchain-Data-Analytics:add-bca-provider
Open

CodiePP wants to merge 4 commits into
IntersectMBO:mainfrom
Blockchain-Data-Analytics:add-bca-provider

Conversation

@CodiePP

@CodiePP CodiePP commented Jul 14, 2026

Copy link
Copy Markdown

This PR adds Blockchain Applied (BCA) as a data provider and tx submit API.

@CodiePP
CodiePP force-pushed the add-bca-provider branch 2 times, most recently from 2fb7776 to 1d70875 Compare October 13, 2026 09:51

@solidsnakedev solidsnakedev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, and for moving it onto the new HTTP layer.

It needs another round before it can merge. A datum-hash output comes back as an inline datum, and no test runs without a BCA token. CI is green, but none of the provider code runs there, and we can't run the live suite ourselves.

Needed:

  1. Datum-hash outputs: when /datum/{hash} answers, resolveUtxo turns a hash-only output into an InlineDatum (BlockchainAppliedEffect.ts:84-91). Please return DatumHash for these, as Koios, Maestro and Kupmios do. Callers get the datum through getDatum. #687 tracks the same bug in Blockfrost.
  2. Offline tests: please add test/provider/BlockchainApplied.test.ts with fetch stubbed, like Maestro.test.ts, built from recorded BCA responses. Cover each method, pagination, the 404 paths, /tx/evaluate with additional_utxos, and the bearer header.
  3. Reference scripts: resolveUtxo swallows any /script failure (line 81), so the UTxO comes back without its script. The builder then leaves that script out of the reference script fee, and the node rejects the transaction. Please fail with a ProviderError instead. Also, ScriptDetails requires bytes and size, which the spec marks nullable, and your backend stores no CBOR for native scripts. The provider drops every native reference script that reaches this path. Please build it from json or fail.
  4. Cost models: please decode them strictly as arrays, as Koios does (Koios.ts:64-67). The object branch in normalizeCostModel keeps the server's key order, and that order gives a wrong script integrity hash (#303 was this failure in Blockfrost). This also removes the two Record<string, unknown> casts.
  5. Protocol parameters: a missing coins_per_utxo_size or min_fee_ref_script_cost_per_byte becomes 0 (BlockchainApplied.ts:232-241). That gives a minimum ADA of 0 and a reference script fee of 0. It also skips the builder's own fallback for the fee. Please fail instead, as Koios, Maestro and Kupmios do.
  6. awaitTx: please retry only on a 404, and decode only hash. Today a 401 keeps polling until the 160 s timeout and then fails as a timeout.
  7. Casts: as Redeemer.RedeemerTag (line 280) and as Provider.Delegation (BlockchainAppliedEffect.ts:217) both compile without the cast. Typing the schema field as Redeemer.RedeemerTag covers the first.

Questions about the API:

  • Is asset_name hex or text in the UTxO responses? The spec's /tx/{txhash} example shows "USDCx", which the provider can't decode. If it is hex, the example needs fixing.
  • Which tag strings does /tx/evaluate return for certificate and withdrawal scripts? If it passes publish and withdraw through, please map them as Kupmios and Koios do.
  • Does /utxos/{address} accept a payment credential (addr_vkh1..., script1...)? If not, please fail for credentials as Maestro does (MaestroEffect.ts:91-97). If it does, set supportsCredentialQueries: true in providers.test.ts.
  • Is reference_script_cbor filled for native scripts?

Smaller:

  • Every endpoint needs a token, so please make token required in the presets and the config.
  • provider-types.mdx, providers/index.mdx and the README still list four providers. Please update them, or leave the docs to a follow-up PR. In the table, a use case such as "Hosted REST API, bearer token" fits the other rows better.
  • Please drop the formatting-only changes in conformance.ts, providers.test.ts, client/internal/Client.ts and the docs, and the **/*.local line in .gitignore.
  • Please make the changeset a patch.

Signed-off-by: Alexander Diemand <codieplusplus@apax.net>
…xact integers

Upstream dropped @effect/platform (IntersectMBO#548) and now hands every JSON number to
the response schemas as its source text (IntersectMBO#558).

- Detect 404s via HttpUtils.HttpResponseError instead of HttpClientError
- Decode integer fields with Schema.BigInt and decimals with
  Schema.NumberFromString; convert to number only where the public
  ProtocolParameters / EvalRedeemer types require it
- Keep the evaluate request's additional_utxos wire format unchanged via an
  explicit AdditionalUtxo type
- Make total_count / total_pages optional: the API no longer returns them,
  and pagination only relies on has_next

Signed-off-by: Alexander Diemand <codieplusplus@apax.net>
Signed-off-by: Alexander Diemand <codieplusplus@apax.net>
Signed-off-by: Alexander Diemand <codieplusplus@apax.net>
@CodiePP

CodiePP commented Nov 12, 2026

Copy link
Copy Markdown
Author

Thanks for this, and for moving it onto the new HTTP layer.

It needs another round before it can merge. A datum-hash output comes back as an inline datum, and no test runs without a BCA token. CI is green, but none of the provider code runs there, and we can't run the live suite ourselves.

Needed:

1. Datum-hash outputs: when `/datum/{hash}` answers, `resolveUtxo` turns a hash-only output into an `InlineDatum` (`BlockchainAppliedEffect.ts:84-91`). Please return `DatumHash` for these, as Koios, Maestro and Kupmios do. Callers get the datum through `getDatum`. [Blockfrost reports datum-hash UTxOs as inline datums #687](https://github.com/IntersectMBO/evolution-sdk/issues/687) tracks the same bug in Blockfrost.

2. Offline tests: please add `test/provider/BlockchainApplied.test.ts` with fetch stubbed, like `Maestro.test.ts`, built from recorded BCA responses. Cover each method, pagination, the 404 paths, `/tx/evaluate` with `additional_utxos`, and the bearer header.

3. Reference scripts: `resolveUtxo` swallows any `/script` failure (line 81), so the UTxO comes back without its script. The builder then leaves that script out of the reference script fee, and the node rejects the transaction. Please fail with a `ProviderError` instead. Also, `ScriptDetails` requires `bytes` and `size`, which the spec marks nullable, and your backend stores no CBOR for native scripts. The provider drops every native reference script that reaches this path. Please build it from `json` or fail.

4. Cost models: please decode them strictly as arrays, as Koios does (`Koios.ts:64-67`). The object branch in `normalizeCostModel` keeps the server's key order, and that order gives a wrong script integrity hash ([Blockfrost provider reads legacy cost_models instead of cost_models_raw — causes ScriptIntegrityHashMismatch on Conway/Plomin #303](https://github.com/IntersectMBO/evolution-sdk/issues/303) was this failure in Blockfrost). This also removes the two `Record<string, unknown>` casts.

5. Protocol parameters: a missing `coins_per_utxo_size` or `min_fee_ref_script_cost_per_byte` becomes 0 (`BlockchainApplied.ts:232-241`). That gives a minimum ADA of 0 and a reference script fee of 0. It also skips the builder's own fallback for the fee. Please fail instead, as Koios, Maestro and Kupmios do.

6. `awaitTx`: please retry only on a 404, and decode only `hash`. Today a 401 keeps polling until the 160 s timeout and then fails as a timeout.

7. Casts: `as Redeemer.RedeemerTag` (line 280) and `as Provider.Delegation` (`BlockchainAppliedEffect.ts:217`) both compile without the cast. Typing the schema field as `Redeemer.RedeemerTag` covers the first.

Questions about the API:

* Is `asset_name` hex or text in the UTxO responses? The spec's `/tx/{txhash}` example shows `"USDCx"`, which the provider can't decode. If it is hex, the example needs fixing.

* Which tag strings does `/tx/evaluate` return for certificate and withdrawal scripts? If it passes `publish` and `withdraw` through, please map them as Kupmios and Koios do.

* Does `/utxos/{address}` accept a payment credential (`addr_vkh1...`, `script1...`)? If not, please fail for credentials as Maestro does (`MaestroEffect.ts:91-97`). If it does, set `supportsCredentialQueries: true` in `providers.test.ts`.

* Is `reference_script_cbor` filled for native scripts?

Smaller:

* Every endpoint needs a token, so please make `token` required in the presets and the config.

* `provider-types.mdx`, `providers/index.mdx` and the README still list four providers. Please update them, or leave the docs to a follow-up PR. In the table, a use case such as "Hosted REST API, bearer token" fits the other rows better.

* Please drop the formatting-only changes in `conformance.ts`, `providers.test.ts`, `client/internal/Client.ts` and the docs, and the `**/*.local` line in `.gitignore`.

* Please make the changeset a patch.

Thank you for this great review. I have addressed all points and describe them below.

Needed

  1. Hash-only outputs stay DatumHash
  2. BlockchainApplied.test.ts uses recorded Preprod responses. It covers every method, pagination via has_next, the 404 paths, evaluate with additional_utxos, and the bearer header.
  3. Fails with ProviderError when CBOR is missing or can’t be decoded.
  4. Strict arrays, same as Koios.
  5. All fields required.
  6. Retries only on 404 and decodes only hash
  7. casts are gone.

API questions

  • asset_name is hex in every UTxO response. The /tx/{txhash} example in the spec has been fixed ("5553444378").
  • reference_script_cbor is filled for native scripts: the API rebuilds the CBOR from db-sync’s JSON and checks it against the script hash. If they don’t match, the field is null, and the provider fails with a ProviderError.
  • /tx/evaluate returns cert and reward as tags: the live cert (PlutusV3) and spend/mint/reward tests decode them.
  • /utxos/{address} accepts addr_vkh1… and script1…: both live credential tests pass, and supportsCredentialQueries is true.

Smaller

  • token required: set in the presets, the constructor and BlockchainAppliedConfig
  • documents updated (five providers now)
  • reverted the formatting changes so only additions remain
  • it now is a patch

Test error

I ran the tests locally against the API and saw one failing: evaluateTx with a different step number. Koios also fails this one in the same way.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants