Skip to content
Open
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
7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ members = [
"scenarios",

"testutils",
<<<<<<< test/insurance-auth-lifecycle-matrix
"integration_tests",
"remitwise-common",
=======
>>>>>>> main

"integration_tests",
]
Expand Down Expand Up @@ -51,6 +46,8 @@ orchestrator = { path = "./orchestrator" }

[dev-dependencies]
soroban-sdk = { version = "=21.7.7", features = ["testutils"] }
remitwise-common = { path = "./remitwise-common" }
orchestrator = { path = "./orchestrator" }

[profile.release]
opt-level = "z"
Expand Down
26 changes: 13 additions & 13 deletions bill_payments/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@
use remitwise_common::{
clamp_limit, EventCategory, EventPriority, RemitwiseEvents, ARCHIVE_BUMP_AMOUNT,
ARCHIVE_LIFETIME_THRESHOLD, CONTRACT_VERSION, INSTANCE_BUMP_AMOUNT,
INSTANCE_LIFETIME_THRESHOLD, MAX_BATCH_SIZE,
};
#[cfg(test)]
use remitwise_common::{DEFAULT_PAGE_LIMIT, MAX_PAGE_LIMIT};
INSTANCE_LIFETIME_THRESHOLD, MAX_BATCH_SIZE, MAX_PAGE_LIMIT,
};
#[cfg(test)]
use remitwise_common::DEFAULT_PAGE_LIMIT;

use soroban_sdk::{
contract, contracterror, contractimpl, contracttype, symbol_short, Address, Env, Map, String,
Symbol, Vec,
};

const MAX_FREQUENCY_DAYS: u32 = 36500; // 100 years
const SECONDS_PER_DAY: u64 = 86400;

#[contracttype]
#[derive(Clone, Debug)]
Expand Down Expand Up @@ -97,8 +93,13 @@ pub enum BillPaymentsError {
InvalidTag = 13,
/// Tags list is empty
EmptyTags = 14,
/// Currency code is invalid
InvalidCurrency = 15,
}

/// Type alias so that `Error` works as shorthand throughout the impl block.
type Error = BillPaymentsError;

#[contracttype]
#[derive(Clone)]
pub struct ArchivedBill {
Expand Down Expand Up @@ -140,9 +141,8 @@ pub enum BillEvent {
ScheduleCancelled,
}

#[derive(Clone, Debug)]
#[contracttype]
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct StorageStats {
pub active_bills: u32,
pub archived_bills: u32,
Expand Down Expand Up @@ -452,8 +452,6 @@ impl BillPayments {
return Err(Error::Unauthorized);
}
}
Some(adm) if adm != caller => return Err(BillPaymentsError::Unauthorized),
_ => {}
}

