Skip to content

Commit

Permalink
feat: improve content
Browse files Browse the repository at this point in the history
  • Loading branch information
scarmuega committed Jan 14, 2024
1 parent ee40d08 commit 5e4e786
Show file tree
Hide file tree
Showing 4 changed files with 279 additions and 73 deletions.
3 changes: 2 additions & 1 deletion napi-pallas/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@

export interface ShelleyPart {
isScript: boolean
pubkeyHash?: string
hash?: string
pointer?: string
}
export interface AddressDiagnostic {
kind: string
network?: string
paymentPart?: ShelleyPart
delegationPart?: ShelleyPart
byronCbor?: string
}
export interface Output {
error?: string
Expand Down
35 changes: 28 additions & 7 deletions napi-pallas/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ fn network_to_string(network: Network) -> String {
#[napi(object)]
pub struct ShelleyPart {
pub is_script: bool,
pub pubkey_hash: Option<String>,
pub hash: Option<String>,
pub pointer: Option<String>,
}

impl From<&pallas::ledger::addresses::ShelleyPaymentPart> for ShelleyPart {
fn from(value: &pallas::ledger::addresses::ShelleyPaymentPart) -> Self {
Self {
is_script: value.is_script(),
pubkey_hash: Some(value.as_hash().to_string()),
hash: Some(value.as_hash().to_string()),
pointer: None,
}
}
Expand All @@ -37,17 +37,17 @@ impl From<&pallas::ledger::addresses::ShelleyDelegationPart> for ShelleyPart {
match value {
pallas::ledger::addresses::ShelleyDelegationPart::Key(x) => Self {
is_script: false,
pubkey_hash: Some(x.to_string()),
hash: Some(x.to_string()),
pointer: None,
},
pallas::ledger::addresses::ShelleyDelegationPart::Script(x) => Self {
is_script: true,
pubkey_hash: Some(x.to_string()),
hash: Some(x.to_string()),
pointer: None,
},
pallas::ledger::addresses::ShelleyDelegationPart::Pointer(x) => Self {
is_script: false,
pubkey_hash: None,
hash: None,
pointer: Some(format!(
"slot: {}, tx: {}, cert: {}",
x.slot(),
Expand All @@ -57,7 +57,24 @@ impl From<&pallas::ledger::addresses::ShelleyDelegationPart> for ShelleyPart {
},
pallas::ledger::addresses::ShelleyDelegationPart::Null => Self {
is_script: false,
pubkey_hash: None,
hash: None,
pointer: None,
},
}
}
}

impl From<&pallas::ledger::addresses::StakePayload> for ShelleyPart {
fn from(value: &pallas::ledger::addresses::StakePayload) -> Self {
match value {
pallas::ledger::addresses::StakePayload::Stake(x) => Self {
is_script: false,
hash: Some(x.to_string()),
pointer: None,
},
pallas::ledger::addresses::StakePayload::Script(x) => Self {
is_script: true,
hash: Some(x.to_string()),
pointer: None,
},
}
Expand All @@ -70,6 +87,7 @@ pub struct AddressDiagnostic {
pub network: Option<String>,
pub payment_part: Option<ShelleyPart>,
pub delegation_part: Option<ShelleyPart>,
pub byron_cbor: Option<String>,
}

impl From<Address> for AddressDiagnostic {
Expand All @@ -80,18 +98,21 @@ impl From<Address> for AddressDiagnostic {
network: None,
payment_part: None,
delegation_part: None,
byron_cbor: Some(hex::encode(x.payload.as_slice())),
},
Address::Shelley(x) => Self {
kind: "Shelley".into(),
network: Some(network_to_string(x.network())),
payment_part: Some(x.payment().into()),
delegation_part: Some(x.delegation().into()),
byron_cbor: None,
},
Address::Stake(x) => Self {
kind: "Stake".into(),
network: Some(network_to_string(x.network())),
payment_part: None,
delegation_part: None,
delegation_part: Some(x.payload().into()),
byron_cbor: None,
},
}
}
Expand Down
40 changes: 28 additions & 12 deletions web/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,36 @@ export default function App() {
</header>
<Outlet />
<footer className="mt-32 p-10 grid grid-cols-3 bg-slate-100 border-t-2 border-gray-300 border-dashed">
<div className="flex flex-col items-center">
<p>Made by TxPipe</p>
<p>Open-source tools for blockchain devs</p>
<a href="https://txpipe.io">txpipe.io</a>
<div className="flex flex-col items-center text-center">
<p className="text-lg font-extrabold">Made by TxPipe</p>
<p className="text-gray-700">
Open-source tools for
<br /> blockchain devs
</p>
<a className="text-blue-400" href="https://txpipe.io">
https://txpipe.io
</a>
</div>
<div className="flex flex-col items-center">
<p>Hosted in Demeter.run</p>
<p>Cardano infrastructure made simple</p>
<a href="https://demeter.run">demeter.run</a>
<div className="flex flex-col items-center text-center">
<p className="text-lg font-extrabold">Hosted in Demeter.run</p>
<p className="text-gray-700">
Cardano infrastructure
<br /> made simple
</p>
<a className="text-blue-400" href="https://demeter.run">
https://demeter.run
</a>
</div>
<div className="flex flex-col items-center">
<p>Building a dApp?</p>
<p>We can help!</p>
<a href="https://txpipe.shop">txpipe.shop</a>
<div className="flex flex-col items-center text-center">
<p className="text-lg font-extrabold">Building a dApp?</p>
<p className="text-gray-700">
We can help!
<br />
Schedule an intro call
</p>
<a className="text-blue-400" href="https://txpipe.shop">
https://txpipe.shop
</a>
</div>
</footer>
</div>
Expand Down
Loading

0 comments on commit 5e4e786

Please sign in to comment.