Skip to content
This repository has been archived by the owner on Dec 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #19 from LNP-BP/feat/epochs
Browse files Browse the repository at this point in the history
RGB: Fungible assets update: burn, replacement, renomination
  • Loading branch information
dr-orlovsky authored Oct 10, 2020
2 parents 2c5d539 + d283cf2 commit b756d0a
Show file tree
Hide file tree
Showing 11 changed files with 309 additions and 152 deletions.
46 changes: 23 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ electrum-client = "=0.3.0-beta.1"

[dependencies.lnpbp]
git = "https://github.com/LNP-BP/rust-lnpbp"
tag = "v0.1.0-rc.1"
branch = "master"
features = ["all"]

[dependencies.lnpbp_derive]
git = "https://github.com/LNP-BP/rust-lnpbp"
tag = "v0.1.0-rc.1"
branch = "master"

[target.'cfg(target_os="android")'.dependencies.zmq]
version = "~0.9"
Expand All @@ -71,6 +71,5 @@ bitcoin = { git = "https://github.com/LNP-BP/rust-bitcoin", tag = "lnpbp-v0.1.0-
# We need custom branches here just to depend on the same bitcoin master and do
# not have secp256k1 version conflict
miniscript = { git = "https://github.com/LNP-BP/rust-miniscript", tag = "lnpbp-v0.1.0-rc1" }
# Remove this once https://github.com/teawithsand/torut/pull/5 got merged
# Remove this once https://github.com/jean-airoldie/zeromq-src-rs/pull/15 got merged
zeromq-src = { git = "https://github.com/LNP-BP/zeromq-src-rs", branch = "fix/cmake" }
2 changes: 2 additions & 0 deletions ffi/ios/DemoApp/RGB Demo App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@
CODE_SIGN_ENTITLEMENTS = "RGB Demo App/RGB Demo App.entitlements";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = BLS4N8A6L6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = "RGB Demo App/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -377,6 +378,7 @@
CODE_SIGN_ENTITLEMENTS = "RGB Demo App/RGB Demo App.entitlements";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = BLS4N8A6L6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = "RGB Demo App/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
4 changes: 0 additions & 4 deletions ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use rgb::lnpbp::bitcoin::OutPoint;

use rgb::lnpbp::bp;
use rgb::lnpbp::lnp::transport::zmq::{SocketLocator, UrlError};
use rgb::lnpbp::rgb::Amount;

use rgb::fungible::{Invoice, IssueStructure, Outcoins};
use rgb::i9n::*;
Expand Down Expand Up @@ -188,8 +187,6 @@ struct IssueArgs {
precision: u8,
#[serde(default)]
prune_seals: Vec<SealSpec>,
#[serde(default)]
dust_limit: Option<Amount>,
}

fn _issue(runtime: &COpaqueStruct, json: *mut c_char) -> Result<(), String> {
Expand All @@ -208,7 +205,6 @@ fn _issue(runtime: &COpaqueStruct, json: *mut c_char) -> Result<(), String> {
data.allocations,
data.precision,
data.prune_seals,
data.dust_limit,
)
.map_err(|e| format!("{:?}", e))
}
Expand Down
6 changes: 1 addition & 5 deletions src/api/fungible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use serde::{Deserialize, Serialize};
use lnpbp::bitcoin::util::psbt::PartiallySignedTransaction;
use lnpbp::bitcoin::OutPoint;
use lnpbp::bp::blind::OutpointReveal;
use lnpbp::rgb::{Amount, Consignment, ContractId};
use lnpbp::rgb::{Consignment, ContractId};

use crate::fungible::{Outcoincealed, Outcoins};
use crate::util::SealSpec;
Expand Down Expand Up @@ -81,10 +81,6 @@ pub struct Issue {
#[clap(short, long, default_value = "0")]
pub precision: u8,

/// Dust limit for asset transfers; defaults to no limit
#[clap(short = 'D', long)]
pub dust_limit: Option<Amount>,

/// Asset allocation, in form of <amount>@<txid>:<vout>
#[clap(required = true)]
pub allocate: Vec<Outcoins>,
Expand Down
23 changes: 9 additions & 14 deletions src/contracts/fungible/data/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ pub struct Asset {
name: String,
description: Option<String>,
supply: Supply,
dust_limit: Coins,
#[serde(with = "serde_with::rust::display_fromstr")]
chain: bp::Chain,
fractional_bits: u8,
Expand Down Expand Up @@ -181,23 +180,23 @@ impl TryFrom<Genesis> for Asset {
Err(SchemaError::WrongSchemaId)?;
}
let genesis_meta = genesis.metadata();
let fractional_bits = genesis_meta.u8(-FieldType::Precision)?;
let fractional_bits = genesis_meta.u8(*FieldType::Precision)?;
let supply = Coins::with_sats_precision(
genesis_meta.u64(-FieldType::IssuedSupply)?,
genesis_meta.u64(*FieldType::IssuedSupply)?,
fractional_bits,
);

let node_id = NodeId::from_inner(genesis.contract_id().into_inner());
let issue = Issue {
id: genesis.contract_id(),
txo: genesis
.known_seal_definitions_by_type(-OwnedRightsType::Issue)
.known_seal_definitions_by_type(*OwnedRightsType::Issue)
.first()
.and_then(|i| bitcoin::OutPoint::try_from((*i).clone()).ok()),
supply: supply.clone(),
};
let mut known_allocations = BTreeMap::<bitcoin::OutPoint, Vec<Allocation>>::default();
for variant in genesis.owned_rights_by_type(-OwnedRightsType::Assets) {
for variant in genesis.owned_rights_by_type(*OwnedRightsType::Assets) {
if let Assignments::DiscreteFiniteField(tree) = variant {
tree.iter().enumerate().for_each(|(index, assign)| {
if let OwnedState::Revealed {
Expand All @@ -220,22 +219,18 @@ impl TryFrom<Genesis> for Asset {
Ok(Self {
id: genesis.contract_id(),
chain: genesis.chain().clone(),
ticker: genesis_meta.string(-FieldType::Ticker)?,
name: genesis_meta.string(-FieldType::Name)?,
description: genesis_meta.string(-FieldType::Description).next(),
ticker: genesis_meta.string(*FieldType::Ticker)?,
name: genesis_meta.string(*FieldType::Name)?,
description: genesis_meta.string(*FieldType::Description).next(),
supply: Supply {
known_circulating: supply.clone(),
total: Some(Coins::with_sats_precision(
genesis_meta.u64(-FieldType::TotalSupply)?,
genesis_meta.u64(*FieldType::TotalSupply)?,
fractional_bits,
)),
},
dust_limit: Coins::with_sats_precision(
genesis_meta.u64(-FieldType::DustLimit)?,
fractional_bits,
),
fractional_bits,
date: NaiveDateTime::from_timestamp(genesis_meta.i64(-FieldType::Timestamp)?, 0),
date: NaiveDateTime::from_timestamp(genesis_meta.i64(*FieldType::Timestamp)?, 0),
unspent_issue_txo: None,
known_issues: vec![list! { issue }],
// we assume that each genesis allocation with revealed amount
Expand Down
Loading

0 comments on commit b756d0a

Please sign in to comment.