@cardananium/cquisitor-lib 0.1.0-beta.51 → 0.1.0-beta.52
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 +14 -5
- package/browser/cquisitor_lib.d.ts +46 -0
- package/browser/cquisitor_lib.js +1 -1
- package/browser/cquisitor_lib_bg.js +25 -0
- package/browser/cquisitor_lib_bg.wasm +0 -0
- package/browser/cquisitor_lib_bg.wasm.d.ts +5 -4
- package/node/cquisitor_lib.d.ts +46 -0
- package/node/cquisitor_lib.js +26 -0
- package/node/cquisitor_lib_bg.wasm +0 -0
- package/node/cquisitor_lib_bg.wasm.d.ts +5 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -353,9 +353,15 @@ validate_cddl("thing = {n: uint}");
|
|
|
353
353
|
validate_cddl("thing = [unknown_rule, int]");
|
|
354
354
|
// { valid: false, error: { kind: "unresolved_references",
|
|
355
355
|
// message: "missing definition for rule unknown_rule" } }
|
|
356
|
+
|
|
357
|
+
validate_cddl("; only a comment\n");
|
|
358
|
+
// { valid: false, error: { kind: "no_rules",
|
|
359
|
+
// message: "CDDL document defines no rules" } }
|
|
356
360
|
```
|
|
357
361
|
|
|
358
|
-
`
|
|
362
|
+
Parser errors include a `byte_span: {offset, length, line}` so editors can squiggle the exact position pest tripped on.
|
|
363
|
+
|
|
364
|
+
`error.kind` values: `"parse_error"`, `"unresolved_references"`, `"no_rules"`.
|
|
359
365
|
|
|
360
366
|
#### `validate_cbor_against_cddl(cbor_hex: string, cddl: string, rule_name: string): { valid: boolean, error?: object }`
|
|
361
367
|
|
|
@@ -378,7 +384,9 @@ validate_cbor_against_cddl("01", "thing = tstr", "thing");
|
|
|
378
384
|
|
|
379
385
|
`error.cddl_byte_span` carries the byte range in the **CDDL source** pointing at the type the validator tried (and failed) to apply — useful for highlighting the offending rule in an editor. It's synthesised by walking the AST in parallel with `path`, so it's available for any error that has a meaningful `path`. When the `rule_name` you passed isn't the first rule of the document, the offsets are still expressed in *your* CDDL coordinates (the wrapper we use internally is invisible to callers).
|
|
380
386
|
|
|
381
|
-
`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`.
|
|
387
|
+
`error.kind` values: `"parse_error"`, `"unresolved_references"`, `"no_rules"`, `"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`.
|
|
388
|
+
|
|
389
|
+
`anchor_spans` is always populated — for container values (Map / Array / Tag / indefinite strings) it covers the whole structure; for scalars it falls back to `position_info` so a UI's halo highlight always has something to draw.
|
|
382
390
|
|
|
383
391
|
#### `decode_cbor_against_cddl(cbor_hex: string, cddl: string, rule_name: string): unknown`
|
|
384
392
|
|
|
@@ -431,9 +439,10 @@ cddl_symbol_at("coin = uint\nfee = coin", /* offset = */ 18);
|
|
|
431
439
|
// definition_span: {offset: 0, length: 4, line: 1},
|
|
432
440
|
// rule_span: {offset: 0, length: 11, line: 1}}
|
|
433
441
|
|
|
434
|
-
// Re-format — round-trip via Display.
|
|
435
|
-
|
|
436
|
-
|
|
442
|
+
// Re-format — round-trip via Display. Comments survive
|
|
443
|
+
// (both standalone `; …` and trailing `; …`).
|
|
444
|
+
cddl_format("; header\nalpha = uint ; trailing");
|
|
445
|
+
// "; header\nalpha = uint ; trailing\n"
|
|
437
446
|
```
|
|
438
447
|
|
|
439
448
|
`validate_cddl` itself returns a `byte_span` on parser errors so editor-side squiggles can underline the offending position directly:
|
|
@@ -232,6 +232,52 @@ export function cddl_symbol_at(cddl: string, offset: number): CddlSymbolAtResult
|
|
|
232
232
|
*/
|
|
233
233
|
export function cddl_format(cddl: string): string;
|
|
234
234
|
|
|
235
|
+
/** One entry from `map_cbor_to_cddl`: a single position of a CBOR
|
|
236
|
+
* node, the type that matched it, and the path it ends up at in the
|
|
237
|
+
* output of `decode_cbor_against_cddl`. */
|
|
238
|
+
export interface CborCddlMapEntry {
|
|
239
|
+
/** Path into the *raw* CBOR tree (numeric map keys are bracketed). */
|
|
240
|
+
cbor_path: string;
|
|
241
|
+
/** Path into the labelled JSON returned by `decode_cbor_against_cddl`.
|
|
242
|
+
* Numeric map keys come back as bracket-quoted strings (`["0"]`)
|
|
243
|
+
* because decoded JSON has only string keys; identifier-safe keys
|
|
244
|
+
* use dot notation (`.name`). For unspecialised tags (anything
|
|
245
|
+
* except 0 / 2 / 3) the inner gets an extra `["@value"]` segment
|
|
246
|
+
* to match the `{@tag, @value}` wrapper the decoder emits. */
|
|
247
|
+
decoded_path: string;
|
|
248
|
+
/** Header byte range of the CBOR node. */
|
|
249
|
+
cbor_byte_span: { offset: number; length: number };
|
|
250
|
+
/** Whole-structure byte range (= `cbor_byte_span` for scalars). */
|
|
251
|
+
cbor_anchor_span: { offset: number; length: number };
|
|
252
|
+
/** Byte range in the CDDL source describing this position. */
|
|
253
|
+
cddl_byte_span: { offset: number; length: number; line: number };
|
|
254
|
+
/** Name of the CDDL rule that matched, if a rule boundary was crossed. */
|
|
255
|
+
rule_name?: string;
|
|
256
|
+
/** CBOR node's wire type (`U8`, `Bytes`, `Map`, `Array`, `Tag`, …). */
|
|
257
|
+
cbor_type?: string;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Returns a flat list of mapping entries pairing each visited CBOR node
|
|
262
|
+
* with the CDDL position that describes it. Use it to wire
|
|
263
|
+
* bidirectional highlight between a CBOR panel and a CDDL panel without
|
|
264
|
+
* needing a validation error to trigger it.
|
|
265
|
+
*
|
|
266
|
+
* Order is depth-first pre-order, so a parent's entry precedes its
|
|
267
|
+
* children's. Tags in the CBOR are transparent to the path grammar
|
|
268
|
+
* (anweiss-style): `Tag(258, [...])` is walked as if the tag wrapper
|
|
269
|
+
* weren't there when matching against `[* a]`-shaped schemas.
|
|
270
|
+
*
|
|
271
|
+
* @param cbor_hex
|
|
272
|
+
* @param cddl
|
|
273
|
+
* @param rule_name
|
|
274
|
+
*/
|
|
275
|
+
export function map_cbor_to_cddl(
|
|
276
|
+
cbor_hex: string,
|
|
277
|
+
cddl: string,
|
|
278
|
+
rule_name: string
|
|
279
|
+
): CborCddlMapEntry[];
|
|
280
|
+
|
|
235
281
|
/**
|
|
236
282
|
* Maps decoded CBOR onto a CDDL schema and returns labelled JSON. Where
|
|
237
283
|
* `cbor_to_json` returns positional CBOR (numeric map keys, raw arrays),
|
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, cddl_format, cddl_from_str, cddl_outline, cddl_references, cddl_symbol_at, 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
|
|
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_format, cddl_from_str, cddl_outline, cddl_references, cddl_symbol_at, 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, map_cbor_to_cddl, 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";
|
|
@@ -29149,6 +29149,31 @@ export function make_vkey_witness(tx_body_hash, sk) {
|
|
|
29149
29149
|
return Vkeywitness.__wrap(ret);
|
|
29150
29150
|
}
|
|
29151
29151
|
|
|
29152
|
+
/**
|
|
29153
|
+
* Returns a flat list of `{cbor_path, cbor_byte_span, cbor_anchor_span,
|
|
29154
|
+
* cddl_byte_span, rule_name?}` entries — one per node visited during a
|
|
29155
|
+
* parallel CBOR ↔ CDDL traversal. Use it to wire bidirectional
|
|
29156
|
+
* highlight between a CBOR panel and a CDDL panel without needing a
|
|
29157
|
+
* validation error to trigger it.
|
|
29158
|
+
* @param {string} cbor_hex
|
|
29159
|
+
* @param {string} cddl
|
|
29160
|
+
* @param {string} rule_name
|
|
29161
|
+
* @returns {any}
|
|
29162
|
+
*/
|
|
29163
|
+
export function map_cbor_to_cddl(cbor_hex, cddl, rule_name) {
|
|
29164
|
+
const ptr0 = passStringToWasm0(cbor_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
29165
|
+
const len0 = WASM_VECTOR_LEN;
|
|
29166
|
+
const ptr1 = passStringToWasm0(cddl, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
29167
|
+
const len1 = WASM_VECTOR_LEN;
|
|
29168
|
+
const ptr2 = passStringToWasm0(rule_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
29169
|
+
const len2 = WASM_VECTOR_LEN;
|
|
29170
|
+
const ret = wasm.map_cbor_to_cddl(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
29171
|
+
if (ret[2]) {
|
|
29172
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
29173
|
+
}
|
|
29174
|
+
return takeFromExternrefTable0(ret[0]);
|
|
29175
|
+
}
|
|
29176
|
+
|
|
29152
29177
|
/**
|
|
29153
29178
|
* returns minimal amount of ada for the output for case when the amount is included to the output
|
|
29154
29179
|
* @param {TransactionOutput} output
|
|
Binary file
|
|
@@ -4,15 +4,14 @@ 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
|
|
8
|
-
export const get_necessary_data_list_js: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
9
|
-
export const validate_transaction_js: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
7
|
+
export const extract_hashes_from_transaction_js: (a: number, b: number) => [number, number, number, number];
|
|
10
8
|
export const cbor_to_json: (a: number, b: number) => [number, number, number];
|
|
11
9
|
export const cddl_format: (a: number, b: number) => [number, number, number, number];
|
|
12
10
|
export const cddl_outline: (a: number, b: number) => [number, number, number];
|
|
13
11
|
export const cddl_references: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
14
12
|
export const cddl_symbol_at: (a: number, b: number, c: number) => [number, number, number];
|
|
15
13
|
export const decode_cbor_against_cddl: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
14
|
+
export const map_cbor_to_cddl: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
16
15
|
export const validate_cbor_against_cddl: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
17
16
|
export const validate_cddl: (a: number, b: number) => [number, number, number];
|
|
18
17
|
export const decode_plutus_program_pretty_uplc: (a: number, b: number) => [number, number, number, number];
|
|
@@ -20,7 +19,9 @@ export const decode_plutus_program_uplc_json: (a: number, b: number) => [number,
|
|
|
20
19
|
export const execute_tx_scripts: (a: number, b: number, c: any, d: any) => [number, number, number];
|
|
21
20
|
export const get_ref_script_bytes: (a: number, b: number, c: number) => [number, number, number, number];
|
|
22
21
|
export const get_utxo_list_from_tx: (a: number, b: number) => [number, number, number, number];
|
|
23
|
-
export const
|
|
22
|
+
export const check_block_or_tx_signatures: (a: number, b: number) => [number, number, number];
|
|
23
|
+
export const get_necessary_data_list_js: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
24
|
+
export const validate_transaction_js: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
24
25
|
export const validate_cbor_from_slice: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
25
26
|
export const validate_json_from_str: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
26
27
|
export const cddl_from_str: (a: number, b: number) => [number, number, number];
|
package/node/cquisitor_lib.d.ts
CHANGED
|
@@ -232,6 +232,52 @@ export function cddl_symbol_at(cddl: string, offset: number): CddlSymbolAtResult
|
|
|
232
232
|
*/
|
|
233
233
|
export function cddl_format(cddl: string): string;
|
|
234
234
|
|
|
235
|
+
/** One entry from `map_cbor_to_cddl`: a single position of a CBOR
|
|
236
|
+
* node, the type that matched it, and the path it ends up at in the
|
|
237
|
+
* output of `decode_cbor_against_cddl`. */
|
|
238
|
+
export interface CborCddlMapEntry {
|
|
239
|
+
/** Path into the *raw* CBOR tree (numeric map keys are bracketed). */
|
|
240
|
+
cbor_path: string;
|
|
241
|
+
/** Path into the labelled JSON returned by `decode_cbor_against_cddl`.
|
|
242
|
+
* Numeric map keys come back as bracket-quoted strings (`["0"]`)
|
|
243
|
+
* because decoded JSON has only string keys; identifier-safe keys
|
|
244
|
+
* use dot notation (`.name`). For unspecialised tags (anything
|
|
245
|
+
* except 0 / 2 / 3) the inner gets an extra `["@value"]` segment
|
|
246
|
+
* to match the `{@tag, @value}` wrapper the decoder emits. */
|
|
247
|
+
decoded_path: string;
|
|
248
|
+
/** Header byte range of the CBOR node. */
|
|
249
|
+
cbor_byte_span: { offset: number; length: number };
|
|
250
|
+
/** Whole-structure byte range (= `cbor_byte_span` for scalars). */
|
|
251
|
+
cbor_anchor_span: { offset: number; length: number };
|
|
252
|
+
/** Byte range in the CDDL source describing this position. */
|
|
253
|
+
cddl_byte_span: { offset: number; length: number; line: number };
|
|
254
|
+
/** Name of the CDDL rule that matched, if a rule boundary was crossed. */
|
|
255
|
+
rule_name?: string;
|
|
256
|
+
/** CBOR node's wire type (`U8`, `Bytes`, `Map`, `Array`, `Tag`, …). */
|
|
257
|
+
cbor_type?: string;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Returns a flat list of mapping entries pairing each visited CBOR node
|
|
262
|
+
* with the CDDL position that describes it. Use it to wire
|
|
263
|
+
* bidirectional highlight between a CBOR panel and a CDDL panel without
|
|
264
|
+
* needing a validation error to trigger it.
|
|
265
|
+
*
|
|
266
|
+
* Order is depth-first pre-order, so a parent's entry precedes its
|
|
267
|
+
* children's. Tags in the CBOR are transparent to the path grammar
|
|
268
|
+
* (anweiss-style): `Tag(258, [...])` is walked as if the tag wrapper
|
|
269
|
+
* weren't there when matching against `[* a]`-shaped schemas.
|
|
270
|
+
*
|
|
271
|
+
* @param cbor_hex
|
|
272
|
+
* @param cddl
|
|
273
|
+
* @param rule_name
|
|
274
|
+
*/
|
|
275
|
+
export function map_cbor_to_cddl(
|
|
276
|
+
cbor_hex: string,
|
|
277
|
+
cddl: string,
|
|
278
|
+
rule_name: string
|
|
279
|
+
): CborCddlMapEntry[];
|
|
280
|
+
|
|
235
281
|
/**
|
|
236
282
|
* Maps decoded CBOR onto a CDDL schema and returns labelled JSON. Where
|
|
237
283
|
* `cbor_to_json` returns positional CBOR (numeric map keys, raw arrays),
|
package/node/cquisitor_lib.js
CHANGED
|
@@ -29412,6 +29412,32 @@ function make_vkey_witness(tx_body_hash, sk) {
|
|
|
29412
29412
|
}
|
|
29413
29413
|
exports.make_vkey_witness = make_vkey_witness;
|
|
29414
29414
|
|
|
29415
|
+
/**
|
|
29416
|
+
* Returns a flat list of `{cbor_path, cbor_byte_span, cbor_anchor_span,
|
|
29417
|
+
* cddl_byte_span, rule_name?}` entries — one per node visited during a
|
|
29418
|
+
* parallel CBOR ↔ CDDL traversal. Use it to wire bidirectional
|
|
29419
|
+
* highlight between a CBOR panel and a CDDL panel without needing a
|
|
29420
|
+
* validation error to trigger it.
|
|
29421
|
+
* @param {string} cbor_hex
|
|
29422
|
+
* @param {string} cddl
|
|
29423
|
+
* @param {string} rule_name
|
|
29424
|
+
* @returns {any}
|
|
29425
|
+
*/
|
|
29426
|
+
function map_cbor_to_cddl(cbor_hex, cddl, rule_name) {
|
|
29427
|
+
const ptr0 = passStringToWasm0(cbor_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
29428
|
+
const len0 = WASM_VECTOR_LEN;
|
|
29429
|
+
const ptr1 = passStringToWasm0(cddl, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
29430
|
+
const len1 = WASM_VECTOR_LEN;
|
|
29431
|
+
const ptr2 = passStringToWasm0(rule_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
29432
|
+
const len2 = WASM_VECTOR_LEN;
|
|
29433
|
+
const ret = wasm.map_cbor_to_cddl(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
29434
|
+
if (ret[2]) {
|
|
29435
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
29436
|
+
}
|
|
29437
|
+
return takeFromExternrefTable0(ret[0]);
|
|
29438
|
+
}
|
|
29439
|
+
exports.map_cbor_to_cddl = map_cbor_to_cddl;
|
|
29440
|
+
|
|
29415
29441
|
/**
|
|
29416
29442
|
* returns minimal amount of ada for the output for case when the amount is included to the output
|
|
29417
29443
|
* @param {TransactionOutput} output
|
|
Binary file
|
|
@@ -4,15 +4,14 @@ 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
|
|
8
|
-
export const get_necessary_data_list_js: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
9
|
-
export const validate_transaction_js: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
7
|
+
export const extract_hashes_from_transaction_js: (a: number, b: number) => [number, number, number, number];
|
|
10
8
|
export const cbor_to_json: (a: number, b: number) => [number, number, number];
|
|
11
9
|
export const cddl_format: (a: number, b: number) => [number, number, number, number];
|
|
12
10
|
export const cddl_outline: (a: number, b: number) => [number, number, number];
|
|
13
11
|
export const cddl_references: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
14
12
|
export const cddl_symbol_at: (a: number, b: number, c: number) => [number, number, number];
|
|
15
13
|
export const decode_cbor_against_cddl: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
14
|
+
export const map_cbor_to_cddl: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
16
15
|
export const validate_cbor_against_cddl: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
17
16
|
export const validate_cddl: (a: number, b: number) => [number, number, number];
|
|
18
17
|
export const decode_plutus_program_pretty_uplc: (a: number, b: number) => [number, number, number, number];
|
|
@@ -20,7 +19,9 @@ export const decode_plutus_program_uplc_json: (a: number, b: number) => [number,
|
|
|
20
19
|
export const execute_tx_scripts: (a: number, b: number, c: any, d: any) => [number, number, number];
|
|
21
20
|
export const get_ref_script_bytes: (a: number, b: number, c: number) => [number, number, number, number];
|
|
22
21
|
export const get_utxo_list_from_tx: (a: number, b: number) => [number, number, number, number];
|
|
23
|
-
export const
|
|
22
|
+
export const check_block_or_tx_signatures: (a: number, b: number) => [number, number, number];
|
|
23
|
+
export const get_necessary_data_list_js: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
24
|
+
export const validate_transaction_js: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
24
25
|
export const validate_cbor_from_slice: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
25
26
|
export const validate_json_from_str: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
26
27
|
export const cddl_from_str: (a: number, b: number) => [number, number, number];
|
package/package.json
CHANGED