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
2 changes: 2 additions & 0 deletions contracts/invoice-escrow/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ pub enum Error {
SignatureExpired = 22,
/// Funding amount does not meet the required milestone threshold.
InvalidMilestoneAmount = 23,
/// Escrow has received partial payment and cannot be cancelled.
EscrowPartiallyFunded = 24,
/// Cannot cancel because escrow is not in the correct state.
CancelNotAllowed = 24,
/// Penalty configuration is invalid (e.g. rate exceeds maximum).
Expand Down
15 changes: 12 additions & 3 deletions contracts/invoice-escrow/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2416,6 +2416,7 @@ fn test_cancel_escrow_partially_funded_refunds() {
&pt_id.address(),
&inv_token_id,
&test_commitment(&env, "test_invoice_data"),
&None,
&Some(500),
);
client.fund_escrow(&invoice_id, &buyer, &500);
Expand Down Expand Up @@ -3600,7 +3601,11 @@ fn test_set_whitelist_enabled_requires_admin_auth() {

let admin = Address::generate(&env);
let non_admin = Address::generate(&env);
escrow_client.initialize(&admin, &300);
env.invoke_contract::<()>(
&escrow_id,
&Symbol::new(&env, "initialize"),
soroban_sdk::vec![&env, admin.to_val(), 300u32.into_val(&env)],
);

let result = escrow_client.try_set_whitelist_enabled(&non_admin, &true);
assert_eq!(result, Err(Ok(Error::Unauthorized)));
Expand Down Expand Up @@ -3657,7 +3662,11 @@ fn test_set_buyer_whitelisted_requires_admin_auth() {
let admin = Address::generate(&env);
let non_admin = Address::generate(&env);
let buyer = Address::generate(&env);
escrow_client.initialize(&admin, &300);
env.invoke_contract::<()>(
&escrow_id,
&Symbol::new(&env, "initialize"),
soroban_sdk::vec![&env, admin.to_val(), 300u32.into_val(&env)],
);

let result = escrow_client.try_set_buyer_whitelisted(&non_admin, &buyer, &true);
assert_eq!(result, Err(Ok(Error::Unauthorized)));
Expand Down Expand Up @@ -5214,7 +5223,7 @@ fn test_settlement_at_exact_due_date_state_persistence() {
let payment_token_asset = AssetClient::new(&env, &payment_token_id.address());
let inv_token_id = env.register(MockInvoiceToken, ());

escrow_client.initialize(&admin, &300);
escrow_client.initialize(&admin, &0);

let seller = Address::generate(&env);
let buyer = Address::generate(&env);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,62 @@
{
"bytes": "746573745f696e766f6963655f64617461000000000000000000000000000000"
},
"void"
]
}
},
"sub_invocations": []
}
]
],
[
[
"CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOLZM",
{
"function": {
"contract_fn": {
"contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM",
"function_name": "fund_escrow",
"args": [
{
"symbol": "INV_PFUND"
},
{
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOLZM"
},
{
"i128": "500"
"i128": "400"
}
]
}
},
"sub_invocations": []
"sub_invocations": [
{
"function": {
"contract_fn": {
"contract_address": "CDLDVFKHEZ2RVB3NG4UQA4VPD3TSHV6XMHXMHP2BSGCJ2IIWVTOHGDSG",
"function_name": "transfer",
"args": [
{
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOLZM"
},
{
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM"
},
{
"i128": "400"
}
]
}
},
"sub_invocations": []
}
]
}
]
],
[],
[],
[]
],
"ledger": {
Expand Down Expand Up @@ -227,30 +273,34 @@
"symbol": "funded_amt"
},
"val": {
"i128": "0"
"i128": "400"
}
},
{
"key": {
"symbol": "funder"
},
"val": "void"
"val": {
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOLZM"
}
},
{
"key": {
"symbol": "funders"
},
"val": {
"vec": []
"vec": [
{
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOLZM"
}
]
}
},
{
"key": {
"symbol": "funding_milestone"
},
"val": {
"i128": "500"
}
"val": "void"
},
{
"key": {
Expand Down Expand Up @@ -316,6 +366,36 @@
},
"live_until": 518400
},
{
"entry": {
"last_modified_ledger_seq": 0,
"data": {
"contract_data": {
"ext": "v0",
"contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM",
"key": {
"vec": [
{
"symbol": "FunderAmount"
},
{
"symbol": "INV_PFUND"
},
{
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOLZM"
}
]
},
"durability": "persistent",
"val": {
"i128": "400"
}
}
},
"ext": "v0"
},
"live_until": 4095
},
{
"entry": {
"last_modified_ledger_seq": 0,
Expand Down Expand Up @@ -371,22 +451,6 @@
},
"val": "void"
},
{
"key": {
"symbol": "penalty_base_bps"
},
"val": {
"u32": 100
}
},
{
"key": {
"symbol": "penalty_rate_per_day_bps"
},
"val": {
"u32": 10
}
},
{
"key": {
"symbol": "whitelist_enabled"
Expand Down Expand Up @@ -441,7 +505,16 @@
"executable": {
"wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
},
"storage": null
"storage": [
{
"key": {
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOLZM"
},
"val": {
"i128": "400"
}
}
]
}
}
}
Expand Down Expand Up @@ -490,6 +563,78 @@
},
"live_until": 6311999
},
{
"entry": {
"last_modified_ledger_seq": 0,
"data": {
"contract_data": {
"ext": "v0",
"contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOLZM",
"key": {
"ledger_key_nonce": {
"nonce": "2032731177588607455"
}
},
"durability": "temporary",
"val": "void"
}
},
"ext": "v0"
},
"live_until": 6311999
},
{
"entry": {
"last_modified_ledger_seq": 0,
"data": {
"contract_data": {
"ext": "v0",
"contract": "CDLDVFKHEZ2RVB3NG4UQA4VPD3TSHV6XMHXMHP2BSGCJ2IIWVTOHGDSG",
"key": {
"vec": [
{
"symbol": "Balance"
},
{
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM"
}
]
},
"durability": "persistent",
"val": {
"map": [
{
"key": {
"symbol": "amount"
},
"val": {
"i128": "400"
}
},
{
"key": {
"symbol": "authorized"
},
"val": {
"bool": true
}
},
{
"key": {
"symbol": "clawback"
},
"val": {
"bool": false
}
}
]
}
}
},
"ext": "v0"
},
"live_until": 518400
},
{
"entry": {
"last_modified_ledger_seq": 0,
Expand All @@ -515,7 +660,7 @@
"symbol": "amount"
},
"val": {
"i128": "1000"
"i128": "600"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4"
},
{
"u32": 300
"u32": 0
}
]
}
Expand Down Expand Up @@ -501,7 +501,7 @@
"symbol": "fee_bps"
},
"val": {
"u32": 300
"u32": 0
}
},
{
Expand Down Expand Up @@ -767,7 +767,7 @@
"symbol": "amount"
},
"val": {
"i128": "60"
"i128": "0"
}
},
{
Expand Down Expand Up @@ -871,7 +871,7 @@
"symbol": "amount"
},
"val": {
"i128": "1940"
"i128": "2000"
}
},
{
Expand Down
Loading