mirror of
https://github.com/aljazceru/cdk.git
synced 2026-02-05 05:06:14 +01:00
refactor: rename 'symbol' to 'unit'
This commit is contained in:
@@ -124,14 +124,14 @@ interface Keys {
|
||||
};
|
||||
|
||||
interface KeySet {
|
||||
constructor(Id id, string symbol, Keys keys);
|
||||
constructor(Id id, string unit, Keys keys);
|
||||
Id id();
|
||||
Keys keys();
|
||||
};
|
||||
|
||||
interface MintKeySet {
|
||||
[Name=generate]
|
||||
constructor(string secret, string symbol, string derivation_path, u8 max_order);
|
||||
constructor(string secret, string unit, string derivation_path, u8 max_order);
|
||||
};
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@ interface MintInfo {
|
||||
};
|
||||
|
||||
interface KeySetInfo {
|
||||
constructor(Id id, string symbol);
|
||||
constructor(Id id, string unit);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -50,11 +50,11 @@ impl Deref for KeySet {
|
||||
}
|
||||
|
||||
impl KeySet {
|
||||
pub fn new(id: Arc<Id>, symbol: String, keys: Arc<Keys>) -> Self {
|
||||
pub fn new(id: Arc<Id>, unit: String, keys: Arc<Keys>) -> Self {
|
||||
Self {
|
||||
inner: KeySetSdk {
|
||||
id: *id.as_ref().deref(),
|
||||
symbol,
|
||||
unit,
|
||||
keys: keys.as_ref().deref().clone(),
|
||||
},
|
||||
}
|
||||
@@ -64,8 +64,8 @@ impl KeySet {
|
||||
Arc::new(self.inner.id.into())
|
||||
}
|
||||
|
||||
pub fn symbol(&self) -> String {
|
||||
self.inner.symbol.clone()
|
||||
pub fn unit(&self) -> String {
|
||||
self.inner.unit.clone()
|
||||
}
|
||||
|
||||
pub fn keys(&self) -> Arc<Keys> {
|
||||
|
||||
@@ -14,14 +14,9 @@ impl Deref for MintKeySet {
|
||||
}
|
||||
|
||||
impl MintKeySet {
|
||||
pub fn generate(
|
||||
secret: String,
|
||||
symbol: String,
|
||||
derivation_path: String,
|
||||
max_order: u8,
|
||||
) -> Self {
|
||||
pub fn generate(secret: String, unit: String, derivation_path: String, max_order: u8) -> Self {
|
||||
Self {
|
||||
inner: KeySetSdk::generate(secret, symbol, derivation_path, max_order),
|
||||
inner: KeySetSdk::generate(secret, unit, derivation_path, max_order),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,11 +23,11 @@ impl From<KeySetInfoSdk> for KeySetInfo {
|
||||
}
|
||||
|
||||
impl KeySetInfo {
|
||||
pub fn new(id: Arc<Id>, symbol: String) -> Self {
|
||||
pub fn new(id: Arc<Id>, unit: String) -> Self {
|
||||
Self {
|
||||
inner: KeySetInfoSdk {
|
||||
id: *id.as_ref().deref(),
|
||||
symbol,
|
||||
unit,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,11 +64,11 @@ impl From<KeySet> for JsKeySet {
|
||||
impl JsKeySet {
|
||||
/// From Hex
|
||||
#[wasm_bindgen(constructor)]
|
||||
pub fn new(id: JsId, symbol: String, keys: JsKeys) -> JsKeySet {
|
||||
pub fn new(id: JsId, unit: String, keys: JsKeys) -> JsKeySet {
|
||||
Self {
|
||||
inner: KeySet {
|
||||
id: *id.deref(),
|
||||
symbol,
|
||||
unit,
|
||||
keys: keys.deref().clone(),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ impl JsMintKeySet {
|
||||
#[wasm_bindgen(constructor)]
|
||||
pub fn generate(
|
||||
secret: String,
|
||||
symbol: String,
|
||||
unit: String,
|
||||
derivation_path: String,
|
||||
max_order: u8,
|
||||
) -> JsMintKeySet {
|
||||
Self {
|
||||
inner: KeySet::generate(secret, symbol, derivation_path, max_order),
|
||||
inner: KeySet::generate(secret, unit, derivation_path, max_order),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ interface Keys {
|
||||
};
|
||||
|
||||
interface KeySet {
|
||||
constructor(Id id, string symbol, Keys keys);
|
||||
constructor(Id id, string unit, Keys keys);
|
||||
Id id();
|
||||
Keys keys();
|
||||
};
|
||||
@@ -135,7 +135,7 @@ interface KeySet {
|
||||
|
||||
interface MintKeySet {
|
||||
[Name=generate]
|
||||
constructor(string secret, string symbol, string derivation_path, u8 max_order);
|
||||
constructor(string secret, string unit, string derivation_path, u8 max_order);
|
||||
};
|
||||
|
||||
|
||||
@@ -264,14 +264,14 @@ interface ProofsStatus {
|
||||
|
||||
|
||||
interface KeySetInfo {
|
||||
constructor(Id id, string symbol);
|
||||
constructor(Id id, string unit);
|
||||
|
||||
};
|
||||
|
||||
// Cashu Sdk
|
||||
|
||||
interface MintKeySetInfo {
|
||||
constructor(Id id, string symbol, u64 valid_from, u64? valid_to, string derivation_path, u8 max_order);
|
||||
constructor(Id id, string unit, u64 valid_from, u64? valid_to, string derivation_path, u8 max_order);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ impl From<KeySetInfoSdk> for KeySetInfo {
|
||||
impl KeySetInfo {
|
||||
pub fn new(
|
||||
id: Arc<Id>,
|
||||
symbol: String,
|
||||
unit: String,
|
||||
valid_from: u64,
|
||||
valid_to: Option<u64>,
|
||||
derivation_path: String,
|
||||
@@ -34,7 +34,7 @@ impl KeySetInfo {
|
||||
Self {
|
||||
inner: KeySetInfoSdk {
|
||||
id: *id.as_ref().deref(),
|
||||
symbol,
|
||||
unit,
|
||||
valid_from,
|
||||
valid_to,
|
||||
derivation_path,
|
||||
|
||||
@@ -35,7 +35,7 @@ impl Mint {
|
||||
) -> Self {
|
||||
let active_keyset = nut02::mint::KeySet::generate(
|
||||
secret,
|
||||
active_keyset_info.symbol.clone(),
|
||||
active_keyset_info.unit.clone(),
|
||||
active_keyset_info.derivation_path.clone(),
|
||||
active_keyset_info.max_order,
|
||||
);
|
||||
@@ -83,7 +83,7 @@ impl Mint {
|
||||
}
|
||||
|
||||
self.inactive_keysets.get(id).map(|k| {
|
||||
nut02::mint::KeySet::generate(&self.secret, &k.symbol, &k.derivation_path, k.max_order)
|
||||
nut02::mint::KeySet::generate(&self.secret, &k.unit, &k.derivation_path, k.max_order)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
@@ -92,7 +92,7 @@ impl Mint {
|
||||
/// Generate new keyset
|
||||
pub fn rotate_keyset(
|
||||
&mut self,
|
||||
symbol: impl Into<String>,
|
||||
unit: impl Into<String>,
|
||||
derivation_path: impl Into<String>,
|
||||
max_order: u8,
|
||||
) {
|
||||
@@ -100,7 +100,7 @@ impl Mint {
|
||||
self.inactive_keysets
|
||||
.insert(self.active_keyset.id, self.active_keyset_info.clone());
|
||||
|
||||
self.active_keyset = MintKeySet::generate(&self.secret, symbol, derivation_path, max_order);
|
||||
self.active_keyset = MintKeySet::generate(&self.secret, unit, derivation_path, max_order);
|
||||
}
|
||||
|
||||
pub fn process_mint_request(
|
||||
@@ -193,7 +193,7 @@ impl Mint {
|
||||
let keyset = if let Some(keyset) = self.inactive_keysets.get(&proof.id) {
|
||||
nut02::mint::KeySet::generate(
|
||||
&self.secret,
|
||||
&keyset.symbol,
|
||||
&keyset.unit,
|
||||
&keyset.derivation_path,
|
||||
keyset.max_order,
|
||||
)
|
||||
|
||||
@@ -167,7 +167,7 @@ impl KeysetResponse {
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
|
||||
pub struct KeySet {
|
||||
pub id: Id,
|
||||
pub symbol: String,
|
||||
pub unit: String,
|
||||
pub keys: Keys,
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ impl From<mint::KeySet> for KeySet {
|
||||
fn from(keyset: mint::KeySet) -> Self {
|
||||
Self {
|
||||
id: keyset.id,
|
||||
symbol: keyset.symbol,
|
||||
unit: keyset.unit,
|
||||
keys: Keys::from(keyset.keys),
|
||||
}
|
||||
}
|
||||
@@ -184,14 +184,14 @@ impl From<mint::KeySet> for KeySet {
|
||||
#[derive(Debug, Clone, Hash, PartialEq, Eq, Deserialize, Serialize)]
|
||||
pub struct KeySetInfo {
|
||||
pub id: Id,
|
||||
pub symbol: String,
|
||||
pub unit: String,
|
||||
}
|
||||
|
||||
impl From<KeySet> for KeySetInfo {
|
||||
fn from(keyset: KeySet) -> KeySetInfo {
|
||||
Self {
|
||||
id: keyset.id,
|
||||
symbol: keyset.symbol,
|
||||
unit: keyset.unit,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -211,14 +211,14 @@ pub mod mint {
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||
pub struct KeySet {
|
||||
pub id: Id,
|
||||
pub symbol: String,
|
||||
pub unit: String,
|
||||
pub keys: Keys,
|
||||
}
|
||||
|
||||
impl KeySet {
|
||||
pub fn generate(
|
||||
secret: impl Into<String>,
|
||||
symbol: impl Into<String>,
|
||||
unit: impl Into<String>,
|
||||
derivation_path: impl Into<String>,
|
||||
max_order: u8,
|
||||
) -> Self {
|
||||
@@ -252,7 +252,7 @@ pub mod mint {
|
||||
|
||||
Self {
|
||||
id: (&keys).into(),
|
||||
symbol: symbol.into(),
|
||||
unit: unit.into(),
|
||||
keys,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ pub enum InvoiceStatus {
|
||||
#[derive(Debug, Hash, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct KeysetInfo {
|
||||
pub id: Id,
|
||||
pub symbol: String,
|
||||
pub unit: String,
|
||||
pub valid_from: u64,
|
||||
pub valid_to: Option<u64>,
|
||||
pub derivation_path: String,
|
||||
@@ -47,7 +47,7 @@ impl From<KeysetInfo> for KeySetInfo {
|
||||
fn from(keyset_info: KeysetInfo) -> Self {
|
||||
Self {
|
||||
id: keyset_info.id,
|
||||
symbol: keyset_info.symbol,
|
||||
unit: keyset_info.unit,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user