env.storage()
Expand Down Expand Up @@ -574,6 +572,7 @@ impl BillPayments {
+ 1;

let current_time = env.ledger().timestamp();
let bill_external_ref = external_ref.clone();
let bill = Bill {
id: next_id,
owner: owner.clone(),
Expand Down Expand Up @@ -680,6 +679,7 @@ impl BillPayments {

let paid_amount = bill.amount;
let was_recurring = bill.recurring;
let bill_external_ref = bill.external_ref.clone();
bills.set(bill_id, bill);
env.storage()
.instance()
Expand Down Expand Up @@ -1188,7 +1188,6 @@ impl BillPayments {
id: archived_bill.id,
owner: archived_bill.owner.clone(),
name: archived_bill.name.clone(),
external_ref: None,
external_ref: archived_bill.external_ref.clone(),
amount: archived_bill.amount,
due_date: env.ledger().timestamp() + 2592000,
Expand Down Expand Up @@ -1696,7 +1695,7 @@ mod test {
use proptest::prelude::*;
use soroban_sdk::{
testutils::{Address as _, Ledger},
Env, String,
Env, IntoVal, String,
};

fn make_env() -> Env {
Expand Down Expand Up @@ -2654,7 +2653,7 @@ mod test {
n in 1usize..6usize,
) {
let env = make_env();
env.ledger().set_timestamp(now);
env.ledger().set_timestamp(1);
env.mock_all_auths();
let cid = env.register_contract(None, BillPayments);
let client = BillPaymentsClient::new(&env, &cid);
Expand All @@ -2674,6 +2673,7 @@ mod test {
);
}

env.ledger().set_timestamp(now);
let page = client.get_overdue_bills(&0, &50);
prop_assert_eq!(
page.count,
Expand Down
76 changes: 60 additions & 16 deletions docs/family-wallet-design.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/bill_payments_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn main() {

// 6. [Write] Pay the bill
println!("\nPaying bill with ID: {}...", bill_id);
client.pay_bill(&owner, &bill_id).unwrap();
client.pay_bill(&owner, &bill_id);
println!("Bill paid successfully!");

// 7. [Read] Verify bill is no longer in unpaid list
Expand Down
3 changes: 2 additions & 1 deletion examples/family_wallet_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ fn main() {

println!("--- Remitwise: Family Wallet Example ---");

// 4. [Write] Initialize the wallet with an owner and some initial members
// 4. [Write] Initialize the wallet. Do not include `owner` in `initial_members`
// (the contract rejects that to preserve FamilyRole::Owner).
println!("Initializing wallet with owner: {:?}", owner);
let mut initial_members = Vec::new(&env);
initial_members.push_back(owner.clone());
Expand Down
10 changes: 5 additions & 5 deletions examples/insurance_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn main() {
let contract_id = env.register_contract(None, Insurance);
let client = InsuranceClient::new(&env, &contract_id);

// 3. Generate a mock owner address
// 3. Generate a mock address for the user
let owner = Address::generate(&env);

println!("--- Remitwise: Insurance Example ---");
Expand All @@ -37,7 +37,7 @@ fn main() {
println!("Policy created successfully with ID: {}", policy_id);

// 5. [Read] List active policies
let policy_page = client.get_active_policies(&owner, &0, &5);
let policy_page = client.get_active_policies(&owner, &0, &10);
println!("\nActive Policies for {:?}:", owner);
for policy in policy_page.items.iter() {
println!(
Expand All @@ -46,9 +46,9 @@ fn main() {
);
}

// 6. [Write] Pay a premium
println!("\nPaying premium for policy ID: {}...", policy_id);
client.pay_premium(&owner, &policy_id).unwrap();
// 6. [Write] Pay policy premium
println!("\nPaying premium for Policy ID: {}", policy_id);
client.pay_premium(&owner, &policy_id);
println!("Premium paid successfully!");

// 7. [Read] Verify policy status (next payment date updated)
Expand Down
10 changes: 5 additions & 5 deletions examples/orchestrator_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ fn main() {
let caller = Address::generate(&env);

// Contract addresses
let family_wallet_addr = Address::generate(&env);
let remittance_split_addr = Address::generate(&env);
let savings_addr = Address::generate(&env);
let bills_addr = Address::generate(&env);
let insurance_addr = Address::generate(&env);
let _family_wallet_addr = Address::generate(&env);
let _remittance_split_addr = Address::generate(&env);
let _savings_addr = Address::generate(&env);
let _bills_addr = Address::generate(&env);
let _insurance_addr = Address::generate(&env);

// Resource IDs
let goal_id = 1u32;
Expand Down
2 changes: 1 addition & 1 deletion examples/remittance_split_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() {
// 4. [Write] Initialize the split configuration
// Percentages: 50% Spending, 30% Savings, 15% Bills, 5% Insurance
println!("Initializing split configuration for owner: {:?}", owner);
client.initialize_split(&owner, &0, &50, &30, &15, &5);
client.initialize_split(&owner, &0, &owner, &50, &30, &15, &5);

// 5. [Read] Verify the configuration
let config = client.get_config().unwrap();
Expand Down
6 changes: 3 additions & 3 deletions examples/reporting_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ fn main() {
env.mock_all_auths();

// 2. Register the Reporting contract
let contract_id = env.register_contract(None, reporting::Reporting);
let client = ReportingClient::new(&env, &contract_id);
let contract_id = env.register_contract(None, ReportingContract);
let client = ReportingContractClient::new(&env, &contract_id);

// 3. Generate mock addresses for dependencies and admin
let admin = Address::generate(&env);
Expand All @@ -29,7 +29,7 @@ fn main() {

// 4. [Write] Initialize the contract
println!("Initializing Reporting contract with admin: {:?}", admin);
client.init(&admin).unwrap();
client.init(&admin);

// 5. [Write] Configure contract addresses
println!("Configuring dependency addresses...");
Expand Down
6 changes: 3 additions & 3 deletions examples/savings_goals_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() {
// 4. [Write] Create a new savings goal
let goal_name = String::from_str(&env, "Emergency Fund");
let target_amount = 5000i128;
let target_date = env.ledger().timestamp() + 31536000; // 1 year from now
let due_date = env.ledger().timestamp() + 31536000; // 1 year from now

println!(
"Creating savings goal: '{}' with target: {}",
Expand All @@ -32,15 +32,15 @@ fn main() {
// 5. [Read] Fetch the goal to check progress
let goal = client.get_goal(&goal_id).unwrap();
println!("\nGoal Details:");
println!(" Name: {}", goal.name);
println!(" ID: {}, Name: {:?}", goal.id, goal.name);
println!(" Current Amount: {}", goal.current_amount);
println!(" Target Amount: {}", goal.target_amount);
println!(" Locked: {}", goal.locked);

// 6. [Write] Add funds to the goal
let contribution = 1000i128;
println!("\nContributing {} to the goal...", contribution);
let new_total = client.add_to_goal(&owner, &goal_id, &contribution).unwrap();
let new_total = client.add_to_goal(&owner, &goal_id, &contribution);
println!("Contribution successful! New total: {}", new_total);

// 7. [Read] Verify progress again
Expand Down
Loading
Loading