From b4ea439031043267942c41aee0e910852951cefa Mon Sep 17 00:00:00 2001 From: Ale Gadea <73836359+alegadea@users.noreply.github.com> Date: Thu, 5 Dec 2024 15:28:36 -0300 Subject: [PATCH] fix: fix display of tx_output_asset_policy_assets and reference_inputs (#6) * Fixing tx_output_asset_policy_asset_name information and a minor typo in tx_mint_policy_asset_count. Bumping pallas dependency for fixing reference inputs * Minor fix related to the validation section. --- napi-pallas/Cargo.toml | 2 +- napi-pallas/index.d.ts | 6 +++--- napi-pallas/index.js | 49 +++++++++++++++++++++++++++++++++--------- napi-pallas/src/tx.rs | 8 +++---- web/app/routes/tx.tsx | 44 ------------------------------------- 5 files changed, 47 insertions(+), 62 deletions(-) diff --git a/napi-pallas/Cargo.toml b/napi-pallas/Cargo.toml index cf2d72f..409fdb0 100644 --- a/napi-pallas/Cargo.toml +++ b/napi-pallas/Cargo.toml @@ -12,7 +12,7 @@ hex = "0.4.3" # Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix napi = { version = "2.12.2", default-features = false, features = ["napi4"] } napi-derive = "2.12.2" -pallas = { git = "https://github.com/alegadea/pallas.git", rev = "54ffc77" , features = ["unstable"]} +pallas = { git = "https://github.com/txpipe/pallas.git", rev = "ba342ab", features = ["unstable"] } [build-dependencies] napi-build = "2.0.1" diff --git a/napi-pallas/index.d.ts b/napi-pallas/index.d.ts index 7254742..5f923ff 100644 --- a/napi-pallas/index.d.ts +++ b/napi-pallas/index.d.ts @@ -32,13 +32,13 @@ export interface Section { bytes?: string children: Array
} -export function parseAddress(raw: string): Output +export declare function parseAddress(raw: string): Output export interface SectionValidation { section: Section validations: Validations } -export function safeParseTx(raw: string): SectionValidation -export function safeParseBlock(raw: string): Section +export declare function safeParseTx(raw: string): SectionValidation +export declare function safeParseBlock(raw: string): Section export interface Validation { name: string value: boolean diff --git a/napi-pallas/index.js b/napi-pallas/index.js index 3388105..690d1e2 100644 --- a/napi-pallas/index.js +++ b/napi-pallas/index.js @@ -224,17 +224,32 @@ switch (platform) { } break case 'arm': - localFileExisted = existsSync( - join(__dirname, 'napi-pallas.linux-arm-gnueabihf.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./napi-pallas.linux-arm-gnueabihf.node') - } else { - nativeBinding = require('napi-pallas-linux-arm-gnueabihf') + if (isMusl()) { + localFileExisted = existsSync( + join(__dirname, 'napi-pallas.linux-arm-musleabihf.node') + ) + try { + if (localFileExisted) { + nativeBinding = require('./napi-pallas.linux-arm-musleabihf.node') + } else { + nativeBinding = require('napi-pallas-linux-arm-musleabihf') + } + } catch (e) { + loadError = e + } + } else { + localFileExisted = existsSync( + join(__dirname, 'napi-pallas.linux-arm-gnueabihf.node') + ) + try { + if (localFileExisted) { + nativeBinding = require('./napi-pallas.linux-arm-gnueabihf.node') + } else { + nativeBinding = require('napi-pallas-linux-arm-gnueabihf') + } + } catch (e) { + loadError = e } - } catch (e) { - loadError = e } break case 'riscv64': @@ -266,6 +281,20 @@ switch (platform) { } } break + case 's390x': + localFileExisted = existsSync( + join(__dirname, 'napi-pallas.linux-s390x-gnu.node') + ) + try { + if (localFileExisted) { + nativeBinding = require('./napi-pallas.linux-s390x-gnu.node') + } else { + nativeBinding = require('napi-pallas-linux-s390x-gnu') + } + } catch (e) { + loadError = e + } + break default: throw new Error(`Unsupported architecture on Linux: ${arch}`) } diff --git a/napi-pallas/src/tx.rs b/napi-pallas/src/tx.rs index 2be1295..2052c37 100644 --- a/napi-pallas/src/tx.rs +++ b/napi-pallas/src/tx.rs @@ -81,9 +81,9 @@ fn tx_output_section(o: &MultiEraOutput) -> Section { .collect_children(x.assets().iter().map(|asset| { Section::new() .with_topic("tx_output_asset_policy_asset") - .with_attr("tx_mint_policy_asset_name", hex::encode(asset.name())) - .with_maybe_attr("tx_mint_policy_asset_name_ascii", asset.to_ascii_name()) - .with_maybe_attr("tx_mint_policy_asset_coint", asset.mint_coin()) + .with_attr("tx_output_asset_policy_asset_name", hex::encode(asset.name())) + .with_maybe_attr("tx_output_asset_policy_asset_name_ascii", asset.to_ascii_name()) + .with_maybe_attr("tx_output_asset_policy_asset_count", asset.output_coin()) })) }) })) @@ -121,7 +121,7 @@ fn tx_mints_section(tx: &MultiEraTx<'_>) -> Section { .with_topic("tx_mint_policy_asset") .with_attr("tx_mint_policy_asset_name", hex::encode(asset.name())) .with_maybe_attr("tx_mint_policy_asset_name_ascii", asset.to_ascii_name()) - .with_maybe_attr("tx_mint_policy_asset_coint", asset.mint_coin()) + .with_maybe_attr("tx_mint_policy_asset_count", asset.mint_coin()) })) }) })) diff --git a/web/app/routes/tx.tsx b/web/app/routes/tx.tsx index 1d1b4ac..f274231 100644 --- a/web/app/routes/tx.tsx +++ b/web/app/routes/tx.tsx @@ -66,50 +66,6 @@ export default function Index() { const validations: IValidation[] = data?.validations || []; - const validations: IValidation[] = [ - { name: "Non empty inputs", value: true, description: "Sucessful" }, - { - name: "All inputs in utxos", - value: false, - description: - "Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro id maiores exercitationem asperiores molestias assumenda doloremque magnam fugit. Iure dolorum fugit facilis autem incidunt vero necessitatibus consectetur ducimus recusandae blanditiis!", - }, - { name: "Validity interval", value: true, description: "Sucessful" }, - { name: "Fee", value: true, description: "Sucessful" }, - { - name: "Preservation of value", - value: false, - description: - "Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro id maiores exercitationem asperiores molestias assumenda doloremque magnam fugit. Iure dolorum fugit facilis autem incidunt vero necessitatibus consectetur ducimus recusandae blanditiis!", - }, - { - name: "Min lovelace per UTxO", - value: false, - description: - "Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro id maiores exercitationem asperiores molestias assumenda doloremque magnam fugit. Iure dolorum fugit facilis autem incidunt vero necessitatibus consectetur ducimus recusandae blanditiis!", - }, - { name: "Output value size", value: true, description: "Successful" }, - { name: "Network Id", value: true, description: "Successful" }, - { name: "Tx size", value: true, description: "Successful" }, - { name: "Tx execution units", value: true, description: "Successful" }, - { name: "Minting", value: true, description: "Successful" }, - { - name: "Well formed", - value: false, - description: - "Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro id maiores exercitationem asperiores molestias assumenda doloremque magnam fugit. Iure dolorum fugit facilis autem incidunt vero necessitatibus consectetur ducimus recusandae blanditiis!", - }, - { name: "Script witness", value: true, description: "Successful" }, - { name: "Languages", value: true, description: "Successful" }, - { - name: "Auxiliary data hash", - value: false, - description: - "Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro id maiores exercitationem asperiores molestias assumenda doloremque magnam fugit. Iure dolorum fugit facilis autem incidunt vero necessitatibus consectetur ducimus recusandae blanditiis!", - }, - { name: "Script data hash", value: true, description: "Successful" }, - ]; - return (

Cardano Tx