@cardananium/cquisitor-lib 0.1.0-beta.47 → 0.1.0-beta.49
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 +47 -7
- package/browser/cquisitor_lib.d.ts +33 -10
- package/browser/cquisitor_lib.js +1 -1
- package/browser/cquisitor_lib_bg.js +165 -0
- package/browser/cquisitor_lib_bg.wasm +0 -0
- package/browser/cquisitor_lib_bg.wasm.d.ts +10 -5
- package/node/cquisitor_lib.d.ts +33 -10
- package/node/cquisitor_lib.js +170 -0
- package/node/cquisitor_lib_bg.wasm +0 -0
- package/node/cquisitor_lib_bg.wasm.d.ts +10 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,8 +25,9 @@ Functions:
|
|
|
25
25
|
### CBOR Decoder & CDDL Validation
|
|
26
26
|
|
|
27
27
|
- `cbor_to_json(cbor_hex)` - Converts raw CBOR to JSON with positional information, supporting indefinite arrays/maps and all CBOR types. Each node carries an optional `oddities` array flagging deviations from RFC 8949 deterministic encoding (overlong integers/floats, indefinite length, unsorted/duplicate map keys, non-canonical bignums). Never throws on malformed input — returns a `{ok, value}` / `{ok: false, error, partial?}` union where `error` is a structured `CborDecodeError` (kind / byte offset / byte span / semantic `path`) and `partial` is the sub-tree decoded before the failure, with every unfinished container flagged `incomplete: true`.
|
|
28
|
-
- `validate_cddl(cddl)` - Parses a CDDL schema and
|
|
29
|
-
- `validate_cbor_against_cddl(cbor_hex, cddl, rule_name)` - Validates CBOR payload against a
|
|
28
|
+
- `validate_cddl(cddl)` - Parses a CDDL schema; reports parse errors and unresolved rule references (e.g. `thing = [unknown_rule, int]` → `kind: "unresolved_references"`).
|
|
29
|
+
- `validate_cbor_against_cddl(cbor_hex, cddl, rule_name)` - Validates a CBOR payload against a named rule. Errors carry `kind`, `expected`, semantic `path`, byte/anchor spans, and an `additional` array when multiple violations fire.
|
|
30
|
+
- `decode_cbor_against_cddl(cbor_hex, cddl, rule_name)` - Maps decoded CBOR onto a CDDL schema and returns labelled JSON (e.g. Cardano `[body, witness_set, bool, aux]` becomes `{transaction_body, transaction_witness_set, ...}`). Handles generics (`set<a>`), tagged sets, type rules used as field labels, and a few well-known tags (bignum → string number, datetime → ISO string). Sub-structures the schema doesn't cover surface under `@extra` / `@positional` so partial matches don't lose data.
|
|
30
31
|
|
|
31
32
|
### Plutus Script Decoder
|
|
32
33
|
|
|
@@ -339,22 +340,61 @@ See `CborOddityKind` and `CborDecodeErrorKind` in the type definitions for the f
|
|
|
339
340
|
|
|
340
341
|
#### `validate_cddl(cddl: string): { valid: boolean, error?: object }`
|
|
341
342
|
|
|
342
|
-
Parses a CDDL schema and reports whether it is well-formed.
|
|
343
|
+
Parses a CDDL schema and reports whether it is well-formed. Beyond surface parse errors this also catches **dangling rule references** at parse time, surfaced as `kind: "unresolved_references"`.
|
|
343
344
|
|
|
344
345
|
```typescript
|
|
345
|
-
|
|
346
|
+
validate_cddl("thing = {n: uint}");
|
|
346
347
|
// { valid: true }
|
|
348
|
+
|
|
349
|
+
validate_cddl("thing = [unknown_rule, int]");
|
|
350
|
+
// { valid: false, error: { kind: "unresolved_references",
|
|
351
|
+
// message: "missing definition for rule unknown_rule" } }
|
|
347
352
|
```
|
|
348
353
|
|
|
354
|
+
`error.kind` values: `"parse_error"`, `"unresolved_references"`.
|
|
355
|
+
|
|
349
356
|
#### `validate_cbor_against_cddl(cbor_hex: string, cddl: string, rule_name: string): { valid: boolean, error?: object }`
|
|
350
357
|
|
|
351
|
-
Validates a CBOR payload against a specific rule in a CDDL schema.
|
|
358
|
+
Validates a CBOR payload against a specific rule in a CDDL schema. The rule does not have to be the first rule in the document — when it isn't, the validator wraps it in a synthetic root internally.
|
|
352
359
|
|
|
353
360
|
```typescript
|
|
354
|
-
|
|
355
|
-
// {
|
|
361
|
+
validate_cbor_against_cddl("01", "thing = tstr", "thing");
|
|
362
|
+
// {
|
|
363
|
+
// valid: false,
|
|
364
|
+
// error: {
|
|
365
|
+
// kind: "mismatch",
|
|
366
|
+
// expected: "tstr",
|
|
367
|
+
// path: "$",
|
|
368
|
+
// byte_spans: [{ offset: 0, length: 1 }],
|
|
369
|
+
// message: "expected type tstr, got Integer(Integer(1))"
|
|
370
|
+
// }
|
|
371
|
+
// }
|
|
356
372
|
```
|
|
357
373
|
|
|
374
|
+
`error.kind` values: `"parse_error"`, `"unresolved_references"`, `"missing_rule"`, `"input_parse"`, `"mismatch"`, `"map_cut"`, `"generic"`. When multiple violations fire, the headline goes in the top-level fields and the rest land in `error.additional`.
|
|
375
|
+
|
|
376
|
+
#### `decode_cbor_against_cddl(cbor_hex: string, cddl: string, rule_name: string): unknown`
|
|
377
|
+
|
|
378
|
+
Walks the CDDL alongside the decoded CBOR and produces a JSON tree where positional/numeric-keyed structures are replaced with the names the schema declares. Useful for turning a Cardano transaction CBOR into something inspectable without hand-mapping every field.
|
|
379
|
+
|
|
380
|
+
```typescript
|
|
381
|
+
decode_cbor_against_cddl(txHex, conwayCddl, "transaction");
|
|
382
|
+
// {
|
|
383
|
+
// transaction_body: {
|
|
384
|
+
// 0: { "@tag": 258, "@value": [{ transaction_id: "16b6...", index: 0 }] },
|
|
385
|
+
// 1: [{ address: "00ae...", amount: 1_000_000 }, ...],
|
|
386
|
+
// 2: 200000,
|
|
387
|
+
// 7: "bdaa..."
|
|
388
|
+
// },
|
|
389
|
+
// transaction_witness_set: {
|
|
390
|
+
// 0: { "@tag": 258, "@value": [{ vkey: "f8f5...", signature: "1e14..." }] }
|
|
391
|
+
// },
|
|
392
|
+
// "@positional": [true, { "@tag": 259, "@value": {} }]
|
|
393
|
+
// }
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
Recognised features: type choices (first match wins), generics (`set<a>`), tagged data (well-known tags 0/2/3 specialised to ISO date / bignum string), rule references, optionals/repetitions, prelude scalars. Sub-structures the schema doesn't cover or that don't match any choice fall back to a raw form under `@extra` (maps) or `@positional` (arrays) so data is never silently dropped.
|
|
397
|
+
|
|
358
398
|
### Plutus Script Decoder
|
|
359
399
|
|
|
360
400
|
#### `decode_plutus_program_uplc_json(hex: string): ProgramJson`
|
|
@@ -146,18 +146,20 @@ export interface CborDecodeError {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
/**
|
|
149
|
-
* Validates a CDDL schema
|
|
150
|
-
*
|
|
151
|
-
*
|
|
149
|
+
* Validates a CDDL schema. Returns `{ valid: true }` if the schema parses
|
|
150
|
+
* **and** every rule reference resolves; otherwise `{ valid: false, error }`.
|
|
151
|
+
* Undefined rule references come back with `kind: "unresolved_references"`
|
|
152
|
+
* (e.g. `thing = [unknown_rule, int]`).
|
|
152
153
|
* @param {string} cddl
|
|
153
154
|
* @returns {any}
|
|
154
155
|
*/
|
|
155
156
|
export function validate_cddl(cddl: string): CddlValidationResult;
|
|
156
157
|
|
|
157
158
|
/**
|
|
158
|
-
* Validates CBOR bytes against a rule in the given CDDL schema. On failure
|
|
159
|
-
* `error` describes the mismatch, including a semantic path
|
|
160
|
-
* in the input that produced it
|
|
159
|
+
* Validates CBOR bytes against a rule in the given CDDL schema. On failure
|
|
160
|
+
* `error` describes the mismatch, including a semantic `path`, the byte
|
|
161
|
+
* spans in the input that produced it, and (when several validation
|
|
162
|
+
* errors fire) an `additional` array with the rest.
|
|
161
163
|
* @param {string} cbor_hex
|
|
162
164
|
* @param {string} cddl
|
|
163
165
|
* @param {string} rule_name
|
|
@@ -169,6 +171,28 @@ export function validate_cbor_against_cddl(
|
|
|
169
171
|
rule_name: string
|
|
170
172
|
): CborValidationResult;
|
|
171
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Maps decoded CBOR onto a CDDL schema and returns labelled JSON. Where
|
|
176
|
+
* `cbor_to_json` returns positional CBOR (numeric map keys, raw arrays),
|
|
177
|
+
* this walks the schema in parallel and replaces them with the named
|
|
178
|
+
* fields the CDDL declares — turning Cardano shapes like
|
|
179
|
+
* `[transaction_body, transaction_witness_set, bool, ...]` into
|
|
180
|
+
* `{transaction_body: {...}, transaction_witness_set: {...}, ...}`.
|
|
181
|
+
*
|
|
182
|
+
* Sub-structures the schema doesn't cover fall back to a raw
|
|
183
|
+
* representation (under `@extra` for maps / `@positional` for arrays),
|
|
184
|
+
* so partial matches still yield useful output.
|
|
185
|
+
* @param {string} cbor_hex
|
|
186
|
+
* @param {string} cddl
|
|
187
|
+
* @param {string} rule_name
|
|
188
|
+
* @returns {any}
|
|
189
|
+
*/
|
|
190
|
+
export function decode_cbor_against_cddl(
|
|
191
|
+
cbor_hex: string,
|
|
192
|
+
cddl: string,
|
|
193
|
+
rule_name: string
|
|
194
|
+
): unknown;
|
|
195
|
+
|
|
172
196
|
export function check_block_or_tx_signatures(hex_str: string): CheckSignaturesResult;
|
|
173
197
|
|
|
174
198
|
/**
|
|
@@ -393,13 +417,12 @@ export type CborValidationResult =
|
|
|
393
417
|
/**
|
|
394
418
|
* `kind` categorises the failure:
|
|
395
419
|
* - "parse_error" — the CDDL itself failed to parse
|
|
396
|
-
* - "
|
|
397
|
-
* - "missing_rule" — the
|
|
398
|
-
* - "unsupported" — the CDDL uses a feature cddl-cat doesn't implement
|
|
399
|
-
* - "value_error" — a CBOR value cannot be validated
|
|
420
|
+
* - "unresolved_references" — the CDDL references a rule name that isn't defined
|
|
421
|
+
* - "missing_rule" — the rule name passed to `validate_cbor_against_cddl` is not in the CDDL
|
|
400
422
|
* - "input_parse" — the CBOR bytes themselves are malformed
|
|
401
423
|
* - "mismatch" / "map_cut" — a data mismatch; inspect `expected`, `path`,
|
|
402
424
|
* `byte_spans`, and `anchor_spans` for precise locations
|
|
425
|
+
* - "generic" — anything that didn't fit one of the buckets above
|
|
403
426
|
*/
|
|
404
427
|
export interface CborValidationErrorInfo {
|
|
405
428
|
kind: string;
|
package/browser/cquisitor_lib.js
CHANGED
|
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./cquisitor_lib_bg.js";
|
|
|
5
5
|
__wbg_set_wasm(wasm);
|
|
6
6
|
wasm.__wbindgen_start();
|
|
7
7
|
export {
|
|
8
|
-
Address, AddressKind, Anchor, AnchorDataHash, AssetName, AssetNames, Assets, AuxiliaryData, AuxiliaryDataHash, AuxiliaryDataSet, BaseAddress, BigInt, BigNum, Bip32PrivateKey, Bip32PublicKey, Block, BlockEra, BlockHash, BootstrapWitness, BootstrapWitnesses, ByronAddress, ByronAddressType, CborContainerType, CborSetType, Certificate, CertificateKind, Certificates, CertificatesBuilder, ChangeConfig, CoinSelectionStrategyCIP2, Committee, CommitteeColdResign, CommitteeHotAuth, Constitution, ConstrPlutusData, CostModel, Costmdls, CredKind, Credential, Credentials, DNSRecordAorAAAA, DNSRecordSRV, DRep, DRepDeregistration, DRepKind, DRepRegistration, DRepUpdate, DRepVotingThresholds, DataCost, DataHash, DatumSource, Ed25519KeyHash, Ed25519KeyHashes, Ed25519Signature, EnterpriseAddress, ExUnitPrices, ExUnits, FixedBlock, FixedTransaction, FixedTransactionBodies, FixedTransactionBody, FixedTxWitnessesSet, FixedVersionedBlock, GeneralTransactionMetadata, GenesisDelegateHash, GenesisHash, GenesisHashes, GenesisKeyDelegation, GovernanceAction, GovernanceActionId, GovernanceActionIds, GovernanceActionKind, HardForkInitiationAction, Header, HeaderBody, InfoAction, Int, Ipv4, Ipv6, KESSignature, KESVKey, Language, LanguageKind, Languages, LegacyDaedalusPrivateKey, LinearFee, MIRKind, MIRPot, MIRToStakeCredentials, MalformedAddress, MetadataJsonSchema, MetadataList, MetadataMap, Mint, MintAssets, MintBuilder, MintWitness, MintsAssets, MoveInstantaneousReward, MoveInstantaneousRewardsCert, MultiAsset, MultiHostName, NativeScript, NativeScriptKind, NativeScriptSource, NativeScripts, NetworkId, NetworkIdKind, NetworkInfo, NewConstitutionAction, NoConfidenceAction, Nonce, OperationalCert, OutputDatum, ParameterChangeAction, PlutusData, PlutusDataKind, PlutusDatumSchema, PlutusList, PlutusMap, PlutusMapValues, PlutusScript, PlutusScriptSource, PlutusScripts, PlutusWitness, PlutusWitnesses, Pointer, PointerAddress, PoolMetadata, PoolMetadataHash, PoolParams, PoolRegistration, PoolRetirement, PoolVotingThresholds, PrivateKey, ProposedProtocolParameterUpdates, ProtocolParamUpdate, ProtocolVersion, PublicKey, PublicKeys, Redeemer, RedeemerTag, RedeemerTagKind, Redeemers, Relay, RelayKind, Relays, RewardAddress, RewardAddresses, ScriptAll, ScriptAny, ScriptDataHash, ScriptHash, ScriptHashNamespace, ScriptHashes, ScriptNOfK, ScriptPubkey, ScriptRef, ScriptSchema, SingleHostAddr, SingleHostName, StakeAndVoteDelegation, StakeDelegation, StakeDeregistration, StakeRegistration, StakeRegistrationAndDelegation, StakeVoteRegistrationAndDelegation, Strings, TimelockExpiry, TimelockStart, Transaction, TransactionBatch, TransactionBatchList, TransactionBodies, TransactionBody, TransactionBuilder, TransactionBuilderConfig, TransactionBuilderConfigBuilder, TransactionHash, TransactionInput, TransactionInputs, TransactionMetadatum, TransactionMetadatumKind, TransactionMetadatumLabels, TransactionOutput, TransactionOutputAmountBuilder, TransactionOutputBuilder, TransactionOutputs, TransactionSetsState, TransactionUnspentOutput, TransactionUnspentOutputs, TransactionWitnessSet, TransactionWitnessSets, TreasuryWithdrawals, TreasuryWithdrawalsAction, TxInputsBuilder, URL, UnitInterval, Update, UpdateCommitteeAction, VRFCert, VRFKeyHash, VRFVKey, Value, VersionedBlock, Vkey, Vkeys, Vkeywitness, Vkeywitnesses, VoteDelegation, VoteKind, VoteRegistrationAndDelegation, Voter, VoterKind, Voters, VotingBuilder, VotingProcedure, VotingProcedures, VotingProposal, VotingProposalBuilder, VotingProposals, Withdrawals, WithdrawalsBuilder, calculate_ex_units_ceil_cost, cbor_to_json, check_block_or_tx_signatures, create_send_all, decode_arbitrary_bytes_from_metadatum, decode_metadatum_to_json_str, decode_plutus_datum_to_json_str, decode_plutus_program_pretty_uplc, decode_plutus_program_uplc_json, decode_specific_type, decrypt_with_password, encode_arbitrary_bytes_as_metadatum, encode_json_str_to_metadatum, encode_json_str_to_native_script, encode_json_str_to_plutus_datum, encrypt_with_password, execute_tx_scripts, extract_hashes_from_transaction_js, get_decodable_types, get_deposit, get_implicit_input, get_necessary_data_list_js, get_possible_types_for_input, get_ref_script_bytes, get_utxo_list_from_tx, has_transaction_set_tag, hash_auxiliary_data, hash_plutus_data, hash_script_data, make_daedalus_bootstrap_witness, make_icarus_bootstrap_witness, make_vkey_witness, min_ada_for_output, min_fee, min_ref_script_fee, min_script_fee, validate_cbor_against_cddl, validate_cddl, validate_transaction_js
|
|
8
|
+
Address, AddressKind, Anchor, AnchorDataHash, AssetName, AssetNames, Assets, AuxiliaryData, AuxiliaryDataHash, AuxiliaryDataSet, BaseAddress, BigInt, BigNum, Bip32PrivateKey, Bip32PublicKey, Block, BlockEra, BlockHash, BootstrapWitness, BootstrapWitnesses, ByronAddress, ByronAddressType, CborContainerType, CborSetType, Certificate, CertificateKind, Certificates, CertificatesBuilder, ChangeConfig, CoinSelectionStrategyCIP2, Committee, CommitteeColdResign, CommitteeHotAuth, Constitution, ConstrPlutusData, CostModel, Costmdls, CredKind, Credential, Credentials, DNSRecordAorAAAA, DNSRecordSRV, DRep, DRepDeregistration, DRepKind, DRepRegistration, DRepUpdate, DRepVotingThresholds, DataCost, DataHash, DatumSource, Ed25519KeyHash, Ed25519KeyHashes, Ed25519Signature, EnterpriseAddress, ExUnitPrices, ExUnits, FixedBlock, FixedTransaction, FixedTransactionBodies, FixedTransactionBody, FixedTxWitnessesSet, FixedVersionedBlock, GeneralTransactionMetadata, GenesisDelegateHash, GenesisHash, GenesisHashes, GenesisKeyDelegation, GovernanceAction, GovernanceActionId, GovernanceActionIds, GovernanceActionKind, HardForkInitiationAction, Header, HeaderBody, InfoAction, Int, Ipv4, Ipv6, KESSignature, KESVKey, Language, LanguageKind, Languages, LegacyDaedalusPrivateKey, LinearFee, MIRKind, MIRPot, MIRToStakeCredentials, MalformedAddress, MetadataJsonSchema, MetadataList, MetadataMap, Mint, MintAssets, MintBuilder, MintWitness, MintsAssets, MoveInstantaneousReward, MoveInstantaneousRewardsCert, MultiAsset, MultiHostName, NativeScript, NativeScriptKind, NativeScriptSource, NativeScripts, NetworkId, NetworkIdKind, NetworkInfo, NewConstitutionAction, NoConfidenceAction, Nonce, OperationalCert, OutputDatum, ParameterChangeAction, PlutusData, PlutusDataKind, PlutusDatumSchema, PlutusList, PlutusMap, PlutusMapValues, PlutusScript, PlutusScriptSource, PlutusScripts, PlutusWitness, PlutusWitnesses, Pointer, PointerAddress, PoolMetadata, PoolMetadataHash, PoolParams, PoolRegistration, PoolRetirement, PoolVotingThresholds, PrivateKey, ProposedProtocolParameterUpdates, ProtocolParamUpdate, ProtocolVersion, PublicKey, PublicKeys, Redeemer, RedeemerTag, RedeemerTagKind, Redeemers, Relay, RelayKind, Relays, RewardAddress, RewardAddresses, ScriptAll, ScriptAny, ScriptDataHash, ScriptHash, ScriptHashNamespace, ScriptHashes, ScriptNOfK, ScriptPubkey, ScriptRef, ScriptSchema, SingleHostAddr, SingleHostName, StakeAndVoteDelegation, StakeDelegation, StakeDeregistration, StakeRegistration, StakeRegistrationAndDelegation, StakeVoteRegistrationAndDelegation, Strings, TimelockExpiry, TimelockStart, Transaction, TransactionBatch, TransactionBatchList, TransactionBodies, TransactionBody, TransactionBuilder, TransactionBuilderConfig, TransactionBuilderConfigBuilder, TransactionHash, TransactionInput, TransactionInputs, TransactionMetadatum, TransactionMetadatumKind, TransactionMetadatumLabels, TransactionOutput, TransactionOutputAmountBuilder, TransactionOutputBuilder, TransactionOutputs, TransactionSetsState, TransactionUnspentOutput, TransactionUnspentOutputs, TransactionWitnessSet, TransactionWitnessSets, TreasuryWithdrawals, TreasuryWithdrawalsAction, TxInputsBuilder, URL, UnitInterval, Update, UpdateCommitteeAction, VRFCert, VRFKeyHash, VRFVKey, Value, VersionedBlock, Vkey, Vkeys, Vkeywitness, Vkeywitnesses, VoteDelegation, VoteKind, VoteRegistrationAndDelegation, Voter, VoterKind, Voters, VotingBuilder, VotingProcedure, VotingProcedures, VotingProposal, VotingProposalBuilder, VotingProposals, Withdrawals, WithdrawalsBuilder, calculate_ex_units_ceil_cost, cbor_to_json, cddl_from_str, check_block_or_tx_signatures, create_send_all, decode_arbitrary_bytes_from_metadatum, decode_cbor_against_cddl, decode_metadatum_to_json_str, decode_plutus_datum_to_json_str, decode_plutus_program_pretty_uplc, decode_plutus_program_uplc_json, decode_specific_type, decrypt_with_password, encode_arbitrary_bytes_as_metadatum, encode_json_str_to_metadatum, encode_json_str_to_native_script, encode_json_str_to_plutus_datum, encrypt_with_password, execute_tx_scripts, extract_hashes_from_transaction_js, get_decodable_types, get_deposit, get_implicit_input, get_necessary_data_list_js, get_possible_types_for_input, get_ref_script_bytes, get_utxo_list_from_tx, has_transaction_set_tag, hash_auxiliary_data, hash_plutus_data, hash_script_data, make_daedalus_bootstrap_witness, make_icarus_bootstrap_witness, make_vkey_witness, min_ada_for_output, min_fee, min_ref_script_fee, min_script_fee, validate_cbor_against_cddl, validate_cbor_from_slice, validate_cddl, validate_cddl_from_str, validate_json_from_str, validate_transaction_js
|
|
9
9
|
} from "./cquisitor_lib_bg.js";
|
|
@@ -28456,6 +28456,38 @@ export function cbor_to_json(cbor_hex) {
|
|
|
28456
28456
|
return takeFromExternrefTable0(ret[0]);
|
|
28457
28457
|
}
|
|
28458
28458
|
|
|
28459
|
+
/**
|
|
28460
|
+
* Returns a `ast::CDDL` wrapped in `JsValue` from a `&str`
|
|
28461
|
+
*
|
|
28462
|
+
* # Arguments
|
|
28463
|
+
*
|
|
28464
|
+
* * `input` - A string slice with the CDDL text input
|
|
28465
|
+
*
|
|
28466
|
+
* # Example
|
|
28467
|
+
*
|
|
28468
|
+
* ```typescript
|
|
28469
|
+
* import * as wasm from 'cddl';
|
|
28470
|
+
*
|
|
28471
|
+
* let cddl: any;
|
|
28472
|
+
* try {
|
|
28473
|
+
* cddl = wasm.cddl_from_str(text);
|
|
28474
|
+
* } catch (e) {
|
|
28475
|
+
* console.error(e);
|
|
28476
|
+
* }
|
|
28477
|
+
* ```
|
|
28478
|
+
* @param {string} input
|
|
28479
|
+
* @returns {any}
|
|
28480
|
+
*/
|
|
28481
|
+
export function cddl_from_str(input) {
|
|
28482
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
28483
|
+
const len0 = WASM_VECTOR_LEN;
|
|
28484
|
+
const ret = wasm.cddl_from_str(ptr0, len0);
|
|
28485
|
+
if (ret[2]) {
|
|
28486
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
28487
|
+
}
|
|
28488
|
+
return takeFromExternrefTable0(ret[0]);
|
|
28489
|
+
}
|
|
28490
|
+
|
|
28459
28491
|
/**
|
|
28460
28492
|
* @param {string} hex_str
|
|
28461
28493
|
* @returns {any}
|
|
@@ -28502,6 +28534,33 @@ export function decode_arbitrary_bytes_from_metadatum(metadata) {
|
|
|
28502
28534
|
return v1;
|
|
28503
28535
|
}
|
|
28504
28536
|
|
|
28537
|
+
/**
|
|
28538
|
+
* Map decoded CBOR onto a CDDL schema and return labelled JSON.
|
|
28539
|
+
*
|
|
28540
|
+
* Where `cbor_to_json` returns positional CBOR (numeric map keys, raw
|
|
28541
|
+
* arrays), this walks the schema in parallel and replaces those with
|
|
28542
|
+
* the named fields the CDDL declares. On unknown / unmatched
|
|
28543
|
+
* sub-structures it falls back to the raw representation rather than
|
|
28544
|
+
* erroring, so partial matches still yield useful output.
|
|
28545
|
+
* @param {string} cbor_hex
|
|
28546
|
+
* @param {string} cddl
|
|
28547
|
+
* @param {string} rule_name
|
|
28548
|
+
* @returns {any}
|
|
28549
|
+
*/
|
|
28550
|
+
export function decode_cbor_against_cddl(cbor_hex, cddl, rule_name) {
|
|
28551
|
+
const ptr0 = passStringToWasm0(cbor_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
28552
|
+
const len0 = WASM_VECTOR_LEN;
|
|
28553
|
+
const ptr1 = passStringToWasm0(cddl, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
28554
|
+
const len1 = WASM_VECTOR_LEN;
|
|
28555
|
+
const ptr2 = passStringToWasm0(rule_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
28556
|
+
const len2 = WASM_VECTOR_LEN;
|
|
28557
|
+
const ret = wasm.decode_cbor_against_cddl(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
28558
|
+
if (ret[2]) {
|
|
28559
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
28560
|
+
}
|
|
28561
|
+
return takeFromExternrefTable0(ret[0]);
|
|
28562
|
+
}
|
|
28563
|
+
|
|
28505
28564
|
/**
|
|
28506
28565
|
* @param {TransactionMetadatum} metadatum
|
|
28507
28566
|
* @param {MetadataJsonSchema} schema
|
|
@@ -29087,6 +29146,27 @@ export function validate_cbor_against_cddl(cbor_hex, cddl, rule_name) {
|
|
|
29087
29146
|
return takeFromExternrefTable0(ret[0]);
|
|
29088
29147
|
}
|
|
29089
29148
|
|
|
29149
|
+
/**
|
|
29150
|
+
* Validate CBOR slice from a given CDDL document string
|
|
29151
|
+
* @param {string} cddl
|
|
29152
|
+
* @param {Uint8Array} cbor_slice
|
|
29153
|
+
* @param {any[] | null} [enabled_features]
|
|
29154
|
+
* @returns {any}
|
|
29155
|
+
*/
|
|
29156
|
+
export function validate_cbor_from_slice(cddl, cbor_slice, enabled_features) {
|
|
29157
|
+
const ptr0 = passStringToWasm0(cddl, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
29158
|
+
const len0 = WASM_VECTOR_LEN;
|
|
29159
|
+
const ptr1 = passArray8ToWasm0(cbor_slice, wasm.__wbindgen_malloc);
|
|
29160
|
+
const len1 = WASM_VECTOR_LEN;
|
|
29161
|
+
var ptr2 = isLikeNone(enabled_features) ? 0 : passArrayJsValueToWasm0(enabled_features, wasm.__wbindgen_malloc);
|
|
29162
|
+
var len2 = WASM_VECTOR_LEN;
|
|
29163
|
+
const ret = wasm.validate_cbor_from_slice(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
29164
|
+
if (ret[2]) {
|
|
29165
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
29166
|
+
}
|
|
29167
|
+
return takeFromExternrefTable0(ret[0]);
|
|
29168
|
+
}
|
|
29169
|
+
|
|
29090
29170
|
/**
|
|
29091
29171
|
* @param {string} cddl
|
|
29092
29172
|
* @returns {any}
|
|
@@ -29101,6 +29181,69 @@ export function validate_cddl(cddl) {
|
|
|
29101
29181
|
return takeFromExternrefTable0(ret[0]);
|
|
29102
29182
|
}
|
|
29103
29183
|
|
|
29184
|
+
/**
|
|
29185
|
+
* Validate CDDL input with partial compilation support.
|
|
29186
|
+
*
|
|
29187
|
+
* Unlike `cddl_from_str` which stops at the first error, this function
|
|
29188
|
+
* performs partial compilation: when the full document parse fails, it splits
|
|
29189
|
+
* the source into individual top-level rule blocks and parses each one
|
|
29190
|
+
* independently, collecting **all** errors across the entire document.
|
|
29191
|
+
*
|
|
29192
|
+
* When `check_refs` is `true`, the function also checks for undefined
|
|
29193
|
+
* references — names used in type expressions or group entries that are not
|
|
29194
|
+
* defined by any rule in the document and are not standard prelude types.
|
|
29195
|
+
* These are reported as warnings rather than errors.
|
|
29196
|
+
*
|
|
29197
|
+
* Returns a `JsValue` (serialised JSON array) containing all diagnostics found.
|
|
29198
|
+
* Each entry has `{ position, msg, severity }` where severity is `"error"` or `"warning"`.
|
|
29199
|
+
* An empty array means the input is valid CDDL with no warnings.
|
|
29200
|
+
*
|
|
29201
|
+
* # Example
|
|
29202
|
+
*
|
|
29203
|
+
* ```typescript
|
|
29204
|
+
* import * as wasm from 'cddl';
|
|
29205
|
+
*
|
|
29206
|
+
* const errors = wasm.validate_cddl_from_str(text, true);
|
|
29207
|
+
* // errors is an Array<{ position, msg, severity }>
|
|
29208
|
+
* if (errors.length === 0) {
|
|
29209
|
+
* console.log('Valid CDDL');
|
|
29210
|
+
* }
|
|
29211
|
+
* ```
|
|
29212
|
+
* @param {string} input
|
|
29213
|
+
* @param {boolean} check_refs
|
|
29214
|
+
* @returns {any}
|
|
29215
|
+
*/
|
|
29216
|
+
export function validate_cddl_from_str(input, check_refs) {
|
|
29217
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
29218
|
+
const len0 = WASM_VECTOR_LEN;
|
|
29219
|
+
const ret = wasm.validate_cddl_from_str(ptr0, len0, check_refs);
|
|
29220
|
+
if (ret[2]) {
|
|
29221
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
29222
|
+
}
|
|
29223
|
+
return takeFromExternrefTable0(ret[0]);
|
|
29224
|
+
}
|
|
29225
|
+
|
|
29226
|
+
/**
|
|
29227
|
+
* Validate JSON string from a given CDDL document string
|
|
29228
|
+
* @param {string} cddl
|
|
29229
|
+
* @param {string} json
|
|
29230
|
+
* @param {any[] | null} [enabled_features]
|
|
29231
|
+
* @returns {any}
|
|
29232
|
+
*/
|
|
29233
|
+
export function validate_json_from_str(cddl, json, enabled_features) {
|
|
29234
|
+
const ptr0 = passStringToWasm0(cddl, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
29235
|
+
const len0 = WASM_VECTOR_LEN;
|
|
29236
|
+
const ptr1 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
29237
|
+
const len1 = WASM_VECTOR_LEN;
|
|
29238
|
+
var ptr2 = isLikeNone(enabled_features) ? 0 : passArrayJsValueToWasm0(enabled_features, wasm.__wbindgen_malloc);
|
|
29239
|
+
var len2 = WASM_VECTOR_LEN;
|
|
29240
|
+
const ret = wasm.validate_json_from_str(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
29241
|
+
if (ret[2]) {
|
|
29242
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
29243
|
+
}
|
|
29244
|
+
return takeFromExternrefTable0(ret[0]);
|
|
29245
|
+
}
|
|
29246
|
+
|
|
29104
29247
|
/**
|
|
29105
29248
|
* @param {string} tx_hex
|
|
29106
29249
|
* @param {string} validation_context
|
|
@@ -29143,6 +29286,13 @@ export function __wbg_String_11905339415cf58e(arg0, arg1) {
|
|
|
29143
29286
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
29144
29287
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
29145
29288
|
}
|
|
29289
|
+
export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
29290
|
+
const ret = String(arg1);
|
|
29291
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
29292
|
+
const len1 = WASM_VECTOR_LEN;
|
|
29293
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
29294
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
29295
|
+
}
|
|
29146
29296
|
export function __wbg___wbindgen_bigint_get_as_i64_3d3aba5d616c6a51(arg0, arg1) {
|
|
29147
29297
|
const v = arg1;
|
|
29148
29298
|
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
@@ -29431,6 +29581,11 @@ export function __wbindgen_cast_0000000000000004(arg0, arg1) {
|
|
|
29431
29581
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
29432
29582
|
return ret;
|
|
29433
29583
|
}
|
|
29584
|
+
export function __wbindgen_cast_0000000000000005(arg0) {
|
|
29585
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
29586
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
29587
|
+
return ret;
|
|
29588
|
+
}
|
|
29434
29589
|
export function __wbindgen_init_externref_table() {
|
|
29435
29590
|
const table = wasm.__wbindgen_externrefs;
|
|
29436
29591
|
const offset = table.grow(4);
|
|
@@ -30186,6 +30341,16 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
30186
30341
|
return ptr;
|
|
30187
30342
|
}
|
|
30188
30343
|
|
|
30344
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
30345
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
30346
|
+
for (let i = 0; i < array.length; i++) {
|
|
30347
|
+
const add = addToExternrefTable0(array[i]);
|
|
30348
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
30349
|
+
}
|
|
30350
|
+
WASM_VECTOR_LEN = array.length;
|
|
30351
|
+
return ptr;
|
|
30352
|
+
}
|
|
30353
|
+
|
|
30189
30354
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
30190
30355
|
if (realloc === undefined) {
|
|
30191
30356
|
const buf = cachedTextEncoder.encode(arg);
|
|
Binary file
|
|
@@ -4,18 +4,23 @@ export const memory: WebAssembly.Memory;
|
|
|
4
4
|
export const decode_specific_type: (a: number, b: number, c: number, d: number, e: any) => [number, number, number];
|
|
5
5
|
export const get_decodable_types: () => [number, number];
|
|
6
6
|
export const get_possible_types_for_input: (a: number, b: number) => [number, number];
|
|
7
|
-
export const
|
|
7
|
+
export const cbor_to_json: (a: number, b: number) => [number, number, number];
|
|
8
|
+
export const decode_cbor_against_cddl: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
9
|
+
export const validate_cbor_against_cddl: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
10
|
+
export const validate_cddl: (a: number, b: number) => [number, number, number];
|
|
11
|
+
export const check_block_or_tx_signatures: (a: number, b: number) => [number, number, number];
|
|
8
12
|
export const get_necessary_data_list_js: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
9
13
|
export const validate_transaction_js: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
10
|
-
export const cbor_to_json: (a: number, b: number) => [number, number, number];
|
|
11
14
|
export const decode_plutus_program_pretty_uplc: (a: number, b: number) => [number, number, number, number];
|
|
12
15
|
export const decode_plutus_program_uplc_json: (a: number, b: number) => [number, number, number];
|
|
13
16
|
export const execute_tx_scripts: (a: number, b: number, c: any, d: any) => [number, number, number];
|
|
14
17
|
export const get_ref_script_bytes: (a: number, b: number, c: number) => [number, number, number, number];
|
|
15
18
|
export const get_utxo_list_from_tx: (a: number, b: number) => [number, number, number, number];
|
|
16
|
-
export const
|
|
17
|
-
export const
|
|
18
|
-
export const
|
|
19
|
+
export const extract_hashes_from_transaction_js: (a: number, b: number) => [number, number, number, number];
|
|
20
|
+
export const validate_cbor_from_slice: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
21
|
+
export const validate_json_from_str: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
22
|
+
export const cddl_from_str: (a: number, b: number) => [number, number, number];
|
|
23
|
+
export const validate_cddl_from_str: (a: number, b: number, c: number) => [number, number, number];
|
|
19
24
|
export const __wbg_bigint_free: (a: number, b: number) => void;
|
|
20
25
|
export const __wbg_certificatesbuilder_free: (a: number, b: number) => void;
|
|
21
26
|
export const __wbg_changeconfig_free: (a: number, b: number) => void;
|
package/node/cquisitor_lib.d.ts
CHANGED
|
@@ -146,18 +146,20 @@ export interface CborDecodeError {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
/**
|
|
149
|
-
* Validates a CDDL schema
|
|
150
|
-
*
|
|
151
|
-
*
|
|
149
|
+
* Validates a CDDL schema. Returns `{ valid: true }` if the schema parses
|
|
150
|
+
* **and** every rule reference resolves; otherwise `{ valid: false, error }`.
|
|
151
|
+
* Undefined rule references come back with `kind: "unresolved_references"`
|
|
152
|
+
* (e.g. `thing = [unknown_rule, int]`).
|
|
152
153
|
* @param {string} cddl
|
|
153
154
|
* @returns {any}
|
|
154
155
|
*/
|
|
155
156
|
export function validate_cddl(cddl: string): CddlValidationResult;
|
|
156
157
|
|
|
157
158
|
/**
|
|
158
|
-
* Validates CBOR bytes against a rule in the given CDDL schema. On failure
|
|
159
|
-
* `error` describes the mismatch, including a semantic path
|
|
160
|
-
* in the input that produced it
|
|
159
|
+
* Validates CBOR bytes against a rule in the given CDDL schema. On failure
|
|
160
|
+
* `error` describes the mismatch, including a semantic `path`, the byte
|
|
161
|
+
* spans in the input that produced it, and (when several validation
|
|
162
|
+
* errors fire) an `additional` array with the rest.
|
|
161
163
|
* @param {string} cbor_hex
|
|
162
164
|
* @param {string} cddl
|
|
163
165
|
* @param {string} rule_name
|
|
@@ -169,6 +171,28 @@ export function validate_cbor_against_cddl(
|
|
|
169
171
|
rule_name: string
|
|
170
172
|
): CborValidationResult;
|
|
171
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Maps decoded CBOR onto a CDDL schema and returns labelled JSON. Where
|
|
176
|
+
* `cbor_to_json` returns positional CBOR (numeric map keys, raw arrays),
|
|
177
|
+
* this walks the schema in parallel and replaces them with the named
|
|
178
|
+
* fields the CDDL declares — turning Cardano shapes like
|
|
179
|
+
* `[transaction_body, transaction_witness_set, bool, ...]` into
|
|
180
|
+
* `{transaction_body: {...}, transaction_witness_set: {...}, ...}`.
|
|
181
|
+
*
|
|
182
|
+
* Sub-structures the schema doesn't cover fall back to a raw
|
|
183
|
+
* representation (under `@extra` for maps / `@positional` for arrays),
|
|
184
|
+
* so partial matches still yield useful output.
|
|
185
|
+
* @param {string} cbor_hex
|
|
186
|
+
* @param {string} cddl
|
|
187
|
+
* @param {string} rule_name
|
|
188
|
+
* @returns {any}
|
|
189
|
+
*/
|
|
190
|
+
export function decode_cbor_against_cddl(
|
|
191
|
+
cbor_hex: string,
|
|
192
|
+
cddl: string,
|
|
193
|
+
rule_name: string
|
|
194
|
+
): unknown;
|
|
195
|
+
|
|
172
196
|
export function check_block_or_tx_signatures(hex_str: string): CheckSignaturesResult;
|
|
173
197
|
|
|
174
198
|
/**
|
|
@@ -393,13 +417,12 @@ export type CborValidationResult =
|
|
|
393
417
|
/**
|
|
394
418
|
* `kind` categorises the failure:
|
|
395
419
|
* - "parse_error" — the CDDL itself failed to parse
|
|
396
|
-
* - "
|
|
397
|
-
* - "missing_rule" — the
|
|
398
|
-
* - "unsupported" — the CDDL uses a feature cddl-cat doesn't implement
|
|
399
|
-
* - "value_error" — a CBOR value cannot be validated
|
|
420
|
+
* - "unresolved_references" — the CDDL references a rule name that isn't defined
|
|
421
|
+
* - "missing_rule" — the rule name passed to `validate_cbor_against_cddl` is not in the CDDL
|
|
400
422
|
* - "input_parse" — the CBOR bytes themselves are malformed
|
|
401
423
|
* - "mismatch" / "map_cut" — a data mismatch; inspect `expected`, `path`,
|
|
402
424
|
* `byte_spans`, and `anchor_spans` for precise locations
|
|
425
|
+
* - "generic" — anything that didn't fit one of the buckets above
|
|
403
426
|
*/
|
|
404
427
|
export interface CborValidationErrorInfo {
|
|
405
428
|
kind: string;
|
package/node/cquisitor_lib.js
CHANGED
|
@@ -28683,6 +28683,39 @@ function cbor_to_json(cbor_hex) {
|
|
|
28683
28683
|
}
|
|
28684
28684
|
exports.cbor_to_json = cbor_to_json;
|
|
28685
28685
|
|
|
28686
|
+
/**
|
|
28687
|
+
* Returns a `ast::CDDL` wrapped in `JsValue` from a `&str`
|
|
28688
|
+
*
|
|
28689
|
+
* # Arguments
|
|
28690
|
+
*
|
|
28691
|
+
* * `input` - A string slice with the CDDL text input
|
|
28692
|
+
*
|
|
28693
|
+
* # Example
|
|
28694
|
+
*
|
|
28695
|
+
* ```typescript
|
|
28696
|
+
* import * as wasm from 'cddl';
|
|
28697
|
+
*
|
|
28698
|
+
* let cddl: any;
|
|
28699
|
+
* try {
|
|
28700
|
+
* cddl = wasm.cddl_from_str(text);
|
|
28701
|
+
* } catch (e) {
|
|
28702
|
+
* console.error(e);
|
|
28703
|
+
* }
|
|
28704
|
+
* ```
|
|
28705
|
+
* @param {string} input
|
|
28706
|
+
* @returns {any}
|
|
28707
|
+
*/
|
|
28708
|
+
function cddl_from_str(input) {
|
|
28709
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
28710
|
+
const len0 = WASM_VECTOR_LEN;
|
|
28711
|
+
const ret = wasm.cddl_from_str(ptr0, len0);
|
|
28712
|
+
if (ret[2]) {
|
|
28713
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
28714
|
+
}
|
|
28715
|
+
return takeFromExternrefTable0(ret[0]);
|
|
28716
|
+
}
|
|
28717
|
+
exports.cddl_from_str = cddl_from_str;
|
|
28718
|
+
|
|
28686
28719
|
/**
|
|
28687
28720
|
* @param {string} hex_str
|
|
28688
28721
|
* @returns {any}
|
|
@@ -28732,6 +28765,34 @@ function decode_arbitrary_bytes_from_metadatum(metadata) {
|
|
|
28732
28765
|
}
|
|
28733
28766
|
exports.decode_arbitrary_bytes_from_metadatum = decode_arbitrary_bytes_from_metadatum;
|
|
28734
28767
|
|
|
28768
|
+
/**
|
|
28769
|
+
* Map decoded CBOR onto a CDDL schema and return labelled JSON.
|
|
28770
|
+
*
|
|
28771
|
+
* Where `cbor_to_json` returns positional CBOR (numeric map keys, raw
|
|
28772
|
+
* arrays), this walks the schema in parallel and replaces those with
|
|
28773
|
+
* the named fields the CDDL declares. On unknown / unmatched
|
|
28774
|
+
* sub-structures it falls back to the raw representation rather than
|
|
28775
|
+
* erroring, so partial matches still yield useful output.
|
|
28776
|
+
* @param {string} cbor_hex
|
|
28777
|
+
* @param {string} cddl
|
|
28778
|
+
* @param {string} rule_name
|
|
28779
|
+
* @returns {any}
|
|
28780
|
+
*/
|
|
28781
|
+
function decode_cbor_against_cddl(cbor_hex, cddl, rule_name) {
|
|
28782
|
+
const ptr0 = passStringToWasm0(cbor_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
28783
|
+
const len0 = WASM_VECTOR_LEN;
|
|
28784
|
+
const ptr1 = passStringToWasm0(cddl, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
28785
|
+
const len1 = WASM_VECTOR_LEN;
|
|
28786
|
+
const ptr2 = passStringToWasm0(rule_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
28787
|
+
const len2 = WASM_VECTOR_LEN;
|
|
28788
|
+
const ret = wasm.decode_cbor_against_cddl(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
28789
|
+
if (ret[2]) {
|
|
28790
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
28791
|
+
}
|
|
28792
|
+
return takeFromExternrefTable0(ret[0]);
|
|
28793
|
+
}
|
|
28794
|
+
exports.decode_cbor_against_cddl = decode_cbor_against_cddl;
|
|
28795
|
+
|
|
28735
28796
|
/**
|
|
28736
28797
|
* @param {TransactionMetadatum} metadatum
|
|
28737
28798
|
* @param {MetadataJsonSchema} schema
|
|
@@ -29349,6 +29410,28 @@ function validate_cbor_against_cddl(cbor_hex, cddl, rule_name) {
|
|
|
29349
29410
|
}
|
|
29350
29411
|
exports.validate_cbor_against_cddl = validate_cbor_against_cddl;
|
|
29351
29412
|
|
|
29413
|
+
/**
|
|
29414
|
+
* Validate CBOR slice from a given CDDL document string
|
|
29415
|
+
* @param {string} cddl
|
|
29416
|
+
* @param {Uint8Array} cbor_slice
|
|
29417
|
+
* @param {any[] | null} [enabled_features]
|
|
29418
|
+
* @returns {any}
|
|
29419
|
+
*/
|
|
29420
|
+
function validate_cbor_from_slice(cddl, cbor_slice, enabled_features) {
|
|
29421
|
+
const ptr0 = passStringToWasm0(cddl, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
29422
|
+
const len0 = WASM_VECTOR_LEN;
|
|
29423
|
+
const ptr1 = passArray8ToWasm0(cbor_slice, wasm.__wbindgen_malloc);
|
|
29424
|
+
const len1 = WASM_VECTOR_LEN;
|
|
29425
|
+
var ptr2 = isLikeNone(enabled_features) ? 0 : passArrayJsValueToWasm0(enabled_features, wasm.__wbindgen_malloc);
|
|
29426
|
+
var len2 = WASM_VECTOR_LEN;
|
|
29427
|
+
const ret = wasm.validate_cbor_from_slice(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
29428
|
+
if (ret[2]) {
|
|
29429
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
29430
|
+
}
|
|
29431
|
+
return takeFromExternrefTable0(ret[0]);
|
|
29432
|
+
}
|
|
29433
|
+
exports.validate_cbor_from_slice = validate_cbor_from_slice;
|
|
29434
|
+
|
|
29352
29435
|
/**
|
|
29353
29436
|
* @param {string} cddl
|
|
29354
29437
|
* @returns {any}
|
|
@@ -29364,6 +29447,71 @@ function validate_cddl(cddl) {
|
|
|
29364
29447
|
}
|
|
29365
29448
|
exports.validate_cddl = validate_cddl;
|
|
29366
29449
|
|
|
29450
|
+
/**
|
|
29451
|
+
* Validate CDDL input with partial compilation support.
|
|
29452
|
+
*
|
|
29453
|
+
* Unlike `cddl_from_str` which stops at the first error, this function
|
|
29454
|
+
* performs partial compilation: when the full document parse fails, it splits
|
|
29455
|
+
* the source into individual top-level rule blocks and parses each one
|
|
29456
|
+
* independently, collecting **all** errors across the entire document.
|
|
29457
|
+
*
|
|
29458
|
+
* When `check_refs` is `true`, the function also checks for undefined
|
|
29459
|
+
* references — names used in type expressions or group entries that are not
|
|
29460
|
+
* defined by any rule in the document and are not standard prelude types.
|
|
29461
|
+
* These are reported as warnings rather than errors.
|
|
29462
|
+
*
|
|
29463
|
+
* Returns a `JsValue` (serialised JSON array) containing all diagnostics found.
|
|
29464
|
+
* Each entry has `{ position, msg, severity }` where severity is `"error"` or `"warning"`.
|
|
29465
|
+
* An empty array means the input is valid CDDL with no warnings.
|
|
29466
|
+
*
|
|
29467
|
+
* # Example
|
|
29468
|
+
*
|
|
29469
|
+
* ```typescript
|
|
29470
|
+
* import * as wasm from 'cddl';
|
|
29471
|
+
*
|
|
29472
|
+
* const errors = wasm.validate_cddl_from_str(text, true);
|
|
29473
|
+
* // errors is an Array<{ position, msg, severity }>
|
|
29474
|
+
* if (errors.length === 0) {
|
|
29475
|
+
* console.log('Valid CDDL');
|
|
29476
|
+
* }
|
|
29477
|
+
* ```
|
|
29478
|
+
* @param {string} input
|
|
29479
|
+
* @param {boolean} check_refs
|
|
29480
|
+
* @returns {any}
|
|
29481
|
+
*/
|
|
29482
|
+
function validate_cddl_from_str(input, check_refs) {
|
|
29483
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
29484
|
+
const len0 = WASM_VECTOR_LEN;
|
|
29485
|
+
const ret = wasm.validate_cddl_from_str(ptr0, len0, check_refs);
|
|
29486
|
+
if (ret[2]) {
|
|
29487
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
29488
|
+
}
|
|
29489
|
+
return takeFromExternrefTable0(ret[0]);
|
|
29490
|
+
}
|
|
29491
|
+
exports.validate_cddl_from_str = validate_cddl_from_str;
|
|
29492
|
+
|
|
29493
|
+
/**
|
|
29494
|
+
* Validate JSON string from a given CDDL document string
|
|
29495
|
+
* @param {string} cddl
|
|
29496
|
+
* @param {string} json
|
|
29497
|
+
* @param {any[] | null} [enabled_features]
|
|
29498
|
+
* @returns {any}
|
|
29499
|
+
*/
|
|
29500
|
+
function validate_json_from_str(cddl, json, enabled_features) {
|
|
29501
|
+
const ptr0 = passStringToWasm0(cddl, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
29502
|
+
const len0 = WASM_VECTOR_LEN;
|
|
29503
|
+
const ptr1 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
29504
|
+
const len1 = WASM_VECTOR_LEN;
|
|
29505
|
+
var ptr2 = isLikeNone(enabled_features) ? 0 : passArrayJsValueToWasm0(enabled_features, wasm.__wbindgen_malloc);
|
|
29506
|
+
var len2 = WASM_VECTOR_LEN;
|
|
29507
|
+
const ret = wasm.validate_json_from_str(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
29508
|
+
if (ret[2]) {
|
|
29509
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
29510
|
+
}
|
|
29511
|
+
return takeFromExternrefTable0(ret[0]);
|
|
29512
|
+
}
|
|
29513
|
+
exports.validate_json_from_str = validate_json_from_str;
|
|
29514
|
+
|
|
29367
29515
|
/**
|
|
29368
29516
|
* @param {string} tx_hex
|
|
29369
29517
|
* @param {string} validation_context
|
|
@@ -29410,6 +29558,13 @@ function __wbg_get_imports() {
|
|
|
29410
29558
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
29411
29559
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
29412
29560
|
},
|
|
29561
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
29562
|
+
const ret = String(arg1);
|
|
29563
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
29564
|
+
const len1 = WASM_VECTOR_LEN;
|
|
29565
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
29566
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
29567
|
+
},
|
|
29413
29568
|
__wbg___wbindgen_bigint_get_as_i64_3d3aba5d616c6a51: function(arg0, arg1) {
|
|
29414
29569
|
const v = arg1;
|
|
29415
29570
|
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
@@ -29698,6 +29853,11 @@ function __wbg_get_imports() {
|
|
|
29698
29853
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
29699
29854
|
return ret;
|
|
29700
29855
|
},
|
|
29856
|
+
__wbindgen_cast_0000000000000005: function(arg0) {
|
|
29857
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
29858
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
29859
|
+
return ret;
|
|
29860
|
+
},
|
|
29701
29861
|
__wbindgen_init_externref_table: function() {
|
|
29702
29862
|
const table = wasm.__wbindgen_externrefs;
|
|
29703
29863
|
const offset = table.grow(4);
|
|
@@ -30460,6 +30620,16 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
30460
30620
|
return ptr;
|
|
30461
30621
|
}
|
|
30462
30622
|
|
|
30623
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
30624
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
30625
|
+
for (let i = 0; i < array.length; i++) {
|
|
30626
|
+
const add = addToExternrefTable0(array[i]);
|
|
30627
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
30628
|
+
}
|
|
30629
|
+
WASM_VECTOR_LEN = array.length;
|
|
30630
|
+
return ptr;
|
|
30631
|
+
}
|
|
30632
|
+
|
|
30463
30633
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
30464
30634
|
if (realloc === undefined) {
|
|
30465
30635
|
const buf = cachedTextEncoder.encode(arg);
|
|
Binary file
|
|
@@ -4,18 +4,23 @@ export const memory: WebAssembly.Memory;
|
|
|
4
4
|
export const decode_specific_type: (a: number, b: number, c: number, d: number, e: any) => [number, number, number];
|
|
5
5
|
export const get_decodable_types: () => [number, number];
|
|
6
6
|
export const get_possible_types_for_input: (a: number, b: number) => [number, number];
|
|
7
|
-
export const
|
|
7
|
+
export const cbor_to_json: (a: number, b: number) => [number, number, number];
|
|
8
|
+
export const decode_cbor_against_cddl: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
9
|
+
export const validate_cbor_against_cddl: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
10
|
+
export const validate_cddl: (a: number, b: number) => [number, number, number];
|
|
11
|
+
export const check_block_or_tx_signatures: (a: number, b: number) => [number, number, number];
|
|
8
12
|
export const get_necessary_data_list_js: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
9
13
|
export const validate_transaction_js: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
10
|
-
export const cbor_to_json: (a: number, b: number) => [number, number, number];
|
|
11
14
|
export const decode_plutus_program_pretty_uplc: (a: number, b: number) => [number, number, number, number];
|
|
12
15
|
export const decode_plutus_program_uplc_json: (a: number, b: number) => [number, number, number];
|
|
13
16
|
export const execute_tx_scripts: (a: number, b: number, c: any, d: any) => [number, number, number];
|
|
14
17
|
export const get_ref_script_bytes: (a: number, b: number, c: number) => [number, number, number, number];
|
|
15
18
|
export const get_utxo_list_from_tx: (a: number, b: number) => [number, number, number, number];
|
|
16
|
-
export const
|
|
17
|
-
export const
|
|
18
|
-
export const
|
|
19
|
+
export const extract_hashes_from_transaction_js: (a: number, b: number) => [number, number, number, number];
|
|
20
|
+
export const validate_cbor_from_slice: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
21
|
+
export const validate_json_from_str: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
22
|
+
export const cddl_from_str: (a: number, b: number) => [number, number, number];
|
|
23
|
+
export const validate_cddl_from_str: (a: number, b: number, c: number) => [number, number, number];
|
|
19
24
|
export const __wbg_bigint_free: (a: number, b: number) => void;
|
|
20
25
|
export const __wbg_certificatesbuilder_free: (a: number, b: number) => void;
|
|
21
26
|
export const __wbg_changeconfig_free: (a: number, b: number) => void;
|
package/package.json
CHANGED