Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #1

Merged
merged 3 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
amplify = "4.0.0-beta.17"
strict_encoding = "2.0.0-rc.1"
strict_types = "1.0.0-beta.3"
aluvm = "0.10.0-alpha.1"
bp-core = "0.10.0-beta.2"
rgb-std = { version = "0.10.0-alpha.1", features = ["serde", "fs"] }
amplify = "4.0.0-beta.20"
strict_encoding = "2.0.1"
strict_types = "1.0.0-rc.1"
aluvm = "0.10.0-rc.1"
bp-core = "0.10.0-rc.2"
rgb-std = { version = "0.10.0-rc.1", features = ["serde", "fs"] }
serde = "1.0.152"
serde_json = "1.0.93"
Binary file modified examples/rgb20-simplest.contract.rgb
Binary file not shown.
Binary file modified examples/rgb20-simplest.iimpl.rgb
Binary file not shown.
21 changes: 13 additions & 8 deletions examples/rgb20-simplest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use amplify::confinement::Confined;
use amplify::hex::FromHex;
use bp::{Chain, Outpoint, Tx, Txid};
use rgbstd::containers::BindleContent;
use rgbstd::interface::{rgb20, ContractBuilder, IfaceImpl, NamedType};
use rgbstd::interface::{rgb20, ContractBuilder, FungibleAllocation, IfaceImpl, NamedType};
use rgbstd::persistence::{Inventory, Stock};
use rgbstd::resolvers::ResolveHeight;
use rgbstd::schema::{
Expand Down Expand Up @@ -106,7 +106,7 @@ fn iface_impl() -> IfaceImpl {
NamedType::with(GS_NOMINAL, tn!("Nominal")),
NamedType::with(GS_CONTRACT, tn!("ContractText")),
},
owned_state: tiny_bset! {
assignments: tiny_bset! {
NamedType::with(OS_ASSETS, tn!("Assets")),
},
valencies: none!(),
Expand Down Expand Up @@ -146,7 +146,7 @@ fn main() {

.add_global_state("Nominal", nominal)
.expect("invalid nominal")

.add_global_state("ContractText", contract_text)
.expect("invalid contract text")

Expand All @@ -157,7 +157,7 @@ fn main() {
.expect("contract doesn't fit schema requirements");

let contract_id = contract.contract_id();

let bindle = contract.bindle();
eprintln!("{bindle}");
bindle.save("examples/rgb20-simplest.contract.rgb").expect("unable to save contract");
Expand All @@ -169,16 +169,21 @@ fn main() {
stock.import_iface_impl(iface_impl()).unwrap();

// Noe we verify our contract consignment and add it to the stock
let verified_contract = bindle.unbindle().validate(&mut DumbResolver).expect("failed contract");
let verified_contract = match bindle.unbindle().validate(&mut DumbResolver) {
Ok(consignment) => consignment,
Err(consignment) => {
panic!("can't produce valid consignment. Report: {}", consignment.validation_status().expect("status always present upon validation"));
}
};
stock.import_contract(verified_contract, &mut DumbResolver).unwrap();

// Reading contract state through the interface from the stock:
let contract = stock.contract_iface(contract_id, rgb20().iface_id()).unwrap();
let nominal = contract.global("Nominal").unwrap();
let allocations = contract.fungible("Assets").unwrap();
eprintln!("{}", nominal[0]);

for (txout, amount) in allocations {
eprintln!("(amount={amount}, txout={txout})");
for FungibleAllocation { owner, witness, value } in allocations {
eprintln!("(amount={value}, owner={owner}, witness={witness})");
}
}