Skip to content

Commit

Permalink
refactor: some cashu-sdk-ffi to v1
Browse files Browse the repository at this point in the history
  • Loading branch information
thesimplekid committed Dec 22, 2023
1 parent 85df354 commit 3301199
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 158 deletions.
67 changes: 36 additions & 31 deletions bindings/cashu-ffi/src/cashu.udl
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ interface Secret {

// NUT00

interface Id {
[Throws=CashuError]
constructor(string id);
};

interface PublicKey {
[Throws=CashuError, Name=from_hex]
Expand Down Expand Up @@ -112,6 +108,14 @@ interface PreMintSecrets {
sequence<Amount> amounts();
};


// NUT-02

interface Id {
[Throws=CashuError]
constructor(string id);
};

interface KeyPair {
[Name=from_secret_key]
constructor(SecretKey secret_key);
Expand All @@ -137,7 +141,6 @@ interface MintKeySet {
constructor(string secret, string unit, string derivation_path, u8 max_order);
};


interface KeysResponse {
constructor(Keys keys);
};
Expand All @@ -147,14 +150,28 @@ interface KeySetResponse {
sequence<KeySetInfo> keysets();
};

// --- NUT-04
// NUT-03

interface SwapRequest {
constructor(sequence<Proof> proofs, sequence<BlindedMessage> outputs);
sequence<Proof> proofs();
sequence<BlindedMessage> outputs();
Amount proofs_amount();
Amount output_amount();
};

interface SwapResponse {
constructor(sequence<BlindedSignature> promises);
sequence<BlindedSignature> signatures();
};

// NUT-04

interface MintQuoteBolt11Request {
constructor(Amount amount, string unit);
Amount amount();
};


interface MintQuoteBolt11Response {
constructor(string quote, string request, boolean paid, u64 expiry);
string quote();
Expand All @@ -175,8 +192,6 @@ interface MintBolt11Response {
sequence<BlindedSignature> signatures();
};

// ---

// NUT-05

interface MeltQuoteBolt11Response {
Expand Down Expand Up @@ -208,20 +223,21 @@ interface MeltBolt11Response {
boolean paid();
};

// ----
interface SwapRequest {
constructor(sequence<Proof> proofs, sequence<BlindedMessage> outputs);
sequence<Proof> proofs();
sequence<BlindedMessage> outputs();
Amount proofs_amount();
Amount output_amount();
};
// NUT-06

interface SwapResponse {
constructor(sequence<BlindedSignature> promises);
sequence<BlindedSignature> signatures();
interface MintInfo {
constructor(string? name, PublicKey? pubkey, MintVersion? version, string? description, string? description_long, sequence<sequence<string>>? contact, string nuts, string? motd);
string? name();
PublicKey? pubkey();
MintVersion? version();
string? description();
string? description_long();
sequence<sequence<string>>? contact();
string? motd();
};

// NUT-07

interface CheckSpendableRequest {
constructor(sequence<MintProof> proofs);
sequence<MintProof> proofs();
Expand All @@ -239,17 +255,6 @@ interface MintVersion {
string version();
};

interface MintInfo {
constructor(string? name, PublicKey? pubkey, MintVersion? version, string? description, string? description_long, sequence<sequence<string>>? contact, string nuts, string? motd);
string? name();
PublicKey? pubkey();
MintVersion? version();
string? description();
string? description_long();
sequence<sequence<string>>? contact();
string? motd();
};

interface KeySetInfo {
constructor(Id id, string unit);

Expand Down
10 changes: 10 additions & 0 deletions bindings/cashu-ffi/src/nuts/nut00/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ impl From<&CurrencyUnit> for CurrencyUnitSdk {
}
}

impl From<CurrencyUnit> for CurrencyUnitSdk {
fn from(unit: CurrencyUnit) -> CurrencyUnitSdk {
match unit {
CurrencyUnit::Sat() => CurrencyUnitSdk::Sat,
CurrencyUnit::Usd() => CurrencyUnitSdk::Usd,
CurrencyUnit::Custom { unit } => CurrencyUnitSdk::Custom(unit.clone()),
}
}
}

impl From<CurrencyUnitSdk> for CurrencyUnit {
fn from(unit: CurrencyUnitSdk) -> CurrencyUnit {
match unit {
Expand Down
6 changes: 6 additions & 0 deletions bindings/cashu-ffi/src/nuts/nut04/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,9 @@ impl MintBolt11Response {
.collect()
}
}

impl From<MintBolt11ResponseSdk> for MintBolt11Response {
fn from(inner: MintBolt11ResponseSdk) -> MintBolt11Response {
MintBolt11Response { inner }
}
}
Loading

0 comments on commit 3301199

Please sign in to comment.